/* ============================================================
   FORGE — forge_app_main.css
   App shell: sidebar, topbar, chat, members panel
   Rail/navbar styles live in forge_app_navbar.css
   ============================================================ */

#page-app {
  display: none;
  height: 100vh;
  overflow: hidden;
}
#page-app.active { display: flex; }

/* ══════════════════════════════════════
   SIDEBAR FOOTER (User bar)
   ══════════════════════════════════════ */
.sidebar {
  position: relative;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding-bottom: 52px; /* Make room for fixed footer */
}
.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.sidebar-header:hover { background: var(--bg-hover); }
.sidebar-header-info { flex: 1; min-width: 0; }
.sidebar-server-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-server-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-server-sub:empty { display: none; }
.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 0;
}

/* ── Sidebar sections ── */
.sidebar-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.sidebar-section-add {
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.sidebar-section-add:hover { color: var(--text-primary); }
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 1px 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav-item.active { background: var(--bg-active); color: var(--text-primary); }
.sidebar-nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

/* ── Categories & channels (DM rows share .ch-item) ── */
.ch-category {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  user-select: none;
}
.ch-category:hover { color: var(--text-secondary); }
.ch-category-chevron { flex-shrink: 0; transition: transform var(--transition-fast); }
.ch-category.collapsed .ch-category-chevron { transform: rotate(-90deg); }
.ch-category-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-category-actions,
.ch-item-actions {
  display: none;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.ch-category:hover .ch-category-actions,
.ch-item:hover .ch-item-actions { display: flex; }
.ch-category-gear,
.ch-category-add,
.ch-action-btn {
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.ch-category-gear:hover,
.ch-category-add:hover,
.ch-action-btn:hover { color: var(--text-primary); }
.ch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 1px 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.ch-item:hover  { background: var(--bg-hover); color: var(--text-primary); }
.ch-item.active { background: var(--bg-active); color: var(--text-primary); }
.ch-icon { width: 18px; text-align: center; color: var(--text-muted); flex-shrink: 0; }
.ch-call-timer {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--green, #3ba55d);
}
.ch-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: calc(-1 * var(--rail-width));
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-sidebar-footer);
  border-top: 1px solid var(--border);
  min-height: 52px;
  z-index: 11; /* Spans under the rail, so it must sit above .rail */
}
.sf-discovery-wrap {
  flex-shrink: 0;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-frame);
  transition: background var(--transition-fast);
}
.sf-discovery-wrap:hover { background: var(--bg-hover); }
.sf-discovery-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.sf-discovery-wrap:hover .sf-discovery-icon { color: var(--text-secondary); border-color: var(--text-muted); }
.sf-discovery-icon.active { color: var(--yellow); border-color: var(--yellow); background: var(--bg-rail); }
.sf-discovery-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-sidebar-footer);
}
.sf-user-block {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 100px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background var(--transition-fast);
}
.sf-user-block:hover { background: var(--bg-hover); }
.sf-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.sf-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; position: absolute; inset: 0; }
.sf-avatar-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-sidebar-footer);
  z-index: 2;
}
.sf-info { min-width: 0; }
.sf-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.sf-status-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.sf-status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }

.sf-action {
  width: 30px; height: 30px;
  border-radius: var(--radius-frame);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
  border: 2.5px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
  font-size: 15px;
  font-family: var(--font-body);
}
.sf-action:hover { color: var(--text-secondary); background: var(--bg-hover); }
.sf-action.active { border-color: var(--yellow); color: var(--yellow); background: var(--bg-rail); }

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main);
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-main);
}
.topbar-ch-icon  { font-size: 18px; color: var(--text-muted); flex-shrink: 0; }
.topbar-ch-name  { font-size: 15px; font-weight: 700; color: var(--text-primary); flex-shrink: 0; }
.topbar-ch-desc  {
  font-size: 13px;
  color: var(--text-muted);
  border-left: 1px solid var(--border-strong);
  padding-left: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-ch-desc:empty { display: none; }
.topbar-actions  { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topbar-btn {
  width: 30px; height: 30px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.topbar-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Chat area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px;
  color: var(--text-secondary);
}
.chat-welcome-icon { font-size: 56px; margin-bottom: 16px; }
.chat-welcome h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.chat-welcome p { font-size: 14px; max-width: 340px; line-height: 1.7; }

/* ── Server overview ── */
.overview-page {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  flex-shrink: 0;
}
.overview-banner {
  height: 200px;
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  background-size: cover;
  background-position: center;
}
.overview-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  margin-top: -36px;
}
.overview-icon {
  width: 80px; height: 80px;
  border-radius: var(--radius-lg);
  border: 3px solid var(--bg-main);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.overview-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.overview-header-info { min-width: 0; padding-top: 36px; }
.overview-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.overview-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.overview-section { margin-top: 24px; }
.overview-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.overview-about {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.overview-empty { font-size: 13px; color: var(--text-muted); }
.overview-post {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.overview-post:hover { border-color: var(--border-strong); }
.overview-post-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.overview-post-author { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.overview-post-meta { font-size: 11px; color: var(--text-muted); }

.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 8px;
  flex-shrink: 0;
}
.chat-date-line { flex: 1; height: 1px; background: var(--border); }
.chat-date-text { font-size: 11px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }

/* ── Messages ── */
.message {
  display: flex;
  gap: 12px;
  padding: 4px 16px;
  transition: background var(--transition-fast);
  position: relative;
}
.message:hover { background: rgba(0,0,0,0.1); }
.message:hover .msg-actions { opacity: 1; pointer-events: all; }

.message.is-compact { padding-top: 1px; padding-bottom: 1px; }
.message.is-compact .msg-avatar { visibility: hidden; height: 0; margin: 0; overflow: hidden; }

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  margin-top: 2px;
  cursor: pointer;
  overflow: hidden;
}

.msg-body { flex: 1; min-width: 0; }
.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.msg-author { font-size: 14px; font-weight: 700; cursor: pointer; line-height: 1; color: var(--text-primary); }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 11px; color: var(--text-muted); line-height: 1; }

.msg-badge { font-size: 10px; padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.msg-badge-mod { background: rgba(var(--accent-rgb),0.15); color: var(--yellow); }
.msg-badge-bot { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(91,141,238,0.3); }

.msg-text {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.55;
  word-break: break-word;
}

/* Multiline / preformatted messages */
.msg-pre {
  font-family: var(--font-mono, 'Consolas', 'Courier New', monospace);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
  margin: 0;
  padding: 8px 12px;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-strong);
  color: var(--text-primary);
  max-width: 100%;
}
.msg-text a     { color: var(--blue); }
.msg-text a:hover { text-decoration: underline; }
.msg-text code  {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.msg-text strong { font-weight: 700; }
.msg-text em     { font-style: italic; }

.msg-reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}
.msg-reaction:hover  { background: rgba(255,255,255,0.1); border-color: var(--border-strong); }
.msg-reaction.active { background: rgba(var(--accent-rgb),0.15); border-color: rgba(var(--accent-rgb),0.4); }
.msg-reaction-count  { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

.msg-actions {
  position: absolute;
  right: 16px; top: -6px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  gap: 1px;
  padding: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 10;
  box-shadow: var(--shadow-md);
}
.msg-action-btn {
  width: 30px; height: 30px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.msg-action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Message input ── */
.chat-input-area { padding: 0 16px 16px; flex-shrink: 0; }

.chat-input-wrap {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color var(--transition-base);
}
.chat-input-wrap:focus-within { border-color: var(--border-strong); }

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
}

.chat-attach-btn {
  width: 30px; height: 30px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}
.chat-attach-btn:hover { color: var(--text-secondary); }

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  resize: none;
  min-height: 24px;
  max-height: 200px;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 0;
}
.chat-input::placeholder { color: var(--text-muted); }

.chat-emoji-btn {
  width: 30px; height: 30px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}
.chat-emoji-btn:hover { color: var(--text-secondary); }

.typing-indicator { padding: 0 16px 4px; font-size: 12px; color: var(--text-muted); min-height: 18px; }

/* ══════════════════════════════════════
   MEMBERS PANEL
   bg: #26282d, width: 232px
══════════════════════════════════════ */
.members-panel {
  width: var(--members-width);
  min-width: var(--members-width);
  background: var(--bg-members);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.members-panel.collapsed { display: none; }

.members-body { flex: 1; overflow-y: auto; padding: 8px 0 16px; }

.members-role-label {
  padding: 12px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.members-role-count { font-size: 11px; font-weight: 700; color: var(--text-muted); }

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 4px;
  transition: background var(--transition-fast);
}
.member-item:hover { background: var(--bg-hover); }

.member-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  background: rgba(30,32,36,0.6);
  flex-shrink: 0;
  position: relative;
}
.member-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.member-status {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-members);
}
.member-info { flex: 1; min-width: 0; }
.member-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-tag { display: flex; margin-top: 2px; min-width: 0; }
.member-tag .user-tag { padding: 1px 7px; gap: 4px; font-size: 10px; line-height: 14px; }
.member-tag .user-tag svg { width: 10px; height: 10px; }
.member-status-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.members-invite-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 4px 4px 0;
  color: var(--text-muted);
  font-size: 13px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.members-invite-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.members-invite-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px dashed var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Reply bar ── */
.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  font-size: 13px;
  color: var(--text-secondary);
  gap: 8px;
}

.reply-bar-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.reply-bar-icon  { color: var(--yellow); font-size: 14px; flex-shrink: 0; }
.reply-bar-label { flex-shrink: 0; }
.reply-bar-label strong { color: var(--text-primary); }

.reply-bar-preview {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-bar-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color var(--transition-fast);
}
.reply-bar-cancel:hover { color: var(--text-primary); }

/* Reply preview inside message */
.msg-reply-preview {
  font-size: 12px;
  color: var(--text-muted);
  border-left: 2px solid var(--border-strong);
  padding: 2px 8px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

/* ── Member context menu ── */
.member-ctx-menu {
  position: fixed;
  z-index: 3000;
  background: var(--bg-panel, #1a1b1e);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: min(270px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-x: hidden;
  overflow-y: auto;
  animation: ctx-pop 0.1s ease;
}

@keyframes ctx-pop {
  from { opacity:0; transform: scale(0.95); }
  to   { opacity:1; transform: scale(1); }
}

.member-ctx-header {
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border);
}

.member-ctx-banner {
  height: 76px;
  margin: 0 -14px;
  background-color: var(--bg-hover);
  background-position: center;
  background-size: cover;
}

.member-ctx-avatar {
  width: 64px; height: 64px;
  margin: -34px 0 8px;
  border: 4px solid var(--bg-panel, #1a1b1e);
  box-sizing: content-box;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.member-ctx-avatar img { position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-radius:50%; }

.member-ctx-name   { overflow: hidden; font-size: 16px; font-weight: 700; color: var(--text-primary); text-overflow: ellipsis; white-space: nowrap; }
.member-ctx-tag    { margin-top: 8px; }
.member-ctx-about  { max-height: 90px; margin-top: 8px; overflow-y: auto; color: var(--text-secondary); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.member-ctx-status { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.member-ctx-items { padding: 4px 0; }

.member-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}
.member-ctx-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.member-ctx-item.danger { color: var(--red); }
.member-ctx-item.danger:hover { background: rgba(224,82,82,0.1); color: var(--red); }

.member-ctx-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }

.member-ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Message links ── */
.msg-link {
  color: #5b9bd5;
  text-decoration: underline;
  text-decoration-color: rgba(91,155,213,0.4);
  cursor: pointer;
  word-break: break-all;
  transition: color var(--transition-fast);
}
.msg-link:hover {
  color: #7ab3e0;
  text-decoration-color: #7ab3e0;
}

/* ── Server dropdown menu ── */
.server-dropdown {
  position: absolute;
  top: 56px; /* just below sidebar header */
  left: 8px;
  right: 8px;
  background: var(--bg-rail);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 500;
  overflow: hidden;
  animation: dd-pop 0.12s ease;
  padding: 4px 0;
}

@keyframes dd-pop {
  from { opacity:0; transform: translateY(-6px) scale(0.97); }
  to   { opacity:1; transform: translateY(0)   scale(1); }
}

.server-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}
.server-dd-item:hover      { background: var(--bg-hover); color: var(--text-primary); }
.server-dd-item svg        { flex-shrink: 0; color: var(--text-muted); }
.server-dd-item:hover svg  { color: var(--text-primary); }

.server-dd-highlight       { color: var(--yellow); font-weight: 600; }
.server-dd-highlight svg   { color: var(--yellow); }
.server-dd-highlight:hover { background: rgba(var(--accent-rgb),0.08); color: var(--yellow); }

.server-dd-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Chevron rotation when open */
.sidebar-header.open .sidebar-chevron {
  transform: rotate(180deg);
  transition: transform 0.2s ease;
}
.sidebar-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

/* Sidebar needs position relative for dropdown absolute positioning */
.sidebar { position: relative; }

/* ══════════════════════════════════════
   MEDIA CHANNEL
   ═════════════════════════════════════ */
.media-channel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.media-channel-icon {
  color: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 8px;
}
.media-channel-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.media-channel-empty p {
  font-size: 14px;
  margin: 0;
}

/* ═════════════════════════════════════
   ANNOUNCEMENT CHANNEL
   ════════════════════════════════════ */
.announce-composer {
  width: 100%;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}
.announce-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 8px;
}
.announce-tool {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.announce-tool:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.announce-tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 4px 6px;
}
.announce-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 80px;
  transition: border-color 0.15s;
}
.announce-input:focus {
  outline: none;
  border-color: var(--yellow);
}
.announce-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.announce-notify {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.announce-btns {
  display: flex;
  gap: 8px;
}

/* ═════════════════════════════════════
   VOICE CHANNEL
   ═══════════════════════════════════ */
.voice-channel-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.voice-lobby-col {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}
.voice-lobby-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.voice-lobby-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}
.voice-lobby-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.voice-lobby-join-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.voice-lobby-join-btn:hover {
  background: #3da35d;
}
.voice-lobby-join-btn.active {
  background: var(--red);
}
.voice-lobby-join-btn.active:hover {
  background: #c0392b;
}
.voice-lobby-users {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}
.voice-lobby-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 120px;
  color: var(--text-muted);
  font-size: 13px;
}
.voice-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
}
.voice-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-hover);
}
.voice-user-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}
.voice-chat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.voice-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Voice Panel (sidebar footer when connected) */
.sidebar-footer.voice-active {
  flex-direction: column;
  padding: 0;
}
.voice-user-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
}
.voice-panel {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.voice-panel-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.voice-panel-connected {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}
.voice-panel-ping {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: 4px;
}
.voice-panel-actions {
  display: flex;
  gap: 6px;
}
.voice-panel-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.voice-panel-action:hover {
  background: var(--border);
  color: var(--text-primary);
}

.voice-panel-action.on {
  background: var(--red);
  color: #fff;
}
.voice-panel-action.leave:hover {
  background: var(--red);
  color: #fff;
}
.voice-panel-connected.pending {
  color: var(--text-muted);
}
.voice-panel-ping.poor {
  color: var(--red);
}
.voice-panel-ping:empty {
  display: none;
}
.voice-panel-channel {
  display: block;
  width: 100%;
  margin: -4px 0 8px;
  padding: 0;
  overflow: hidden;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.voice-panel-channel:hover {
  color: var(--text-primary);
  text-decoration: underline;
}
.voice-user-avatar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}
.voice-user-item.speaking .voice-user-avatar,
.ch-voice-user.speaking .voice-user-avatar {
  box-shadow: 0 0 0 2px var(--green);
}
.voice-user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-user-state {
  display: flex;
  color: var(--text-muted);
}
.ch-voice-users:empty {
  display: none;
}
.ch-voice-users {
  padding: 2px 0 4px 28px;
}
.ch-voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
}
.ch-voice-user .voice-user-avatar {
  width: 20px;
  height: 20px;
  font-size: 8px;
}
.ch-voice-user .voice-user-name {
  font-size: 12px;
  color: var(--text-secondary);
}
.voice-mic-test {
  display: flex;
  align-items: center;
  gap: 12px;
}
.voice-mic-meter {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-hover);
}
#voice-mic-level {
  width: 0;
  height: 100%;
  background: var(--green);
}
.voice-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-primary);
}

/* Voice & Audio: microphone and speakers side by side, one column on a phone */
.voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
  margin-bottom: 16px;
}
@media (max-width: 600px) { .voice-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
.voice-col .form-group { margin-bottom: 12px; }
.voice-range-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.voice-range-row .form-label { margin-bottom: 4px; }
.voice-range-value {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.voice-range {
  width: 100%;
  margin: 4px 0 0;
  accent-color: var(--gold);
  cursor: pointer;
}
.voice-sensitivity { position: relative; padding-top: 2px; }
.voice-sensitivity-meter {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-hover);
}
#voice-sensitivity-level {
  width: 0;
  height: 100%;
  background: var(--text-muted);
  transition: width 60ms linear;
}
#voice-sensitivity-level.over { background: var(--green); }
#voice-sensitivity-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--gold);
}
.voice-ptt { padding: 4px 0 8px; }
.voice-ptt-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.voice-ptt-key {
  min-width: 96px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-primary);
  font: 600 13px/1.2 inherit;
  text-align: center;
}
.voice-ptt-key.unset { color: var(--text-muted); font-weight: 400; }
.voice-ptt-key.listening { border-color: var(--gold); color: var(--gold); }
.voice-camera-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--bg-hover);
}
.voice-camera-preview video { display: none; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.voice-camera-preview.live video { display: block; }
.voice-camera-preview.live #voice-camera-note { display: none; }
#voice-camera-note { padding: 12px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* Push to talk: the Talk button in the voice panel */
.voice-panel-ptt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.voice-panel-ptt.held { border-color: var(--green); background: var(--green); color: #fff; }

/* ═════════════════════════════════════
   FORUM CHANNEL
   ════════════════════════════════════ */
.forum-channel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.forum-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.forum-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.forum-thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.forum-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.forum-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.forum-empty-icon {
  color: var(--text-muted);
  opacity: 0.4;
  margin-bottom: 16px;
}
.forum-empty h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
}
.forum-empty p {
  font-size: 14px;
  margin: 0;
}
.forum-error {
  padding: 20px;
  color: var(--red);
  font-size: 14px;
  text-align: center;
}
.forum-thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.forum-thread-item:hover {
  background: var(--bg-hover);
}
.forum-thread-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-hover);
  flex-shrink: 0;
}
.forum-thread-content {
  flex: 1;
  min-width: 0;
}
.forum-thread-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.forum-thread-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.forum-thread-dot {
  opacity: 0.5;
}
.forum-thread-replies {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.forum-reply-count {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.forum-reply-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Thread View */
.forum-thread-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.forum-thread-back {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.forum-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.forum-back-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.forum-thread-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.forum-thread-post {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.forum-post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-hover);
  flex-shrink: 0;
}
.forum-post-body {
  flex: 1;
  min-width: 0;
}
.forum-post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.forum-post-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.forum-post-time {
  font-size: 12px;
  color: var(--text-muted);
}
.forum-post-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.forum-replies-section {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.forum-replies-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
}
.forum-replies-list {
  max-height: 200px;
  overflow-y: auto;
}
.forum-replies-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px;
}
.forum-reply-input {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.forum-reply-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  transition: border-color 0.15s;
}
.forum-reply-textarea:focus {
  outline: none;
  border-color: var(--yellow);
}
.forum-reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* New Thread Modal */
#new-thread-modal .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}
#new-thread-modal .form-textarea:focus {
  outline: none;
  border-color: var(--yellow);
}

/* ── User popout ── */
.user-popout {
  position: fixed;
  z-index: 900;
  width: min(300px, calc(100vw - 16px));
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.up-banner {
  height: 96px;
  border-radius: 9px 9px 0 0;
  background-color: var(--bg-hover);
  background-position: center;
  background-size: cover;
}
.up-avatar {
  margin: -44px 0 0 14px;
  width: 76px;
  height: 76px;
  border: 4px solid var(--bg-card);
  border-radius: 50%;
  background-color: var(--bg-hover);
  background-size: cover;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.up-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.up-avatar .sf-avatar-status {
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  border: 3px solid var(--bg-card);
}
.up-body {
  padding: 8px 14px 14px;
}
.up-name {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.up-tag {
  margin-top: 6px;
}
.up-about {
  max-height: 110px;
  margin-top: 10px;
  overflow-y: auto;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.up-edit {
  display: block;
  width: 100%;
  margin-top: 12px;
}
.up-status {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 10px;
  border: none;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.up-status:hover { background: var(--bg-active); }
.up-status .up-status-label { flex: 1; }
.up-status-arrow {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}
.up-status-menu {
  position: absolute;
  bottom: 0;
  left: calc(100% + 8px);
  width: 290px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.up-status-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.up-status-option + .up-status-option { margin-top: 2px; }
.up-status-option:hover,
.up-status-option.active { background: var(--bg-hover); }
.up-status-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.up-status-note {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}
.status-icon {
  position: relative;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin-top: 3px;
  border-radius: 50%;
}
.up-status .status-icon { margin-top: 0; }
.status-icon-online { background: var(--green); }
.status-icon-idle {
  background: #faa61a;
  -webkit-mask: radial-gradient(circle at 25% 25%, transparent 42%, #000 44%);
  mask: radial-gradient(circle at 25% 25%, transparent 42%, #000 44%);
}
.status-icon-dnd { background: var(--red); }
.status-icon-dnd::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 2px;
  width: 8px;
  height: 2px;
  border-radius: 1px;
  background: var(--bg-card);
}
.status-icon-offline {
  box-sizing: border-box;
  border: 3px solid var(--text-muted);
}
@media (max-width: 700px) {
  .up-status-menu {
    position: static;
    width: auto;
    margin: 0 8px 8px;
    box-shadow: none;
  }
}

/* ── Video in voice channels ── */
.voice-panel-action.live {
  background: var(--green);
  color: #fff;
}
.voice-user-state.live {
  color: var(--green);
}
.voice-chat-col {
  min-width: 0;
}
.voice-stage {
  display: grid;
  flex: 1 1 60%;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deepest);
}
.voice-stage.hidden {
  display: none;
}
.voice-stage.has-focus {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) 96px;
}
.voice-stage.has-focus .video-tile.focused {
  grid-column: 1 / -1;
  grid-row: 1;
}
.voice-stage.has-focus .video-tile:not(.focused) {
  grid-row: 2;
}
.voice-chat-col:has(.voice-stage:not(.hidden)) .voice-chat-messages {
  flex: 1 1 40%;
  min-height: 0;
}
.video-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  cursor: pointer;
}
.video-tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-tile.screen video,
.video-tile:fullscreen video {
  object-fit: contain;
}
.video-tile.mirrored video {
  transform: scaleX(-1);
}
.video-tile-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 2px 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-tile-full {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
}
.video-tile:hover .video-tile-full,
.video-tile-full:focus-visible {
  opacity: 1;
}
.screen-picker-overlay {
  position: fixed;
  z-index: 4000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.screen-picker {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.screen-picker-title {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}
.screen-picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}
.screen-picker-source {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.screen-picker-source:hover {
  border-color: var(--yellow);
}
.screen-picker-source img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 4px;
  background: #000;
}
.screen-picker-source span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.screen-picker-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ── Games on profiles ── */
.up-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.up-actions .up-edit {
  flex: 1;
  width: auto;
  margin: 0;
}
.profile-col-arrow {
  background: none;
  border: none;
  cursor: pointer;
}
.profile-games-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.game-grid.favorites {
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
}
.game-card {
  position: relative;
  min-width: 0;
}
.game-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.game-cover {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 22px;
  font-weight: 700;
}
.game-card-name {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-star,
.game-remove {
  position: absolute;
  top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.game-star { right: 6px; }
.game-star.on { color: #ffcc33; }
.game-star.static { cursor: default; }
.game-remove {
  left: 6px;
  font-size: 12px;
  opacity: 0;
}
.game-card:hover .game-remove,
.game-remove:focus-visible {
  opacity: 1;
}
.game-remove:hover {
  background: var(--red);
}
.game-picker-overlay {
  position: fixed;
  z-index: 4000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.game-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(520px, 100%);
  height: min(640px, 100%);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.game-picker-title {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}
.game-picker-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.game-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.game-picker-row:hover {
  background: var(--bg-hover);
}
.game-picker-row .game-cover {
  flex-shrink: 0;
  width: 36px;
  border-radius: 4px;
  font-size: 11px;
}
.game-picker-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-picker-state {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
}
.game-picker-row.added .game-picker-state {
  color: var(--green);
}
.game-picker-actions {
  display: flex;
  justify-content: flex-end;
}

/* ── Roles in the member menu ── */
.member-ctx-roles {
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border);
}
.member-ctx-roles-title {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.member-ctx-role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.member-ctx-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 12px;
}
.member-ctx-role-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-ctx-role-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.member-ctx-role-none {
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Drag to reorder roles ── */
.role-list-item.can-drag {
  cursor: grab;
}
.role-list-item.dragging {
  opacity: 0.45;
}
.role-list-item.drop-before {
  box-shadow: inset 0 2px 0 var(--yellow);
}
.role-list-item.drop-after {
  box-shadow: inset 0 -2px 0 var(--yellow);
}

/* ── Audit log ── */
.audit-page {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
  overflow-y: auto;
}
.audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.audit-title {
  margin: 0;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
}
.audit-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
.audit-filter {
  width: 180px;
  cursor: pointer;
}
.audit-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}
.audit-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.audit-row:last-child {
  border-bottom: none;
}
.audit-text {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.audit-text strong {
  color: var(--text-primary);
}
.audit-changes {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}
.audit-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.audit-empty {
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
.audit-empty.error {
  color: var(--red);
}
.audit-more {
  display: block;
  margin: 12px auto 0;
}

/* ── Past Updates ── */
.past-update {
  border-bottom: 1px solid var(--border);
}
.past-update:last-child {
  border-bottom: none;
}
.past-update summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.past-update .update-notes-text {
  margin: 0 0 12px;
}
.past-update-current {
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--green);
  font-size: 11px;
}
.past-update-date {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.voice-pref-note {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}
