:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-input: #1a1a3e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;
  --accent: #e94560;
  --accent-hover: #d63451;
  --online: #43b581;
  --offline: #555;
  --border: #2a2a4a;
  --error: #e94560;
  --success: #43b581;
  --nav-hover-bg: rgba(255, 255, 255, 0.08);
}

/* Theme: Exile — charcoal with subdued purple */
[data-theme="exile"] {
  --bg-primary: #1c1c24;
  --bg-secondary: #23232e;
  --bg-tertiary: #2d2c3e;
  --bg-input: #1c1c24;
  --text-primary: #d4d4dc;
  --text-secondary: #9090a0;
  --text-muted: #606070;
  --accent: #9b8ec4;
  --accent-hover: #8b7eb4;
  --online: #43b581;
  --offline: #505060;
  --border: #2d2d3d;
  --error: #c47070;
  --success: #43b581;
  --nav-hover-bg: rgba(255, 255, 255, 0.07);
}

/* Theme: Druid — deep greens with charcoal */
[data-theme="druid"] {
  --bg-primary: #181f1c;
  --bg-secondary: #1e2b25;
  --bg-tertiary: #263830;
  --bg-input: #181f1c;
  --text-primary: #c4d4bc;
  --text-secondary: #7a9870;
  --text-muted: #4e6450;
  --accent: #52b06a;
  --accent-hover: #43a05a;
  --online: #52b06a;
  --offline: #3a4e3c;
  --border: #263428;
  --error: #c47a5a;
  --success: #52b06a;
  --nav-hover-bg: rgba(255, 255, 255, 0.07);
}

/* Theme: Warlock — high-contrast dark with red highlights */
[data-theme="warlock"] {
  --bg-primary: #080808;
  --bg-secondary: #0e0e0e;
  --bg-tertiary: #181818;
  --bg-input: #080808;
  --text-primary: #f0f0f0;
  --text-secondary: #b0b0b0;
  --text-muted: #606060;
  --accent: #cc2200;
  --accent-hover: #aa1c00;
  --online: #00aa44;
  --offline: #444444;
  --border: #282828;
  --error: #cc2200;
  --success: #00aa44;
  --nav-hover-bg: rgba(255, 255, 255, 0.06);
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

#app {
  height: 100%;
}

/* Auth Layout */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1rem;
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  text-align: center;
}

.btn:hover {
  background: var(--accent-hover);
}

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

.auth-switch {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-password-hint {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin: 4px 0 0;
}

.error-message {
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.ban-notice {
  background: rgba(192, 57, 43, 0.15);
  border: 1px solid #c0392b;
  border-radius: 6px;
  color: #e8a09a;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 0.2rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
}

.ban-notice strong {
  color: #e57373;
  font-weight: 600;
}

/* Chat Layout */
.chat-layout {
  display: grid;
  grid-template-columns: 260px 4px 1fr;
  height: 100%;
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar brand — full-width header with favicon toggle + "Kenoma" */
.sidebar-brand {
  padding: 0.55rem 0.75rem 0.55rem 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand-btn {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sidebar-brand-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-lower {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
}

/* Nav rail — 56px wide, shown below sidebar brand; hidden when .collapsed */
.nav-rail {
  width: 56px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nav-logo-img {
  width: 26px;
  height: 26px;
  display: block;
}

.nav-rail-top {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  scrollbar-width: none;
}

.nav-rail-top::-webkit-scrollbar {
  display: none;
}

.nav-rail-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.nav-rail.collapsed {
  display: none;
}

.nav-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  position: relative;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--nav-hover-bg);
  color: var(--text-primary);
}

.nav-item.active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--text-primary);
}

.nav-item-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.nav-item-realm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: border-radius 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.nav-item:hover .nav-item-realm {
  border-radius: 10px;
  color: var(--text-primary);
}

.nav-item.active .nav-item-realm {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
}

.nav-item-realm.has-avatar {
  background: transparent;
  overflow: hidden;
}

.nav-item-realm-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.nav-item-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
}

.sidebar-brand-name {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

/* Sidebar channel content */
.sidebar-channel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.sidebar-realm-header {
  padding: 0.6rem 1rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.sidebar-realm-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-realm-settings-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  line-height: 1;
  transition: color 0.15s;
  opacity: 0;
  pointer-events: none;
}

.sidebar-realm-header:hover .sidebar-realm-settings-btn {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-realm-settings-btn:hover {
  color: var(--text-primary);
}

.sidebar-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-scroll-area .channel-list {
  flex: none;
  overflow-y: visible;
  overflow-x: visible;
}

/* Blank screens (realm-manager / docs / admin) */
.blank-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.blank-screen-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.blank-screen-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sidebar-resize-handle {
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
}

.sidebar-resize-handle:hover {
  background: #574b72;
}

/* .sidebar-header and .sidebar-logo removed — replaced by .nav-rail */
/* .realm-selector and .realm-btn removed — realm switching via nav-rail items */

.sidebar-section {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem 0;
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.15s;
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.channel-item.active {
  background: rgba(233, 69, 96, 0.15);
  color: var(--text-primary);
}

.channel-item .hash {
  color: var(--text-muted);
  margin-right: 0.35rem;
  font-weight: 600;
}

.member-list {
  border-top: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.presence-dot.online {
  background: var(--online);
}

.presence-dot.offline {
  background: var(--offline);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.logout-btn:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Main Chat Area */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-header .hash {
  color: var(--text-muted);
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.message {
  padding: 0.3rem 0;
  line-height: 1.4;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.msg-avatar-col {
  flex-shrink: 0;
  width: 40px;
}

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

.message-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

/* Message sender avatar */
.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-sender {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.message-edited {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

.message-content {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-top: 0.1rem;
  word-break: break-word;
}

.message-deleted .message-content {
  color: var(--text-muted);
  font-style: italic;
}

.message-group {
  display: block;
  padding-left: calc(40px + 0.5rem);
}

/* Message hover actions */
.message-actions {
  position: absolute;
  top: 2px;
  right: 4px;
  display: none;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 2px;
}

.message:hover .message-actions {
  display: inline-flex;
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 7px;
  border-radius: 3px;
  line-height: 1;
}

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

.action-btn-danger:hover {
  color: var(--error);
}

/* Inline edit */
.message-edit-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  margin-top: 0.15rem;
}

.edit-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Unread badges */
.channel-item .channel-name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  padding-right: 1.2rem;
}

/* Channel settings gear icon */
.channel-settings-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.channel-settings-btn:hover {
  color: var(--text-primary);
}

.channel-item:hover .channel-settings-btn {
  display: inline-flex;
}

.channel-item.has-unread .channel-name {
  font-weight: 600;
  color: var(--text-primary);
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* Channel Creation */
.channel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-create-form {
  padding: 0.35rem 0.75rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.channel-create-input {
  width: 100%;
  padding: 0.35rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  margin-bottom: 4px;
  transition: border-color 0.2s;
}

.channel-create-input:focus {
  border-color: var(--accent);
}

.channel-create-btn {
  padding: 0.3rem 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.2s;
}

.channel-create-btn:hover {
  background: var(--accent-hover);
}

.channel-create-btn.cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.channel-create-btn.cancel:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.channel-create-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.channel-create-error {
  font-size: 0.7rem;
  color: var(--error);
  margin-left: 4px;
}

/* DM Section */
.dm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dm-new-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.dm-new-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dm-list {
  overflow-y: auto;
  padding: 0.25rem 0;
}

.dm-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.15s;
}

.dm-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.dm-item.active {
  background: rgba(233, 69, 96, 0.15);
  color: var(--text-primary);
}

.dm-item .dm-name {
  flex: 1;
}

.dm-item.has-unread .dm-name {
  font-weight: 600;
  color: var(--text-primary);
}

.dm-picker {
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  max-height: 180px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.dm-picker-item {
  display: flex;
  align-items: center;
  padding: 0.35rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all 0.15s;
}

.dm-picker-item:hover {
  background: rgba(233, 69, 96, 0.15);
  color: var(--text-primary);
}

.dm-picker-empty {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* DM Picker Modal */
.dm-picker-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}

.dm-picker-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 440px; max-height: 560px;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.dm-picker-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  font-weight: 600; font-size: 1rem;
  border-bottom: 1px solid var(--border);
}

.dm-picker-close-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 1.1rem;
}

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

.dm-picker-search-input {
  margin: 0.75rem 1rem 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-primary);
  font-size: 0.875rem; outline: none;
  width: calc(100% - 2rem); box-sizing: border-box;
}

.dm-picker-search-input:focus { border-color: var(--accent); }

.dm-picker-user-list {
  flex: 1; overflow-y: auto; padding: 0.25rem 0;
}

.dm-picker-user-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  cursor: pointer; color: var(--text-secondary);
  transition: background 0.1s;
  user-select: none;
}

.dm-picker-user-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

.dm-picker-user-item.selected {
  background: rgba(233, 69, 96, 0.12);
  color: var(--text-primary);
}

.dm-picker-user-item.disabled {
  opacity: 0.4; cursor: default;
}

.dm-picker-check {
  margin-left: auto; color: var(--accent);
  font-size: 0.85rem;
}

.dm-picker-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
}

.dm-picker-start-btn {
  padding: 0.4rem 1rem;
  background: var(--accent); color: white;
  border: none; border-radius: 4px; cursor: pointer;
  font-size: 0.875rem; font-weight: 500;
  transition: opacity 0.15s;
}

.dm-picker-start-btn:disabled { opacity: 0.4; cursor: default; }
.dm-picker-start-btn:not(:disabled):hover { opacity: 0.85; }

.dm-item .dm-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-right: 0.4rem;
  font-size: 0.85rem;
}

/* DM list avatar with presence indicator overlay */
.dm-avatar-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-right: 0.4rem;
}

.dm-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.dm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-presence-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.dm-presence-indicator.online { background: var(--online); }
.dm-presence-indicator.offline { background: var(--offline); }

.typing-indicator {
  padding: 0.25rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 1.5rem;
}

/* Message Input */
.message-input-container {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  position: relative;
}

.message-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.message-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
  min-height: 2.4rem;
  max-height: 12rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-input:focus {
  border-color: var(--accent);
}

/* Placeholder via CSS pseudo-element (contenteditable has no native placeholder) */
.message-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.message-input.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-secondary));
}

/* Live markdown formatting inside the composer */
.message-input .md-list-item {
  display: block;
  padding-left: 1.2em;
  position: relative;
}
.message-input .md-list-item::before {
  content: '•';
  position: absolute;
  left: 0.35em;
  color: var(--text-secondary);
}

.send-btn {
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.send-btn:hover {
  background: var(--accent-hover);
}

/* Sentinel (invisible trigger for IntersectionObserver) */
.message-list-sentinel {
  height: 1px;
  width: 100%;
}

/* Loading spinner */
.message-list-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
}

.spinner-dots {
  display: flex;
  gap: 6px;
}

.spinner-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: spinner-bounce 1.4s ease-in-out infinite both;
}

.spinner-dots span:nth-child(1) { animation-delay: -0.32s; }
.spinner-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes spinner-bounce {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Jump-to-message highlight */
.message-highlight {
  animation: msg-highlight 2s ease-out;
}

@keyframes msg-highlight {
  0%, 20% { background-color: rgba(233, 69, 96, 0.25); }
  100% { background-color: transparent; }
}

/* Reactions */
.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.reaction-badge:hover {
  border-color: rgba(139, 92, 246, 0.5);
  background: rgba(139, 92, 246, 0.1);
}

.reaction-badge.active {
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(139, 92, 246, 0.15);
  color: var(--text-primary);
}

/* Reaction user list panel */
.reaction-badge-wrapper {
  position: relative;
  display: inline-flex;
}

.reaction-users-panel {
  display: none;
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 100px;
  max-width: 180px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  pointer-events: none;
}

.reaction-user-entry {
  font-size: 0.75rem;
  color: var(--text-primary);
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Emoji Picker */
.emoji-picker {
  position: absolute;
  top: 100%;
  right: 4px;
  z-index: 100;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  width: 280px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.emoji-picker-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 6px 4px 4px;
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-picker-item {
  background: none;
  border: none;
  font-size: 1.2rem;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
  text-align: center;
}

.emoji-picker-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.emoji-picker-coming-soon {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 4px 8px;
}

/* Channel Settings Pane */
.channel-settings-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.channel-settings-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-settings-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 7px;
  border-radius: 3px;
  line-height: 1;
}

.channel-settings-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.channel-settings-body {
  padding: 1.5rem;
}

.channel-settings-body h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.channel-settings-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.channel-settings-desc.muted {
  color: var(--text-muted);
  font-style: italic;
}

/* Channel Settings Editing */
.channel-settings-field {
  margin-bottom: 0.75rem;
}

.channel-settings-edit-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
  vertical-align: middle;
  margin-left: 4px;
}

.channel-settings-edit-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.channel-settings-edit-btn.always-visible {
  display: inline;
}

.channel-settings-edit-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  outline: none;
}

.channel-settings-edit-textarea {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  resize: vertical;
  font-family: inherit;
}

.channel-settings-edit-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.channel-settings-edit-error {
  font-size: 0.7rem;
  color: var(--error);
  margin-top: 4px;
}

/* Channel Settings Danger Zone */
.channel-settings-danger {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.channel-settings-danger h3 {
  font-size: 0.9rem;
  color: var(--error);
  margin-bottom: 0.5rem;
}

.channel-settings-danger p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.channel-delete-btn {
  padding: 0.4rem 1rem;
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.channel-delete-btn:hover {
  background: #c0283d;
}

/* Chat Main Wrapper */
.chat-main-wrapper {
  display: flex;
  flex-direction: row;
  height: 100%;
  overflow: hidden;
}

.chat-main-wrapper > .chat-main {
  flex: 1;
  min-width: 0;
}

/* Notification Icon Button */
.notification-icon-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.notification-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.notification-icon-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Chat Header Title */
.chat-header-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

/* No-channel state with notification button */
.no-channel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1.1rem;
  gap: 1rem;
}

/* Right Panel Resize Handle */
.right-panel-resize-handle {
  width: 3px;
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
}

.right-panel-resize-handle:hover {
  background: #574b72;
}

/* Right Panel (members / notifications) */
.right-panel {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.right-panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.right-panel .member-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
  border-top: none;
  max-height: none;
}

.right-panel .member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Notification Panel */
.notification-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.notification-panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notification-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.notification-mark-all-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.2s;
}

.notification-mark-all-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.notification-list {
  flex: 1;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.notification-item.unread {
  background: rgba(233, 69, 96, 0.08);
}

.notification-item.unread:hover {
  background: rgba(233, 69, 96, 0.12);
}

.notification-type-icon {
  font-size: 1rem;
  line-height: 1.4;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.notification-body {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.notification-excerpt {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.notification-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
  padding: 2rem;
}

/* Mentions */
.mention {
  color: var(--accent);
  background: rgba(233, 69, 96, 0.15);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 500;
}

.mention-self {
  background: rgba(233, 69, 96, 0.3);
}

/* Mention Autocomplete */
.mention-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
  margin-bottom: 4px;
}

.mention-autocomplete-item {
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s;
}

.mention-autocomplete-item:hover,
.mention-autocomplete-item.active {
  background: rgba(233, 69, 96, 0.2);
  color: var(--text-primary);
}

/* Clickable notification items */
.notification-item.clickable {
  cursor: pointer;
}

/* File Upload Button */
.file-upload-hidden {
  display: none;
}

.file-upload-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.file-upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Upload Progress */
.upload-progress {
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.upload-progress-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 0.5rem;
}

.upload-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s;
}

.upload-error {
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.4rem;
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--error);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--error);
}

/* File Content in Messages */
.file-content {
  margin-top: 0.25rem;
  max-width: 400px;
}

/* File Image */
.file-image-container {
  position: relative;
  display: inline-block;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.file-image {
  display: block;
  max-width: 400px;
  max-height: 300px;
  object-fit: contain;
  cursor: pointer;
}

.file-image-placeholder {
  width: 200px;
  height: 120px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* File Audio */
.file-audio-container {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  background: var(--bg-tertiary);
}

.file-audio-container audio {
  width: 100%;
  height: 36px;
}

/* File Video */
.file-video-container {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.file-video-container video {
  display: block;
  max-width: 400px;
  max-height: 300px;
}

/* Generic File Badge */
.file-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.file-badge-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

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

.file-badge-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  word-break: break-word;
}

.file-badge-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-download-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.file-download-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* File Info Bar (shared by image/audio/video) */
.file-info-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-info-bar .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info-bar .file-size {
  flex-shrink: 0;
}

.file-download-link {
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
}

.file-download-link:hover {
  color: var(--accent);
}

/* Inline URL links within message text */
.message-link {
  color: #7aadff;
  text-decoration: none;
  word-break: break-all;
}
.message-link:hover {
  text-decoration: underline;
}

/* URL Embed — shared dismiss button */
.url-embed-dismiss {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  line-height: 20px;
  text-align: center;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.url-embed-media:hover .url-embed-dismiss,
.url-embed-card:hover .url-embed-dismiss {
  opacity: 1;
}
.url-embed-dismiss:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Inline media (image / video / audio) */
.url-embed-media {
  position: relative;
  display: inline-block;
  margin-top: 0.35rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 420px;
}

.url-embed-image {
  display: block;
  max-width: 420px;
  max-height: 320px;
  object-fit: contain;
}

.url-embed-video {
  display: block;
  max-width: 420px;
  max-height: 300px;
  background: #000;
}

.url-embed-audio {
  display: block;
  width: 360px;
  max-width: 100%;
  padding: 6px;
  background: var(--bg-secondary);
}

/* OG preview card */
.url-embed-card {
  position: relative;
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  overflow: hidden;
  max-width: 420px;
  background: var(--bg-secondary);
}

.url-embed-card-image {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

.url-embed-card-body {
  padding: 8px 10px;
}

.url-embed-card-site {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.url-embed-card-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.url-embed-card-title:hover {
  text-decoration: underline;
  color: var(--accent);
}

.url-embed-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Markdown formatting in messages */
.md-list {
  margin: 0.15em 0;
  padding-left: 1.4em;
  list-style-type: disc;
}
.md-list li {
  margin: 0.1em 0;
}
.md-blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.2em 0;
  padding: 0.15em 0.65em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 3px 3px 0;
}
.md-code {
  font-family: 'Consolas', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-size: 0.88em;
  color: #e6b87a;
}

/* Pinned Messages */
.message-pinned {
  background: rgba(233, 69, 96, 0.06);
  border-left: 2px solid var(--accent);
}

.action-btn.pin-active {
  color: var(--accent);
}

.pin-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pin-panel-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.pin-list {
  flex: 1;
  overflow-y: auto;
}

.pin-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.pin-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.pin-item-sender {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.pin-item-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pin-item-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.pin-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.pin-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.channel-settings-pins {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.channel-settings-pins h3 {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.pin-settings-item {
  padding: 0.4rem 0;
  cursor: pointer;
  transition: color 0.15s;
}

.pin-settings-item:hover {
  color: var(--accent);
}

.pin-settings-sender {
  font-weight: 600;
  font-size: 0.8rem;
}

.pin-settings-content {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Search panel */
.search-panel { display: flex; flex-direction: column; height: 100%; }
.search-scope-buttons { display: flex; gap: 0.5rem; padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); }
.search-scope-btn { flex: 1; padding: 0.3rem 0; background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); cursor: pointer; font-size: 0.8rem; }
.search-scope-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.search-input-row { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.search-input { flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px; padding: 0.4rem 0.6rem; color: var(--text-primary); font-size: 0.85rem; }
.search-input:focus { outline: none; border-color: var(--accent); }
.search-submit-btn { background: var(--accent); border: none; border-radius: 4px; padding: 0.4rem 0.7rem; color: #fff; cursor: pointer; font-size: 0.9rem; }
.search-submit-btn:hover { opacity: 0.85; }
.search-loading { display: flex; justify-content: center; padding: 1rem; }
.search-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.search-results { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
.search-result-item { padding: 0.6rem 1rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-result-item:hover { background: var(--bg-tertiary); }
.search-result-channel { font-size: 0.75rem; color: var(--accent); margin-bottom: 0.2rem; }
.search-result-meta { display: flex; justify-content: space-between; margin-bottom: 0.25rem; }
.search-result-sender { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.search-result-time { font-size: 0.75rem; color: var(--text-muted); }
.search-result-preview { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4; }
.search-result-preview mark { background: rgba(233,69,96,0.3); color: var(--text-primary); border-radius: 2px; padding: 0 1px; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== Projects Section ==================== */

/* Sidebar */
.project-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-list {
  overflow-y: auto;
  padding: 0.25rem 0;
}

.project-group {
  margin-bottom: 2px;
}

.project-header {
  display: flex;
  align-items: center;
  padding: 0.4rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.project-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.project-header.active {
  background: rgba(233, 69, 96, 0.15);
  color: var(--text-primary);
}

.project-expand {
  font-size: 1rem;
  margin-right: 0.35rem;
  color: var(--text-muted);
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.project-expand:hover {
  color: var(--text-primary);
}

.project-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.project-status-dot.status-plan { background: var(--text-muted); }
.project-status-dot.status-in-progress { background: #f0ad4e; }
.project-status-dot.status-complete { background: var(--success); }

.project-channels {
  padding-left: 1.25rem;
}

.project-channels .channel-item {
  padding-left: 0.75rem;
  font-size: 0.85rem;
}

.project-channel-add {
  display: flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: color 0.15s;
}

.project-channel-add:hover {
  color: var(--accent);
}

.project-channel-add .hash {
  margin-right: 0.3rem;
}

.project-channel-add .add-channel {
  font-style: italic;
}

.project-channel-create {
  margin-left: 0;
  padding: 0.25rem 0.5rem;
}

/* Project Page */
.project-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.project-page-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.project-page-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.project-page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-style: italic;
}

.project-screenshot-placeholder {
  width: 100%;
  height: 200px;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.project-title {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* Status */
.project-status-section {
  margin-bottom: 1rem;
}

.project-status-badge {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-status-badge.status-plan {
  background: rgba(106, 106, 122, 0.2);
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
}

.project-status-badge.status-in-progress {
  background: rgba(240, 173, 78, 0.15);
  color: #f0ad4e;
  border: 1px solid #f0ad4e;
}

.project-status-badge.status-complete {
  background: rgba(67, 181, 129, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}

.project-status-select {
  padding: 0.3rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.project-status-select:focus {
  border-color: var(--accent);
}

/* Placeholder sections */
.project-placeholder-section {
  margin: 1rem 0;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.project-placeholder-section h3 {
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.muted-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Member list */
.project-members-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.project-members-section h3,
.project-channels-section h3 {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.project-member-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

.project-member-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* Project channels in page */
.project-channels-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.project-channel-link {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.project-channel-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
}

.project-channel-link .hash {
  color: var(--text-muted);
  margin-right: 0.25rem;
}

/* Project row settings gear — hover reveal */
.project-settings-gear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}
.project-header:hover .project-settings-gear { opacity: 1; }
.project-header:hover .project-settings-gear:hover { color: var(--text-primary); }

/* Project settings panel */
.project-settings {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-settings-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.project-settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.project-settings-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
}

.project-settings-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem 0;
}

.project-settings-field {
  margin-bottom: 0.75rem;
}

.project-settings-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.project-settings-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.project-settings-role-select {
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  cursor: pointer;
}

.project-settings-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 1rem;
  line-height: 1;
}
.project-settings-remove-btn:hover { color: var(--error, #e94560); }

.project-add-member-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.75rem;
}

.project-add-member-select { flex: 1; min-width: 120px; }
.project-add-role-select { min-width: 90px; }

/* Custom role tags */
.project-role-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.project-role-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.project-role-tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
}
.project-role-tag-remove:hover { color: var(--error, #e94560); }

.project-role-limit-badge {
  font-size: 0.7rem;
  font-weight: normal;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

/* Reset the large channel-name input style when used inside project settings */
.project-settings-body .channel-settings-edit-input {
  font-size: 0.875rem;
  font-weight: normal;
}
.project-settings-body .channel-settings-edit-textarea {
  font-size: 0.875rem;
}

.project-external-link {
  color: var(--accent);
  font-size: 0.85rem;
  word-break: break-all;
}
.project-external-link:hover { text-decoration: underline; }

/* ─────────────────────────────────────────────
   Phase 7: Voice Channels
   ───────────────────────────────────────────── */

/* Voice Channels sidebar section */
.voice-channels-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.voice-channel-list {
  padding: 0.25rem 0;
}

.voice-channel-empty {
  padding: 0.25rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.voice-channel-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.voice-channel-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.voice-channel-item.active {
  background: rgba(67, 181, 129, 0.12);
  color: var(--online);
}

.voice-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.voice-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
  animation: voice-pulse 2s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Sidebar footer layout update */
.sidebar-user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.sidebar-user-identity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.user-bar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.user-bar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Sidebar user actions row */
.sidebar-user-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.user-settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.user-settings-btn:hover {
  color: var(--text-primary);
  background: var(--hover);
}

/* User Settings Pane */
.user-settings-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
}

.user-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.user-settings-body {
  overflow-y: auto;
  flex: 1;
}

.user-settings-body-inner {
  padding: 1.5rem 2rem;
  max-width: 600px;
}

.settings-section {
  margin-bottom: 2.25rem;
}

.settings-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.settings-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.settings-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.settings-avatar-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.15s, color 0.15s;
}

.settings-avatar-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.settings-avatar-btn.uploading {
  opacity: 0.6;
  cursor: default;
}

.settings-avatar-file-input {
  display: none;
}

.settings-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.settings-avatar-error {
  font-size: 0.8rem;
  color: var(--error);
}

.settings-soon-tag {
  font-size: 0.6rem;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.settings-field-group {
  margin-bottom: 1.25rem;
}

.settings-field-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.settings-field-sublabel {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.settings-value-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.settings-value {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.settings-value.muted {
  color: var(--text-muted);
}

.settings-field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.settings-edit-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-edit-block input[type="password"] {
  font-size: 0.875rem;
  font-weight: 400;
}

.settings-placeholder-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  opacity: 0.5;
}

.settings-placeholder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 4px;
}

.settings-placeholder-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.settings-placeholder-value {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-success-msg {
  font-size: 0.82rem;
  color: #4caf50;
  margin-top: 0.25rem;
}

/* Settings Edit Button (inline edit in settings panes) */
.settings-edit-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.settings-edit-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.settings-value-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Realm avatar in settings — initials use bg-tertiary instead of accent */
.realm-settings-avatar {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 1.25rem;
}

/* Realm Settings */
.realm-settings-banner-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.realm-settings-banner-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.realm-settings-banner-placeholder {
  width: 100%;
  height: 120px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.realm-settings-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.realm-settings-banner-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.realm-settings-banner-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.realm-settings-banner-btn.loading {
  opacity: 0.6;
  cursor: default;
}

.realm-settings-banner-error {
  font-size: 0.8rem;
  color: var(--error);
}

.realm-settings-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.realm-settings-placeholder-card {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  opacity: 0.6;
}

.realm-settings-placeholder-card p {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.realm-settings-error {
  font-size: 0.8rem;
  color: var(--error);
}

.realm-settings-member-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.realm-settings-member-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}

.realm-settings-member-row:hover {
  background: var(--bg-tertiary);
}

.realm-settings-member-name {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.realm-settings-you {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.realm-settings-role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.realm-settings-role-badge.role-owner {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.realm-settings-role-badge.role-admin {
  background: rgba(255, 165, 0, 0.15);
  color: #ffa500;
}

.realm-settings-role-badge.role-member {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.realm-settings-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  opacity: 0;
}

.realm-settings-member-row:hover .realm-settings-remove-btn {
  opacity: 1;
}

.realm-settings-remove-btn:hover {
  color: var(--error);
  background: rgba(233, 69, 96, 0.1);
}

/* Voice Panel — appears above user bar in sidebar footer */
.voice-panel {
  background: rgba(67, 181, 129, 0.08);
  border-top: 1px solid rgba(67, 181, 129, 0.2);
  padding: 0.5rem 0.75rem;
  flex-shrink: 0;
}

.voice-panel-channel {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.voice-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.voice-status-dot.live {
  background: var(--online);
  animation: voice-pulse 2s ease-in-out infinite;
}

.voice-status-dot.connecting {
  background: #f0ad4e;
  animation: voice-pulse 1s ease-in-out infinite;
}

.voice-channel-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--online);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.voice-channel-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-panel-controls {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.voice-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.voice-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.voice-btn.muted,
.voice-btn.deafened {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.voice-btn.leave-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.voice-btn.leave-btn:hover {
  background: var(--accent);
  color: white;
}

.voice-btn.placeholder,
.voice-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Voice screen center pane ── */

.voice-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
}

.voice-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-screen-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.voice-screen-share-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  transition: background 0.15s, border-color 0.15s;
}

.voice-screen-share-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

/* Participant grid (standard mode) */
.voice-participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
  align-content: start;
  overflow-y: auto;
  flex: 1;
}

.voice-participant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 1rem;
  border-radius: 0.5rem;
  transition: background 0.15s;
}

.voice-participant-card:hover {
  background: var(--bg-tertiary);
}

/* Avatar ring */
.voice-avatar-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  padding: 3px;
  border: 3px solid transparent;
  transition: border-color 0.1s, box-shadow 0.1s;
  box-sizing: border-box;
}

.voice-avatar-ring.speaking {
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.5);
}

.voice-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.voice-participant-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-participant-indicators {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  font-size: 0.8rem;
  min-height: 1.2em;
}

/* Screen share layout */
.voice-screen-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.voice-screen-share-feed {
  flex: 3;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.voice-screen-share-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.voice-participants-strip {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 1rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  align-items: center;
  border-top: 1px solid var(--border);
  min-height: 0;
}

.voice-participants-strip .voice-avatar-ring {
  width: 56px;
  height: 56px;
}

.voice-participants-strip .voice-avatar {
  font-size: 1rem;
}

.voice-participants-strip .voice-participant-card {
  flex-shrink: 0;
  padding: 0.5rem;
  min-width: 70px;
}

/* Sidebar participant names under voice channel */
.voice-sidebar-members {
  font-size: 0.7rem;
  font-style: italic;
  color: var(--text-muted);
  padding: 0 0 0.2rem 2rem;
  line-height: 1.4;
}

/* Attachment preview strip (pre-send staging area) */
.attachment-preview-strip {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0.75rem 0;
  max-height: 8rem;
}

.attachment-preview-item {
  position: relative;
  flex-shrink: 0;
  width: 5rem;
  height: 5rem;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.attachment-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-preview-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  word-break: break-all;
  text-align: center;
  padding: 0.25rem;
}

.attachment-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  line-height: 1.2rem;
  text-align: center;
}

.attachment-preview-remove:hover {
  background: var(--accent);
}

/* Edit mode attachment strip (inside message edit area) */
.edit-attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.edit-attachment-item {
  position: relative;
  width: 4rem;
  height: 4rem;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-attachment-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.edit-attachment-discard {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  font-size: 0.65rem;
  cursor: pointer;
  line-height: 1.1rem;
  text-align: center;
}

.edit-attachment-discard:hover {
  background: var(--accent);
}

.edit-attachment-add {
  width: 3rem;
  height: 3rem;
  border-radius: 4px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.edit-attachment-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Reply bar (above input, shown when replying to a message) */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.reply-bar-body {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reply-bar-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 0.25rem;
  flex-shrink: 0;
}

.reply-bar-dismiss:hover {
  color: var(--accent);
}

/* Reply preview (inside message, shown when message has a reply_to) */
.reply-preview {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.25rem;
  border-left: 2px solid var(--accent);
  background: var(--bg-tertiary);
  border-radius: 0 4px 4px 0;
  font-size: 0.78rem;
  cursor: pointer;
  max-width: 480px;
  opacity: 0.85;
}

.reply-preview:hover {
  opacity: 1;
  background: var(--bg-secondary);
}

.reply-preview-sender {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.1rem;
}

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

.reply-preview-deleted {
  font-style: italic;
  cursor: default;
  opacity: 0.6;
}

/* ── Sound & Alert Preference ─────────────────────────────── */

/* Notification panel: sound toggle button */
.notif-sound-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
}
.notif-sound-toggle.active {
  opacity: 1;
}
.notif-sound-toggle:hover {
  opacity: 0.85;
}

/* Channel settings: alert preference select + label */
.channel-settings-alert-pref {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.channel-settings-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.channel-settings-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  max-width: 260px;
}
.channel-settings-select:focus {
  outline: none;
  border-color: var(--accent);
}
.channel-settings-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* User settings: alert pref row */
.settings-alert-pref-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.settings-success-inline {
  font-size: 0.8rem;
  color: var(--success);
}

/* Theme picker */
.theme-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.theme-picker-panel {
  position: fixed;
  left: 64px;
  bottom: 8px;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 172px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.theme-picker-header {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px 6px;
}

.theme-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.theme-picker-item:hover {
  background: var(--nav-hover-bg);
}

.theme-picker-item.active {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.theme-swatch {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.theme-swatch-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(128, 128, 128, 0.25);
  display: inline-block;
}

.theme-picker-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  flex: 1;
}

.theme-picker-check {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

/* ── Project Media Viewer (Steam-style: main pane + thumbnail strip) ── */

/* Side-by-side layout: gallery (~68%) + info card (flex:1) */
.project-media-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.project-media-viewer {
  flex: 0 0 68%;
  min-width: 0;
}

.project-info-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.project-info-card .project-title {
  margin: 0 0 0.1rem;
}

.project-info-card .project-status-section {
  margin-bottom: 0.1rem;
}

.project-info-card .channel-settings-field {
  margin: 0;
}

.project-info-link-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.project-info-link-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.project-media-main-pane {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.4rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-media-main-pane a {
  display: block;
  width: 100%;
  height: 100%;
}

.project-media-main-pane img,
.project-media-main-pane video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.project-media-main-pane a:hover img {
  opacity: 0.9;
}

/* Hover navigation arrows */
.project-media-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 2;
  padding: 0;
}

.project-media-nav.nav-left  { left: 0; justify-content: flex-start; padding-left: 0.5rem; }
.project-media-nav.nav-right { right: 0; justify-content: flex-end; padding-right: 0.5rem; }

.project-media-main-pane:hover .project-media-nav {
  opacity: 1;
}

.project-media-nav-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: background 0.15s, transform 0.1s;
  pointer-events: none;
}

.project-media-nav:hover .project-media-nav-icon {
  background: rgba(0,0,0,0.8);
  transform: scale(1.1);
}

.project-media-strip-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.3rem;
}

.project-media-strip-arrow {
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}

.project-media-strip-arrow:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.project-media-strip {
  flex: 1;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding-bottom: 3px;
}

.project-media-strip-thumb {
  flex-shrink: 0;
  width: 160px;
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--bg-tertiary);
  transition: border-color 0.15s;
}

.project-media-strip-thumb.active {
  border-color: var(--accent);
}

.project-media-strip-thumb:hover:not(.active) {
  border-color: var(--text-muted);
}

.project-media-strip-thumb img,
.project-media-strip-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* ── Project Media Settings (project-settings pane) ───────────────── */

.project-media-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.project-media-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}

.project-media-thumb {
  width: 60px;
  height: 42px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  display: block;
}

.project-media-row-name {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.project-media-order-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  font-size: 0.65rem;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.project-media-order-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.project-media-order-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.project-media-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-size: 1rem;
  flex-shrink: 0;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.project-media-delete-btn:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.project-media-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  transition: border-color 0.15s, color 0.15s;
  margin-top: 0.25rem;
}

.project-media-upload-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.project-media-upload-label input[type="file"] {
  display: none;
}

/* User Profile Banner */
.user-settings-banner {
  width: 100%;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.user-settings-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-settings-banner-empty {
  width: 100%;
  height: 100%;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-settings-banner-actions {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-settings-banner-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.user-settings-banner-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.user-settings-banner-btn.uploading {
  opacity: 0.6;
  cursor: default;
}

/* User Profile Pane (center screen) */
.user-profile-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
}

.user-profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 2rem 2rem;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.user-profile-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  align-self: flex-start;
  padding-top: 48px;
  margin-left: auto;
  flex-shrink: 0;
}

.user-profile-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}

.user-profile-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.profile-modal-banner {
  width: 100%;
  height: 160px;
  background: var(--bg-tertiary);
  position: relative;
  flex-shrink: 0;
}

.profile-modal-banner-img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

.profile-modal-identity {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 0 2rem 1rem;
  margin-top: -36px;
  position: relative;
}

.profile-modal-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 4px solid var(--bg-primary);
  overflow: hidden;
}

.profile-modal-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

.profile-modal-name-block {
  flex: 1;
  min-width: 0;
  padding-top: 48px;
}

.profile-modal-display-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.profile-modal-username {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.profile-modal-role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  margin-left: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.profile-modal-note {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.profile-modal-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.profile-modal-account-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}

.profile-modal-account-row:last-child { border-bottom: none; }

.profile-modal-account-platform {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 3px;
  padding: 2px 5px;
  min-width: 44px;
  text-align: center;
  flex-shrink: 0;
}

.profile-modal-account-value {
  flex: 1;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.profile-modal-account-value a {
  color: var(--accent);
  text-decoration: none;
}

.profile-modal-account-value a:hover { text-decoration: underline; }

.profile-modal-skeleton-line {
  height: 12px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.profile-modal-error {
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--error);
  text-align: center;
}

/* External Accounts */
.ext-account-list {
  display: flex;
  flex-direction: column;
}

.ext-account-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.ext-account-row:last-child {
  border-bottom: none;
}

.ext-account-platform {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 2px 6px;
  min-width: 48px;
  text-align: center;
  flex-shrink: 0;
}

.ext-account-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 80px;
  flex-shrink: 0;
}

.ext-account-value {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ext-account-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.ext-account-add-form {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ext-account-add-row {
  display: flex;
  gap: 0.4rem;
}


/* ─── Admin Account Manager ─────────────────────────────────────── */

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

.admin-pane-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.admin-pane-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.admin-tabs {
  display: flex;
  gap: 0.25rem;
}

.admin-tab-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  transition: background 0.15s, color 0.15s;
}

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

.admin-tab-btn.active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

.admin-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
}

.admin-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.admin-class-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg-secondary);
}

.admin-class-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-class-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.admin-class-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.admin-class-card-body {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.admin-permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.admin-perm-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.admin-perm-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.admin-ban-form {
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-ban-form-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.admin-badge-banned {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--accent);
}

.admin-badge-temp {
  background: color-mix(in srgb, #f59e0b 20%, transparent);
  color: #f59e0b;
}

.admin-ip-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0.35rem;
  flex-shrink: 0;
}

.admin-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.25rem 0 0.5rem;
}

.admin-new-class-form {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.admin-inline-edit {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-inline-edit input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

.settings-save-btn {
  padding: 0.3rem 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.settings-save-btn:hover {
  background: var(--accent-hover);
}

.settings-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-cancel-btn {
  padding: 0.3rem 0.65rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  transition: border-color 0.2s, color 0.2s;
}

.settings-cancel-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.danger-btn {
  background: #c0392b !important;
  color: #fff !important;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.danger-btn:hover {
  background: #a93226 !important;
}

/* ─── User Reports ─────────────────────────────────────────────────────────── */

.report-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.report-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.report-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.report-reporter strong {
  color: var(--text-primary);
}

.report-date {
  font-size: 0.75rem;
}

.report-jump-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.report-jump-btn:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.report-message-embed {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.report-message-embed-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.report-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--text-primary);
}

.report-message-embed-meta {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}

.report-sender-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.report-sender-username {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.report-message-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.report-channel-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.report-badge-dm {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.report-message-content {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.5;
  padding-left: calc(32px + 0.5rem);
  word-break: break-word;
  white-space: pre-wrap;
}

.report-dm-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.5rem 0 0;
  padding-left: calc(32px + 0.5rem);
}

.report-content-deleted {
  color: var(--text-muted);
}

.report-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.report-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.report-badge-pending {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  color: #f59e0b;
}

.report-badge-reviewing {
  background: color-mix(in srgb, #3b82f6 18%, transparent);
  color: #60a5fa;
}

.report-badge-complete {
  background: color-mix(in srgb, #22c55e 18%, transparent);
  color: #4ade80;
}

.report-comment-area {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.report-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
}

.report-comment-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.report-comment-placeholder {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.report-comment-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  resize: vertical;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.report-comment-input:focus {
  outline: none;
  border-color: var(--accent);
}

.report-comment-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.report-error {
  font-size: 0.8rem;
  color: var(--error, #e74c3c);
}

.report-message-actions,
.report-ban-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.report-ban-active {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.report-ban-section:last-child,
.report-message-actions:last-child {
  border-bottom: none;
}

.report-action-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.report-edit-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-ban-type-row {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.admin-ban-type-row label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.action-btn.report-sent {
  color: #f59e0b;
  border-color: #f59e0b;
  opacity: 0.75;
}

.admin-loading {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 1rem;
}

/* ─── Content Screening ────────────────────────────────────────────────────── */

.screening-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.screening-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.screening-toggle-label input {
  cursor: pointer;
}

.screening-bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.screening-bulk-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.screening-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
}

.screening-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screening-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.screening-item-approved {
  opacity: 0.6;
}

.screening-item-selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent) !important;
}

.screening-item-checkbox {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  background: var(--bg-primary);
  border-radius: 3px;
  padding: 1px;
  line-height: 0;
}

.screening-item-checkbox input {
  cursor: pointer;
  width: 15px;
  height: 15px;
  margin: 0;
}

.screening-item-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screening-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.screening-item-placeholder {
  font-size: 2rem;
  color: var(--text-muted);
  user-select: none;
}

.screening-thumb-loading {
  font-size: 1.1rem;
  animation: screening-pulse 1.2s ease-in-out infinite;
}

@keyframes screening-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.screening-approved-indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #22c55e;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.screening-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.screening-item:hover .screening-item-overlay {
  opacity: 1;
}

.screening-overlay-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.15s;
}

.screening-overlay-btn:hover {
  transform: scale(1.1);
}

.screening-overlay-approve {
  background: #22c55e;
  color: #fff;
}

.screening-overlay-approve:disabled {
  background: #166534;
  color: #4ade80;
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.screening-overlay-delete {
  background: var(--error, #e74c3c);
  color: #fff;
}

.screening-item-info {
  padding: 0.45rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-height: 0;
}

.screening-item-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screening-item-channel {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screening-item-submeta {
  font-size: 0.67rem;
  color: var(--text-muted);
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screening-count-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 1rem 1.25rem;
  margin: 0;
}

.screening-approve-btn-solid {
  background: #166534 !important;
  border-color: #22c55e !important;
  color: #4ade80 !important;
}

.screening-approve-btn-solid:hover {
  background: #15803d !important;
}

.screening-approved-badge {
  font-size: 0.78rem;
  color: #4ade80;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
}

/* ─── Content Screening — Lightbox ─────────────────────────────────────────── */

.screening-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.screening-lightbox-inner {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: min(900px, 100%);
  max-height: 90vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screening-lightbox-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.screening-lightbox-title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.screening-lightbox-filename {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.screening-lightbox-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.screening-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.screening-lightbox-content {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  min-height: 0;
  padding: 1rem;
  box-sizing: border-box;
}

.screening-lightbox-img {
  max-width: 100%;
  max-height: calc(90vh - 120px);
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

.screening-lightbox-video {
  max-width: 100%;
  max-height: calc(90vh - 120px);
  display: block;
  border-radius: 4px;
}

.screening-lightbox-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.screening-lightbox-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-primary);
  gap: 0.25rem;
}

/* ── Audio Settings ────────────────────────────────────────────────────────── */

.audio-level-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.audio-level-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 50ms linear;
}

.audio-device-select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.audio-device-select:focus {
  outline: none;
  border-color: var(--accent);
}

.audio-volume-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 0.4rem;
}

.audio-settings-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ── Channel Visibility ────────────────────────────────────────── */

/* Lock badge in channel list */
.channel-visibility-badge {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 0.2rem;
  flex-shrink: 0;
}

/* Public / Private toggle in channel create form */
.channel-vis-toggle {
  display: flex;
  gap: 0.4rem;
  margin: 0.35rem 0 0.2rem;
}

.channel-vis-option {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: transparent;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.channel-vis-option input[type="radio"] {
  margin: 0;
  accent-color: var(--accent);
}

.channel-vis-option.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text-primary);
}

/* Rules panel (channel create form + channel settings) */
.channel-vis-rules-panel {
  margin-top: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.channel-vis-loading {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.3rem 0;
}

.channel-vis-group {
  margin-bottom: 0.6rem;
}

.channel-vis-group:last-child {
  margin-bottom: 0;
}

.channel-vis-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.channel-vis-check-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 0.15rem 0;
  cursor: pointer;
  user-select: none;
}

.channel-vis-check-item input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

.channel-vis-user-list {
  max-height: 130px;
  overflow-y: auto;
}

.channel-vis-summary {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.channel-vis-summary.muted {
  color: var(--text-muted);
  font-style: italic;
}

/* Creator meta row in channel settings pane */
.channel-settings-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.channel-settings-meta-item {
  display: inline-flex;
  align-items: center;
}

.channel-settings-meta-sep {
  color: var(--text-muted);
}

.channel-visibility-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.channel-visibility-pill.public {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.channel-visibility-pill.private {
  background: color-mix(in srgb, #f0a500 15%, transparent);
  color: #f0a500;
}

/* Visibility rules section wrapper in channel settings */
.channel-settings-section {
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.channel-settings-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 0 0 0.6rem 0;
}

.channel-settings-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}

/* ── Realm Roles ────────────────────────────────────────────────── */

.realm-roles-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.realm-role-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.realm-role-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
}

.realm-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.realm-role-members-panel {
  padding: 0.5rem 0.75rem 0.65rem;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.realm-role-member-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.5rem;
}

.realm-role-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0.2rem 0;
}

.realm-role-add-member {
  margin-top: 0.4rem;
}

.realm-role-add-member .channel-settings-select {
  width: 100%;
}

.realm-role-create-form {
  margin-top: 0.6rem;
}

.realm-role-create-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.realm-role-create-row .channel-settings-edit-input {
  flex: 1;
  min-width: 0;
}

.realm-role-color-picker {
  width: 2.2rem;
  height: 2rem;
  padding: 0.1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  cursor: pointer;
  flex-shrink: 0;
}

/* Custom emoji picker */
.emoji-picker-item-custom { padding: 2px; }
.emoji-picker-custom-img {
  width: 28px; height: 28px;
  object-fit: contain; border-radius: 4px; display: block;
}

/* Reactions — custom emoji images */
.reaction-custom-emoji {
  width: 18px; height: 18px;
  object-fit: contain; vertical-align: middle; border-radius: 2px;
}

/* User settings — emoji keyboard */
.emoji-keyboard-grid {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.emoji-keyboard-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-tertiary); border-radius: 6px; padding: 8px; width: 90px;
}
.emoji-keyboard-img { width: 48px; height: 48px; object-fit: contain; border-radius: 4px; }
.emoji-keyboard-name { font-size: 0.7rem; color: var(--text-muted); word-break: break-all; text-align: center; }
.emoji-keyboard-sharing-badge { font-size: 0.65rem; color: var(--text-muted); }
.emoji-keyboard-actions { display: flex; gap: 4px; }
.emoji-keyboard-edit-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer; color: var(--text-muted); padding: 2px 6px;
}
.emoji-keyboard-delete-btn { padding: 2px 6px; font-size: 0.75rem; }
.emoji-upload-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px;
}
.emoji-upload-name-input {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-primary); padding: 6px 10px; font-size: 0.85rem; width: 180px;
}
.emoji-upload-sharing-select {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-primary); padding: 6px 8px; font-size: 0.85rem;
}
.emoji-upload-btn, .emoji-upload-chosen {
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 12px; font-size: 0.85rem; cursor: pointer; color: var(--text-primary);
  white-space: nowrap;
}
.emoji-sharing-editor {
  width: 100%; background: var(--bg-secondary); border-radius: 4px; padding: 8px;
  margin-top: 4px; display: flex; flex-direction: column; gap: 6px;
}
.emoji-sharing-editor-actions { display: flex; gap: 6px; }
.emoji-realm-checkboxes { display: flex; flex-direction: column; gap: 4px; }
.emoji-placeholder-card {
  margin-top: 24px; background: var(--bg-tertiary); border-radius: 8px;
  padding: 16px; border: 1px solid var(--border);
}
.emoji-placeholder-card h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--text-secondary); }

/* DM active voice call indicator */
.dm-voice-members {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 1rem 0.25rem calc(1rem + 28px + 0.5rem);
  line-height: 1.3;
}

/* Incoming DM call card */
.incoming-call-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  animation: incoming-call-pulse 1.5s ease-in-out infinite;
}
@keyframes incoming-call-pulse {
  0%, 100% { background: var(--bg-tertiary); }
  50% { background: color-mix(in srgb, var(--accent) 18%, var(--bg-tertiary)); }
}
.incoming-call-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-secondary); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 600; color: var(--text-secondary);
  flex-shrink: 0;
}
.incoming-call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.incoming-call-text { flex: 1; min-width: 0; }
.incoming-call-label { font-size: 0.65rem; color: var(--text-muted); line-height: 1.2; }
.incoming-call-name { font-size: 0.8rem; color: var(--text-primary); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.incoming-call-actions { display: flex; gap: 5px; flex-shrink: 0; }
.incoming-call-accept {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: #27ae60; color: #fff; font-size: 0.85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.incoming-call-accept:hover { background: #2ecc71; }
.incoming-call-reject {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: #c0392b; color: #fff; font-size: 0.85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.incoming-call-reject:hover { background: #e74c3c; }

/* ─────────────────────────────────────────────
   Mobile Responsive Layout
   ───────────────────────────────────────────── */

/* Base styles for mobile-only elements (always rendered, hidden on desktop) */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 10px; left: 10px; z-index: 200;
  width: 36px; height: 36px; border: none; border-radius: 8px;
  background: var(--bg-secondary); color: var(--text-primary); font-size: 1.2rem;
  cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.mobile-sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 299;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.mobile-sidebar-backdrop.visible { opacity: 1; pointer-events: all; }
.sidebar-mobile-close-btn { display: none; }
.mobile-msg-actions-btn { display: none; }
.mobile-panel-close-btn { display: none; }
.mobile-right-panel-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 249;
}

/* Mobile breakpoint */
@media (max-width: 767px) {
  /* Single-column layout */
  .chat-layout { grid-template-columns: 1fr !important; }
  .sidebar-resize-handle, .right-panel-resize-handle { display: none; }

  /* Sidebar as overlay drawer */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh;
    width: min(300px, 85vw); z-index: 300;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Show mobile-only elements */
  .mobile-menu-btn { display: flex; }
  .mobile-sidebar-backdrop { display: block; }
  .sidebar-mobile-close-btn {
    display: flex; margin-left: auto;
    background: none; border: none; color: var(--text-muted);
    font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 4px;
  }
  .sidebar-mobile-close-btn:hover { color: var(--text-primary); }

  /* Right panel as slide-in overlay from right */
  .right-panel {
    position: fixed; right: 0; top: 0; height: 100dvh;
    width: min(320px, 90vw); z-index: 250;
    transform: translateX(100%); transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,0.5);
  }
  .right-panel.mobile-panel-open { transform: translateX(0); }
  .mobile-panel-close-btn {
    display: flex; position: absolute; top: 0.6rem; right: 0.75rem;
    background: none; border: none; color: var(--text-muted);
    font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: 4px;
    z-index: 1;
  }
  .mobile-panel-close-btn:hover { color: var(--text-primary); }

  /* Message actions — disable hover-only, enable tap-expand */
  .message-actions { display: none !important; }
  .message:hover .message-actions { display: none !important; }
  .message.actions-expanded .message-actions {
    display: inline-flex !important;
    position: absolute; top: 2px; right: 4px; z-index: 10;
  }
  .mobile-msg-actions-btn {
    display: inline-flex; align-items: center;
    background: none; border: none; color: var(--text-muted);
    font-size: 0.9rem; font-weight: bold; letter-spacing: 1px;
    padding: 0 4px; cursor: pointer; margin-left: 0.35rem;
    line-height: 1; flex-shrink: 0;
  }
  .mobile-msg-actions-btn:hover { color: var(--text-primary); }

  /* Header padding-left for hamburger button clearance */
  .chat-header { padding-left: 54px; }

  /* Dynamic viewport height (handles iOS Safari URL bar) */
  .chat-main { height: 100dvh; }

  /* Virtual keyboard + iOS safe area */
  .message-input-container {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  /* Modal sizing */
  .dm-picker-modal { width: 95vw; max-height: 80vh; }
  .profile-modal { width: 95vw; }

  /* Reduced padding on mobile */
  .message-list { padding: 0.75rem; }
  .settings-body { padding: 1rem; }

  /* Center pane header clearance for fixed ☰ hamburger button */
  .blank-screen-header,
  .project-page-header,
  .project-settings-header,
  .user-settings-header,
  .voice-screen-header,
  .admin-pane-header {
    padding-left: 54px;
  }
}

/* Tablet breakpoint */
@media (min-width: 768px) and (max-width: 1199px) {
  /* Narrower right panel on tablet */
  .right-panel { width: 240px; }
  .right-panel-resize-handle { display: none; }
}
