/* ═══════════════════════════════════════════════════
   AgentChat V4 — Dark Theme Stylesheet
   ═══════════════════════════════════════════════════ */

/* ── Global: ensure [hidden] always works ─────────── */
[hidden] { display: none !important; }

/* ── CSS Variables ────────────────────────────────── */
:root {
  /* ── Backgrounds ─────────────────────────────────── */
  --bg: #1a1a2e;
  --bg-primary: #1a1a2e;
  --bg-surface: #16213e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-message-hover: rgba(255, 255, 255, 0.02);
  --bg-input: #0d2d55;
  --bg-login-card: #16213e;
  --bg-server-bar: #0e1525; /* kept for user-panel and other dark accents */

  /* ── Text ────────────────────────────────────────── */
  --text: #e8e8e8;
  --text-primary: #e8e8e8;
  --text-secondary: #8e9aaf;
  --text-muted: #9ca3af;
  --text-link: #53a8b6;
  --text-mention: #7b68ee;

  /* ── Accent ──────────────────────────────────────── */
  --accent: #53a8b6;
  --accent-hover: #6bc4d2;
  --accent-dim: rgba(83, 168, 182, 0.15);

  /* ── Borders ─────────────────────────────────────── */
  --border: #1e3054;
  --border-light: #2a3f5f;

  /* ── Semantic Colors ─────────────────────────────── */
  --success: #43b581;
  --warning: #faa61a;
  --error: #f04747;
  --danger: #f04747;

  /* ── Presence ────────────────────────────────────── */
  --online: #43b581;
  --away: #faa61a;
  --dnd: #f04747;
  --offline: #636b75;

  --bot-badge: #5865f2;

  /* ── Radii ───────────────────────────────────────── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Shadows ─────────────────────────────────────── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* ── Layout ──────────────────────────────────────── */
  --sidebar-width: 240px;
  /* --server-bar-width: 56px; removed — server bar merged into sidebar */
  --member-list-width: 240px;
  --header-height: 48px;

  /* ── Typography ──────────────────────────────────── */
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  /* ── Transitions ─────────────────────────────────── */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-main);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

ul { list-style: none; }

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

input, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

/* ── Focus-visible (keyboard navigation) ─────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Scrollbar (dark theme for webkit browsers) ──── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
::-webkit-scrollbar-corner {
  background: var(--bg-primary);
}
/* Firefox dark scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

/* ═══════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════ */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #0a0e1a 100%);
  animation: loginBgPulse 8s ease-in-out infinite alternate;
}

@keyframes loginBgPulse {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

.login-card {
  background: var(--bg-login-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: loginSlideUp 0.4s ease-out;
}

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

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo .version {
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

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

/* ── Login password show/hide toggle (a11y, card 35116604) ── */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrap input {
  flex: 1;
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted, #6a6a80);
}
.password-toggle:hover {
  color: var(--text-primary, #e0e0e0);
}
.password-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ── Members list: hidden-user badge (admin view, card 90c77b66 / Dan spec) ── */
.member-hidden-badge {
  margin-left: 6px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgba(250,166,26,0.15);
  color: var(--warning, #faa61a);
  flex-shrink: 0;
}
.member-item.hidden-member {
  opacity: 0.72;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

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

.btn-primary:active {
  transform: scale(0.98);
}

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

.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

.login-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 24px;
}

/* ═══════════════════════════════════════════════════
   APP LAYOUT (Flexbox)
   ═══════════════════════════════════════════════════ */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app[hidden] {
  display: none !important;
}

.login-screen[hidden] {
  display: none !important;
}

/* ── Server Bar (removed — merged into sidebar) ──── */
/* .server-bar, .server-icon, .server-separator styles removed */

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 200ms ease, width 200ms ease,
              min-width 200ms ease, box-shadow 200ms ease;
  will-change: transform;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

/* ── Sidebar: desktop-collapsed (narrow icon strip + tiny labels) ── */
@media (min-width: 769px) {
  .sidebar.desktop-collapsed {
    width: 72px;
    min-width: 72px;
    overflow: hidden;
  }

  .sidebar.desktop-collapsed .sidebar-header {
    padding: 0 4px;
    justify-content: center;
    gap: 0;
  }

  .sidebar.desktop-collapsed .sidebar-header-brand,
  .sidebar.desktop-collapsed .sidebar-header #settings-flyout-btn {
    display: none;
  }

  .sidebar.desktop-collapsed .sidebar-section-header span,
  .sidebar.desktop-collapsed .sidebar-section-header .chevron,
  .sidebar.desktop-collapsed .sidebar-section-header .icon-btn-sm {
    display: none;
  }

  .sidebar.desktop-collapsed .sidebar-section-header {
    padding: 4px 0;
    justify-content: center;
    pointer-events: none;
  }

  .sidebar.desktop-collapsed .channel-list {
    padding: 0 2px;
  }

  .sidebar.desktop-collapsed .channel-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    gap: 2px;
  }

  .sidebar.desktop-collapsed .channel-item .channel-label {
    display: block;
    font-size: 9px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 64px;
    line-height: 1.2;
    opacity: 0.7;
  }

  .sidebar.desktop-collapsed .channel-item .unread-badge,
  .sidebar.desktop-collapsed .channel-item .channel-announcement-label,
  .sidebar.desktop-collapsed .channel-item .channel-mute-icon,
  .sidebar.desktop-collapsed .channel-item .drag-handle,
  .sidebar.desktop-collapsed .channel-item .channel-category-dropdown {
    display: none;
  }

  .sidebar.desktop-collapsed .channel-item .channel-hash-icon {
    opacity: 0.8;
    font-size: 18px;
  }

  .sidebar.desktop-collapsed .forge-tools-list .forge-tool-icon {
    font-size: 20px;
  }

  .sidebar.desktop-collapsed .forge-tool-item .channel-label {
    display: block;
    font-size: 9px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 64px;
    line-height: 1.2;
    opacity: 0.7;
  }

  .sidebar.desktop-collapsed .forge-tool-item .notification-badge {
    display: none;
  }

  .sidebar.desktop-collapsed .forge-tool-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    gap: 2px;
  }

  .sidebar.desktop-collapsed .voice-controls,
  .sidebar.desktop-collapsed .voice-connection-status {
    display: none;
  }

  .sidebar.desktop-collapsed .voice-channel-item .voice-label,
  .sidebar.desktop-collapsed .voice-channel-item .voice-user-count {
    display: none;
  }

  .sidebar.desktop-collapsed .voice-channel-item {
    justify-content: center;
    padding: 8px 0;
  }

  .sidebar.desktop-collapsed .sidebar-resize-handle,
  .sidebar.desktop-collapsed .forge-tools-resize-handle {
    display: none;
  }

  .sidebar.desktop-collapsed .user-panel {
    padding: 8px 4px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .sidebar.desktop-collapsed .user-panel-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
  }

  .sidebar.desktop-collapsed .user-panel-name {
    display: block;
    font-size: 9px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 64px;
    line-height: 1.2;
    opacity: 0.7;
  }

  .sidebar.desktop-collapsed .user-panel-tag,
  .sidebar.desktop-collapsed .user-panel-status-btn,
  .sidebar.desktop-collapsed #account-switcher-btn,
  .sidebar.desktop-collapsed #logout-btn,
  .sidebar.desktop-collapsed .status-dropdown {
    display: none;
  }

  /* Collapse toggle button */
  .sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    transition: color var(--transition-fast), background var(--transition-fast);
    font-family: var(--font-main);
    line-height: 1;
  }

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

  /* Member list collapsed state */
  .member-list.desktop-collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: none;
  }

  .member-list.desktop-collapsed .member-list-resize-handle {
    display: none;
  }
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sidebar-header-brand svg {
  flex-shrink: 0;
}

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

.sidebar-section {
  padding: 12px 0 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 4px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.sidebar-section-header:hover {
  color: var(--text-secondary);
}

.sidebar-section-header .chevron {
  transition: transform var(--transition-fast);
  transform: rotate(90deg);
}

.sidebar-section-header.collapsed .chevron {
  transform: rotate(0deg);
}

.sidebar-section-header .icon-btn-sm {
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.sidebar-section-header:hover .icon-btn-sm {
  opacity: 1;
}

/* ── Channel List ─────────────────────────────────── */
.channel-list {
  padding: 0 8px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

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

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

.channel-item .channel-hash-icon {
  font-size: 16px;
  font-weight: 700;
  opacity: 0.5;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.channel-item .channel-label {
  flex: 1;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  font-size: clamp(11px, 1.2vw, 13px);
  min-width: 0;
}

.channel-item .unread-badge {
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

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

/* ── Voice Channel Items ─────────────────────────── */
.voice-channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.voice-channel-item.voice-active {
  color: var(--success);
}

.voice-channel-item .voice-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  opacity: 0.6;
}

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

.voice-channel-item .voice-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-channel-item .voice-user-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 9px;
  margin-left: auto;
}

.voice-channel-participants {
  padding: 0 8px 0 34px;
  margin-top: -2px;
}

.voice-channel-participant {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.voice-channel-participant.speaking {
  color: var(--success);
}

.voice-channel-participant .voice-speaking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.voice-channel-participant.speaking .voice-speaking-dot {
  background: var(--success);
  animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ── Unified Voice Channel Items (in channel list) ── */

.channel-item.channel-type-voice .channel-hash-icon {
  color: var(--text-muted);
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
}

.channel-item.channel-type-voice .channel-hash-icon.voice-icon svg {
  width: 14px;
  height: 14px;
}

.channel-item.channel-type-voice:hover .channel-hash-icon {
  opacity: 1;
}

.channel-item.channel-type-voice.voice-active {
  color: var(--success, #3ba55c);
}

.channel-item.channel-type-voice.voice-active .channel-hash-icon {
  color: var(--success, #3ba55c);
  opacity: 1;
}

.channel-item.channel-type-voice.voice-active .channel-hash-icon svg {
  animation: voice-pulse 2s ease-in-out infinite;
}

.channel-item.channel-type-voice.voice-has-participants {
  color: var(--text-secondary);
}

.channel-item.channel-type-voice .voice-user-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-dim, rgba(88, 101, 242, 0.15));
  color: var(--accent, #5865f2);
  padding: 1px 6px;
  border-radius: 9px;
  margin-left: auto;
  flex-shrink: 0;
}

.channel-item.channel-type-voice.voice-active .voice-user-count {
  background: rgba(59, 165, 92, 0.15);
  color: var(--success, #3ba55c);
}

/* ── Forge Tools Sidebar Section ─────────────────── */
.forge-tools-section {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
  padding-top: 8px;
  flex: none;
}

.forge-tools-list {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.forge-tool-item {
  padding: 5px 8px !important;
  font-size: clamp(11px, 1.2vw, 13px) !important;
  white-space: nowrap;
  overflow: visible;
}

.forge-tool-item:hover {
  background: rgba(88, 101, 242, 0.08) !important;
  color: var(--text-primary) !important;
}

.forge-tool-item.active {
  background: rgba(88, 101, 242, 0.15) !important;
  color: var(--accent) !important;
  border-left: 3px solid var(--accent);
  padding-left: 5px !important;
}

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

.forge-tool-item:hover .forge-tool-icon,
.forge-tool-item.active .forge-tool-icon {
  opacity: 1;
}

/* ── Sidebar resize handle (right edge) ──────────── */
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
  transition: background 0.15s ease;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--border);
}

/* Sidebar needs position:relative for the absolute handle */
.sidebar {
  position: relative;
}

/* ── Forge Tools resize handle (horizontal, above section) ── */
.forge-tools-resize-handle {
  height: 4px;
  cursor: row-resize;
  flex-shrink: 0;
  background: transparent;
  transition: background 0.15s ease;
}

.forge-tools-resize-handle:hover,
.forge-tools-resize-handle.dragging {
  background: var(--border);
}

/* When forge tools section has a fixed height from resizing */
.forge-tools-section.resized {
  flex: none;
  overflow-y: auto;
}

.forge-tools-section.resized .forge-tools-list {
  max-height: none;
}

/* When forge tools is collapsed via its own toggle (not section-collapsed) */
.forge-tools-section.ft-collapsed .forge-tools-list {
  display: none;
}

.forge-tools-section.ft-collapsed {
  flex: none !important;
  height: auto !important;
  overflow: visible;
}

/* Hide forge-tools resize handle when section is collapsed */
.forge-tools-resize-handle.ft-handle-hidden {
  display: none;
}

/* ── Notification badge (sidebar) ────── */
.notification-badge {
  margin-left: auto;
  background: var(--error, #e53935);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 5px;
  flex-shrink: 0;
}

/* ── Voice Controls Panel (bottom of sidebar) ────── */
.voice-controls {
  padding: 8px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-connected-info {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

.voice-participants {
  padding: 0 0 6px;
  max-height: 80px;
  overflow-y: auto;
}

.voice-participant-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  position: relative;
}

.voice-participant-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.voice-participant-item.speaking {
  color: var(--success);
}

.voice-participant-item .voice-speaking-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.voice-participant-item.speaking .voice-speaking-indicator {
  background: var(--success);
  box-shadow: 0 0 4px var(--success);
}

/* Per-user volume slider (on hover) */
.voice-participant-item .voice-volume-slider {
  display: none;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.voice-participant-item:hover .voice-volume-slider {
  display: block;
}

.voice-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.voice-btn-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.voice-ctrl-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.voice-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.voice-ctrl-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.voice-ctrl-btn.muted {
  background: rgba(240, 71, 71, 0.15);
  color: var(--error);
  border-color: var(--error);
}

.voice-leave-btn {
  background: rgba(240, 71, 71, 0.1);
  border-color: rgba(240, 71, 71, 0.3);
  color: var(--error);
}

.voice-leave-btn:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.voice-ctrl-btn.deafened {
  background: rgba(240, 71, 71, 0.15);
  color: var(--error);
  border-color: var(--error);
}

/* ── Voice Connection Status ─────────────────────── */
.voice-connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

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

.voice-status-dot.connecting {
  background: var(--warning);
  animation: voice-status-pulse 1s ease-in-out infinite;
}

.voice-status-dot.connected {
  background: var(--success);
}

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

/* ── Voice Bar Deafen ────────────────────────────── */
.voice-bar-btn.deafened {
  background: rgba(240, 71, 71, 0.2);
  color: var(--error);
}

/* ── Voice Media Container (video/screen) ────────── */
.voice-media-container {
  flex-shrink: 0;
  background: #0a0e1a;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  max-height: 300px;
}

/* Screen share indicator + bot vision toggle */
.screen-share-indicator {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
}

.screen-share-indicator-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.screen-share-indicator .screen-share-name {
  flex: 1;
  color: var(--accent);
  font-weight: 600;
}

.share-with-bots-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.share-with-bots-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.share-with-bots-toggle.active {
  background: rgba(83, 168, 182, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.voice-media-grid {
  display: flex;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.voice-media-tile {
  position: relative;
  flex: 0 0 auto;
  width: 240px;
  height: 160px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-primary);
  border: 2px solid var(--border);
}

.voice-media-tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 8px rgba(67, 181, 129, 0.3);
}

.voice-media-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.voice-media-tile .voice-tile-label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.voice-media-tile.screenshare {
  width: 480px;
  height: 270px;
}

/* ── User Panel (bottom of sidebar) ───────────────── */
.user-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-server-bar);
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.user-panel-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.presence-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-server-bar);
}

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

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

.user-panel-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ── Status Dropdown ─────────────────────────────── */
.user-panel-status-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.user-panel-status-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.status-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 6px 0;
  z-index: 200;
  box-shadow: var(--shadow-md);
  margin-bottom: 4px;
}

.status-dropdown.visible {
  display: block;
}

.status-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

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

.status-dot-icon.online { background: var(--online); }
.status-dot-icon.away { background: var(--away); }
.status-dot-icon.dnd { background: var(--dnd); }
.status-dot-icon.offline { background: var(--offline); }

/* ── Status Divider ────────────────────────────────── */
.status-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 8px;
}

/* ── Custom Status Section ─────────────────────────── */
.status-custom-section {
  padding: 4px 8px;
}

.status-custom-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-custom-emoji {
  font-size: 14px;
  flex-shrink: 0;
}

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

.status-custom-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.status-custom-clear:hover {
  color: var(--error);
}

.status-custom-set-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.status-custom-set-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

/* ── Custom Status Modal ───────────────────────────── */
.custom-status-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.custom-status-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg, 12px);
  padding: 20px;
  width: 360px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,0.4));
}

.custom-status-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text-primary);
}

.custom-status-emoji-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.custom-status-emoji-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.custom-status-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.custom-status-text-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.custom-status-text-input:focus {
  border-color: var(--accent);
}

.custom-status-emoji-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.custom-status-emoji-grid span {
  font-size: 18px;
  padding: 4px;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.custom-status-emoji-grid span:hover {
  background: rgba(255, 255, 255, 0.1);
}

.custom-status-expiry {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.custom-status-expiry label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.custom-status-expiry-select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

.custom-status-expiry-custom {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

.custom-status-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── User Panel Custom Status Display ──────────────── */
.user-panel-custom-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
}
.user-panel-custom-status span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Member Custom Status ──────────────────────────── */
.member-custom-status {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

/* ── Message Author Status ─────────────────────────── */
.message-author-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Make user-panel position relative for dropdown anchoring */
.user-panel {
  position: relative;
}

/* ── Account Switcher Dropdown ────────────────────── */
.account-switcher-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0;
  z-index: 210;
  box-shadow: var(--shadow-md);
  margin-bottom: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.account-switcher-dropdown.visible {
  display: block;
}

.account-switcher-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  letter-spacing: 0.5px;
}

.account-switcher-list {
  padding: 4px 0;
}

.account-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.account-switcher-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.account-switcher-item.active {
  background: rgba(88, 101, 242, 0.12);
}

.account-switcher-item .avatar-circle {
  width: 28px;
  height: 28px;
  font-size: 12px;
  flex-shrink: 0;
}

.account-switcher-item-info {
  flex: 1;
  min-width: 0;
}

.account-switcher-item-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  color: var(--text-primary);
}

.account-switcher-item-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.account-switcher-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.account-switcher-switch-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: opacity var(--transition-fast);
}

.account-switcher-switch-btn:hover {
  opacity: 0.85;
}

.account-switcher-remove-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  font-size: 14px;
  line-height: 1;
}

.account-switcher-remove-btn:hover {
  background: rgba(255, 60, 60, 0.15);
  color: var(--error);
}

.account-switcher-active-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.account-switcher-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.account-switcher-add:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

/* ── Client Conflict Modal ────────────────────────── */
.client-conflict-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}

.client-conflict-modal[hidden] {
  display: none;
}

.client-conflict-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg, 12px);
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,0.4));
}

.client-conflict-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
  color: var(--text-primary);
}

.client-conflict-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}

.client-conflict-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}

.client-conflict-actions .btn-primary {
  padding: 8px 20px;
  font-size: 14px;
}

.client-conflict-actions .btn-secondary {
  padding: 8px 20px;
  font-size: 14px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.client-conflict-actions .btn-secondary:hover {
  background: var(--bg-tertiary, rgba(255,255,255,0.08));
}

.client-conflict-hint {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  margin: 0 !important;
}

/* ── Icon Buttons ─────────────────────────────────── */
.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

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

.icon-btn-sm {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  color: var(--text-muted);
}

.icon-btn-sm:hover {
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════
   CONTENT AREA (wraps tool panel + main content + persistent input)
   ═══════════════════════════════════════════════════ */

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Content Middle (tool-panel/main-content + member-list side-by-side) ── */
.content-middle {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════ */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Persistent Input (always visible at bottom of content-area) ── */
.persistent-input {
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
}

/* When tool panel is NOT open, the persistent input border blends with chat */
.content-area:not(.tool-open) .persistent-input {
  border-top: none;
}

.persistent-channel-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.persistent-channel-hash {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
}

.persistent-channel-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.persistent-back-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

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

/* Persistent typing indicator (shown when tool panel is open) */
.persistent-typing {
  padding-left: 16px;
}

/* When tool panel is open: hide main-content (chat), show tool panel */
.content-area.tool-open .main-content {
  display: none;
}

.content-area.tool-open .tool-panel {
  display: flex;
  flex: 1;
}

/* When tool panel is NOT open: hide typing in persistent area (use inline one) */
.content-area:not(.tool-open) .persistent-typing {
  display: none !important;
}

/* When tool panel is NOT open: hide channel label */
.content-area:not(.tool-open) .persistent-channel-label {
  display: none !important;
}

/* ── Channel Header ───────────────────────────────── */
.channel-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.channel-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.channel-hash {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-muted);
}

.channel-name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.channel-topic {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.channel-topic:empty {
  display: none;
}

.channel-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Per-Channel Voice Button ──────────────────────── */
.channel-voice-btn {
  position: relative;
  color: var(--text-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
}

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

.channel-voice-btn.voice-active {
  color: var(--success, #3ba55c);
}

.channel-voice-btn.voice-active svg {
  animation: voice-pulse 2s ease-in-out infinite;
}

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

.channel-voice-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--success, #3ba55c);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

/* Sidebar voice-active indicator on channel items */
.channel-voice-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--success, #3ba55c);
  flex-shrink: 0;
}

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

/* Hide sidebar collapse button on mobile and by default (shown via @media min-width:769px) */
.sidebar-collapse-btn {
  display: none;
}

/* ── Content Body (messages + members) ────────────── */
.content-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-primary);
}

.messages-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

/* ── Messages ─────────────────────────────────────── */
.messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* scroll-behavior: smooth; -- disabled: breaks programmatic scrollToBottom */
  contain: layout paint;
}

.lock-bottom-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  z-index: 10;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lock-bottom-btn:hover { opacity: 1; }
.lock-bottom-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  opacity: 1;
}

.new-messages-btn {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s, transform 0.2s;
  opacity: 1;
  animation: newMsgBtnAppear 0.2s ease-out;
}

.new-messages-btn:hover {
  filter: brightness(1.1);
}

.new-messages-btn[hidden] {
  display: none;
}

.messages-top-spacer {
  height: 16px;
}

.messages-container {
  padding: 0 16px 8px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  margin-top: 2px;
  border-radius: var(--radius-sm);
  animation: messageAppear 0.2s ease-out;
  contain: content;
  /* Virtual scrolling via content-visibility — the browser skips layout/paint
     for messages outside the viewport, dramatically reducing render cost for
     long channels. The 50px intrinsic size prevents scroll jumpiness. */
  content-visibility: auto;
  contain-intrinsic-size: auto 50px;
}

.message:hover {
  background: var(--bg-message-hover);
}

.message.grouped {
  margin-top: 0;
}

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

.message-avatar {
  flex-shrink: 0;
  width: 40px;
  padding-top: 2px;
}

.message-avatar .avatar-circle {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.message.grouped .message-avatar {
  visibility: hidden;
}

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

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

.message.grouped .message-header {
  display: none;
}

.message-author {
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

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

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

.message.grouped .message-compact-time {
  display: none;
  font-size: 10px;
  color: var(--text-muted);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
  padding-top: 3px;
}

.message.grouped:hover .message-compact-time {
  display: block;
}

.message.grouped:hover .message-avatar {
  display: none;
}

.bot-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--bot-badge);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

.message-content {
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.message-content p {
  margin: 0;
}

.message-content p + p {
  margin-top: 4px;
}

/* Markdown-lite */
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }

.message-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 3px;
  color: #e8e8e8;
}

.message-content pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin: 4px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content a {
  color: var(--text-link);
}

.message-content .mention {
  background: rgba(123, 104, 238, 0.2);
  color: var(--text-mention);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
}

.message-content .mention:hover {
  background: rgba(123, 104, 238, 0.35);
}

/* @mention highlight — entire message row gets a distinct background */
.message.mention-highlight {
  background: rgba(123, 104, 238, 0.08);
  border-left: 3px solid var(--text-mention);
  padding-left: calc(var(--msg-padding-left, 16px) - 3px);
}

.message.mention-highlight:hover {
  background: rgba(123, 104, 238, 0.12);
}

/* Muted channel indicator */
.channel-item.muted .channel-label,
.dm-item.muted .dm-name {
  opacity: 0.5;
}

.channel-mute-icon {
  margin-left: auto;
  opacity: 0.4;
  font-size: 12px;
  flex-shrink: 0;
}

.message-edited {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
}

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

.reaction {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.reaction:hover {
  background: rgba(255, 255, 255, 0.08);
}

.reaction.reaction-mine {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.reaction .reaction-count {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Reaction add button — appears on message hover */
.reaction-add-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  z-index: 5;
}

.message {
  position: relative;
}

.message:hover .reaction-add-btn {
  display: flex;
}

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

/* Quick-react buttons in message action bar */
.message-quick-reactions {
  display: flex;
  gap: 1px;
  align-items: center;
}

.quick-react-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  border: none;
  transition: background var(--transition-fast), transform 0.1s ease;
  opacity: 0.7;
}

.quick-react-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.25);
  opacity: 1;
}

/* Full reaction emoji picker (categorized) */
.reaction-picker-full {
  display: flex;
  flex-direction: column;
  width: 272px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: pickerFadeIn 0.15s ease-out;
  overflow: hidden;
}

.reaction-picker-quick-row {
  display: flex;
  gap: 2px;
  padding: 8px 8px 4px;
  justify-content: center;
}

.reaction-picker-divider {
  height: 1px;
  background: var(--border);
  margin: 0 8px;
}

.reaction-picker-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 2px;
  overflow-x: auto;
}

.reaction-picker-tab {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  border: none;
  opacity: 0.5;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.reaction-picker-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  opacity: 0.8;
}

.reaction-picker-tab.active {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.reaction-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 4px 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.reaction-picker-grid::-webkit-scrollbar {
  width: 5px;
}

.reaction-picker-grid::-webkit-scrollbar-track {
  background: transparent;
}

.reaction-picker-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Legacy flat reaction picker (kept for backward compat) */
.reaction-picker {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: pickerFadeIn 0.15s ease-out;
}

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

.reaction-picker-emoji {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  background: none;
  border: none;
}

.reaction-picker-emoji:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.2);
}

.reaction-quick-emoji {
  width: 36px;
  height: 36px;
  font-size: 22px;
}

/* Reaction pop animation */
@keyframes reactionPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.reaction-pop {
  animation: reactionPop 0.3s ease-out;
}

/* ── Typing Indicator ─────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 24px;
}

.typing-indicator[hidden] {
  display: none !important;
}

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

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

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Message Input ────────────────────────────────── */
.message-input-wrapper {
  padding: 0 6px 8px;
  flex-shrink: 0;
}

.message-input-container {
  display: flex;
  align-items: stretch;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 3px 4px 4px;
  gap: 1px;
  transition: border-color var(--transition-fast);
}

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

/* Left action group (attach, emoji) */
.input-actions-left {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

/* Right action group (schedule, send) */
.input-actions-right {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.input-actions-right .send-btn {
  width: 32px;
  align-self: stretch;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.input-actions-right .send-btn:hover {
  background: var(--accent-hover);
  color: #fff;
}

.message-input {
  flex: 1;
  min-width: 0;
  resize: none;
  padding: 4px 4px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  color: var(--text-primary);
  background: transparent;
}

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

.attach-btn {
  color: var(--text-muted);
}

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

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

/* ═══════════════════════════════════════════════════
   FORMATTING TOOLBAR
   ═══════════════════════════════════════════════════ */

.formatting-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  flex-wrap: wrap;
}

/* Logical button groups within the formatting toolbar */
.fmt-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* Spacer pushes audio group to the far right */
.fmt-spacer {
  flex: 0;
  min-width: 0;
  display: none;
}

/* Audio group visual separation */
.fmt-group-audio {
  gap: 1px;
  padding-left: 0;
  margin-left: 2px;
}

.formatting-toolbar + .fmt-preview-pane + .message-input-container {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.formatting-toolbar + .fmt-preview-pane:not([hidden]) + .message-input-container {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* When toolbar present, remove top radius from input container */
.formatting-toolbar ~ .message-input-container {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.fmt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.fmt-btn:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.fmt-btn:active,
.fmt-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.fmt-btn svg {
  flex-shrink: 0;
}

.fmt-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.fmt-codeblock-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.fmt-lang-picker {
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  outline: none;
}

.fmt-lang-picker:focus {
  border-color: var(--accent);
}

.fmt-lang-picker option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.fmt-preview-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Markdown preview pane */
.fmt-preview-pane {
  padding: 10px 12px;
  background: var(--bg-input);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 40px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.fmt-preview-pane:empty::before {
  content: 'Nothing to preview';
  color: var(--text-muted);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════
   SLASH COMMAND PALETTE
   ═══════════════════════════════════════════════════ */

.slash-command-palette {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
  z-index: 60;
}

.slash-command-list {
  list-style: none;
  margin: 0;
  padding: 4px;
}

.slash-command-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.slash-command-option:hover,
.slash-command-option.selected {
  background: var(--accent-dim);
}

.slash-command-option .slash-cmd-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.slash-command-option .slash-cmd-desc {
  color: var(--text-muted);
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════
   MEMBER LIST
   ═══════════════════════════════════════════════════ */

.member-list {
  position: relative;
  width: var(--member-list-width);
  min-width: var(--member-list-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
  transition: width 200ms ease, min-width 200ms ease, padding 200ms ease, border 200ms ease;
}

/* ── Member list resize handle (left edge) ──────────── */
.member-list-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
  transition: background 0.15s ease;
}

.member-list-resize-handle:hover,
.member-list-resize-handle.dragging {
  background: var(--border);
}

.member-list.hidden,
.member-list.thread-active-hide {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}

.member-list.hidden .member-list-resize-handle,
.member-list.thread-active-hide .member-list-resize-handle {
  display: none;
}

.member-section {
  margin-bottom: 16px;
}

.member-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 8px 6px;
}

.member-items {}

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

.member-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.member-item .member-avatar {
  position: relative;
  flex-shrink: 0;
}

.member-item .avatar-circle {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.member-item .presence-dot {
  width: 10px;
  height: 10px;
  border-width: 2px;
  border-color: var(--bg-secondary);
}

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

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

.member-item .member-name .bot-badge {
  margin-left: 4px;
  font-size: 9px;
  vertical-align: middle;
}

.member-item .member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ═══════════════════════════════════════════════════
   ROLE-BASED MEMBER GROUPS
   ═══════════════════════════════════════════════════ */

.member-role-group {
  margin-bottom: 4px;
}

.member-role-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  user-select: none;
  transition: background var(--transition-fast);
}

.member-role-group-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.member-group-chevron {
  flex-shrink: 0;
  transition: transform 150ms ease;
  transform: rotate(90deg);
  color: var(--text-muted);
}

.member-group-chevron.collapsed {
  transform: rotate(0deg);
}

.member-group-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.member-role-group[data-role-group="admin"] .member-group-icon {
  color: var(--warning, #f0a020);
}

.member-role-group[data-role-group="moderator"] .member-group-icon {
  color: var(--accent);
}

.member-role-group[data-role-group="bot"] .member-group-icon {
  color: var(--success, #43b581);
}

.member-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.member-group-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.7;
}

.member-role-group .member-items {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 200ms ease;
}

.member-role-group .member-items.collapsed {
  max-height: 0;
}

/* ═══════════════════════════════════════════════════
   MEMBER MINI-PROFILE POPUP
   ═══════════════════════════════════════════════════ */

.member-profile-popup {
  position: fixed;
  z-index: 1000;
  width: 260px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  animation: memberProfileFadeIn 120ms ease-out;
}

.member-profile-popup[hidden] {
  display: none;
}

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

.member-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
}

.member-profile-avatar {
  position: relative;
  flex-shrink: 0;
}

.member-profile-avatar .avatar-circle {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.member-profile-avatar .presence-dot {
  width: 14px;
  height: 14px;
  border-width: 3px;
  border-color: var(--bg-secondary);
}

.member-profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

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

.member-profile-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 10px;
  width: fit-content;
}

.member-profile-role-badge[data-role="admin"] {
  color: var(--warning, #f0a020);
  background: rgba(240, 160, 32, 0.12);
}

.member-profile-role-badge[data-role="moderator"] {
  color: var(--accent);
  background: rgba(var(--accent-rgb, 88, 101, 242), 0.12);
}

.member-profile-role-badge[data-role="bot"] {
  color: var(--success, #43b581);
  background: rgba(67, 181, 129, 0.12);
}

.member-profile-details {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.member-profile-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-profile-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.member-profile-value {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.member-profile-actions {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
}

.member-profile-dm-btn {
  width: 100%;
  text-align: center;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: none;
  transition: opacity var(--transition-fast);
}

.member-profile-dm-btn:hover {
  opacity: 0.85;
}

/* ═══════════════════════════════════════════════════
   CONNECTION TOAST
   ═══════════════════════════════════════════════════ */

.connection-toast {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warning);
  color: #000;
  padding: 6px 20px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  z-index: 1000;
  animation: toastSlideDown 0.3s ease-out;
}

.connection-toast.error {
  background: var(--error);
  color: #fff;
}

.connection-toast.success {
  background: var(--success);
  color: #fff;
}

@keyframes toastSlideDown {
  from { transform: translateX(-50%) translateY(-100%); }
  to { transform: translateX(-50%) translateY(0); }
}

/* ── Responsive: see consolidated breakpoints near end of file ── */

/* ═══════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Day separator in message list */
.day-separator {
  display: flex;
  align-items: center;
  margin: 16px 0 8px;
  gap: 12px;
}

.day-separator::before,
.day-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.day-separator span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

/* Welcome message at top of channel */
.channel-welcome {
  padding: 16px 0 8px;
}

.channel-welcome h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.channel-welcome p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Loading spinner — shared across all pages */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.spinner-xl {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.spinner-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* ═══════════════════════════════════════════════════
   FILE UPLOADS & IMAGE ATTACHMENTS
   ═══════════════════════════════════════════════════ */

/* Inline images in messages */
.message-image-link {
  display: block;
  margin: 6px 0;
  line-height: 0;
}

.message-image {
  max-width: min(400px, 90vw);
  max-height: 300px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition-fast);
  object-fit: contain;
}

.message-image:hover {
  opacity: 0.85;
}

/* File download links in messages */
.message-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-link);
  font-size: 13px;
  text-decoration: none;
  transition: background var(--transition-fast);
}

.message-file-link:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

/* Attach button active state */
.attach-btn:hover {
  color: var(--accent);
}

/* Upload preview (shown while uploading) */
.upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 16px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: messageAppear 0.15s ease-out;
}

.upload-preview-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.upload-preview-file-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.upload-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

.upload-preview-size {
  font-size: 11px;
  color: var(--text-muted);
}

.upload-preview-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-preview-cancel {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.upload-preview-cancel:hover {
  color: var(--error);
  background: rgba(240, 71, 71, 0.1);
}

/* Drag-and-drop overlay */
.messages-wrapper.drag-over {
  position: relative;
}

.messages-wrapper.drag-over::after {
  content: 'Drop file to upload';
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(83, 168, 182, 0.1);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════
   MESSAGE ATTACHMENTS
   ═══════════════════════════════════════════════════ */

.message-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.attachment {
  max-width: 400px;
}

.attachment-image .message-image {
  border-radius: var(--radius);
  max-width: 350px;
  max-height: 300px;
  object-fit: contain;
  cursor: pointer;
}

.attachment-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.attachment-file .message-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
}

.attachment-file .message-file-link:hover {
  background: var(--bg-secondary);
}

.attachment-video .message-video {
  max-width: min(400px, 90vw);
  max-height: 350px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #000;
}

.attachment-size {
  color: var(--text-muted);
  font-size: 11px;
}

/* Upload preview items (multiple attachments) */
.upload-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.upload-preview-item + .upload-preview-item {
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════
   CREATE CHANNEL MODAL
   ═══════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: modalFadeIn 0.15s ease-out;
}

.modal-overlay[hidden] {
  display: none !important;
}

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

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.2s ease-out;
  will-change: transform, opacity;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

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

.btn-secondary {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.modal-actions .btn-primary {
  width: auto;
  padding: 10px 24px;
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════
   DIRECT MESSAGES — Sidebar
   ═══════════════════════════════════════════════════ */

.dm-section {
  flex: none;
}

.dm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

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

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

.dm-item .dm-avatar {
  position: relative;
  flex-shrink: 0;
}

.dm-item .avatar-circle {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.dm-item .presence-dot {
  width: 8px;
  height: 8px;
  border-width: 2px;
  border-color: var(--bg-secondary);
  bottom: -2px;
  right: -2px;
}

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

.dm-item .unread-badge {
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

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

/* DM info column (name + status on separate lines) */
.dm-item .dm-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.dm-item .dm-info .dm-name {
  flex: none;
}

.dm-item .dm-status-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-item .dm-status-away { color: var(--warning); }
.dm-item .dm-status-dnd { color: var(--error); }

/* Group DM stacked avatars */
.dm-avatar-group {
  position: relative;
  width: 28px;
  height: 24px;
  flex-shrink: 0;
}

.dm-avatar-group .dm-avatar-stack-1 {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  font-size: 8px;
  z-index: 2;
}

.dm-avatar-group .dm-avatar-stack-2 {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  font-size: 8px;
  z-index: 1;
}

.dm-avatar-group .dm-avatar-count {
  position: absolute;
  bottom: -2px;
  right: -4px;
  font-size: 8px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 0 2px;
  z-index: 3;
}

/* DM search input */
.dm-search-wrap {
  padding: 4px 8px 6px;
}

.dm-search-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  transition: border-color var(--transition-fast);
}

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

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

/* Group DM button in header */
.dm-group-btn {
  margin-left: auto;
}

/* DM header info (in channel header for active DM) */
.dm-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.dm-header-avatar {
  position: relative;
  flex-shrink: 0;
}

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

.dm-header-profile-btn {
  font-size: 11px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.dm-header-profile-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* Group DM modal */
.group-dm-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  min-height: 0;
}

.group-dm-selected:empty {
  margin-top: 0;
}

.group-dm-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.group-dm-chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.group-dm-chip button:hover {
  color: var(--error);
}

.group-dm-user-list {
  list-style: none;
  margin: 0;
  padding: 8px;
}

.group-dm-user-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: background var(--transition-fast);
}

.group-dm-user-option:hover {
  background: rgba(255, 255, 255, 0.04);
}

.group-dm-user-option.selected {
  background: rgba(var(--accent-rgb, 99, 102, 241), 0.15);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════
   @MENTION AUTOCOMPLETE
   ═══════════════════════════════════════════════════ */

.mention-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-bottom: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 300;
  animation: mentionFadeIn 0.1s ease-out;
}

.mention-autocomplete[hidden] {
  display: none !important;
}

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

.mention-list {
  padding: 4px 0;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.mention-option:hover,
.mention-option.active {
  background: rgba(255, 255, 255, 0.06);
}

.mention-option .avatar-circle {
  width: 24px;
  height: 24px;
  font-size: 10px;
  flex-shrink: 0;
}

.mention-option-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.mention-option-username {
  font-size: 11px;
  color: var(--text-muted);
}

.mention-option .bot-badge {
  font-size: 9px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Make message-input-wrapper position relative for autocomplete anchoring */
.message-input-wrapper {
  position: relative;
}

/* ═══════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════ */

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

.empty-state-icon {
  opacity: 0.5;
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════
   EDITING STATE
   ═══════════════════════════════════════════════════ */

.message-input.editing {
  border-left: 3px solid var(--warning);
  padding-left: 5px;
}

.message-input-container:has(.message-input.editing) {
  border-color: var(--warning);
}

/* ═══════════════════════════════════════════════════
   MOBILE SIDEBAR BACKDROP
   ═══════════════════════════════════════════════════ */

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.sidebar-backdrop[hidden] {
  display: none !important;
}

/* ── Mobile member list backdrop ──────────────────── */
.member-list-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.member-list-backdrop[hidden] {
  display: none !important;
}

/* ═══════════════════════════════════════════════════
   SEARCH PANEL
   ═══════════════════════════════════════════════════ */

.search-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: searchSlideIn 0.2s ease-out;
}

.search-panel[hidden] {
  display: none !important;
}

@keyframes searchSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.search-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.search-input-wrapper {
  position: relative;
  padding: 12px 16px;
  flex-shrink: 0;
}

.search-input-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

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

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

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.search-empty,
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.search-error {
  color: var(--error);
}

.search-result-item {
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.search-result-channel {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: lowercase;
}

.search-result-message {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.search-result-avatar {
  flex-shrink: 0;
  padding-top: 1px;
}

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

.search-result-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}

.search-result-author {
  font-size: 13px;
  font-weight: 600;
}

.search-result-time {
  font-size: 10px;
  color: var(--text-muted);
}

.search-result-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  /* Clamp to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-highlight {
  background: rgba(250, 166, 26, 0.3);
  color: var(--text-primary);
  padding: 0 1px;
  border-radius: 2px;
}

/* Flash animation for navigated-to message */
@keyframes searchFlash {
  0% { background: rgba(83, 168, 182, 0.25); }
  100% { background: transparent; }
}

.message.search-flash {
  animation: searchFlash 2s ease-out;
}

.search-result-count {
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  border-bottom: 1px solid var(--border-color, #333);
  font-weight: 500;
}

.search-load-more {
  padding: 12px 16px;
  text-align: center;
  color: var(--accent-color, #5865f2);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  border-top: 1px solid var(--border-color, #333);
  transition: background 0.15s;
}
.search-load-more:hover {
  background: var(--hover-bg, rgba(255,255,255,0.05));
}

/* Responsive: search panel — see consolidated breakpoints */

/* Search backdrop overlay */
.search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 299;
  backdrop-filter: blur(2px);
}

.search-backdrop[hidden] {
  display: none !important;
}

/* Search modal (centered overlay) */
.search-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  right: auto;
  width: 640px;
  max-width: 92vw;
  height: auto;
  max-height: 80vh;
  border-radius: var(--radius-lg, 12px);
  border-left: none;
  animation: searchFadeIn 0.15s ease-out;
}

@keyframes searchFadeIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.search-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-shortcut-hint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* Search Filters */
.search-filters {
  padding: 8px 16px 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-filter-group {
  flex: 1;
  min-width: 0;
}

.search-filter-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.search-filter-select,
.search-filter-input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  font-size: 12px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.search-filter-select:focus,
.search-filter-input:focus {
  border-color: var(--accent);
}

.search-filter-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.search-filter-tags {
  gap: 6px;
  flex-wrap: wrap;
}

.search-filter-tag {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.search-filter-tag:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.search-filter-tag.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Search History */
.search-history {
  border-bottom: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
}

.search-history[hidden] {
  display: none !important;
}

.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-history-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm, 4px);
  transition: color var(--transition-fast);
}

.search-history-clear:hover {
  color: var(--error);
}

.search-history-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 8px;
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background var(--transition-fast);
  color: var(--text-secondary);
  font-size: 13px;
}

.search-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.search-history-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.search-history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Results Info */
.search-results-info {
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-results-info[hidden] {
  display: none !important;
}

/* Pagination */
.search-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.search-pagination[hidden] {
  display: none !important;
}

.search-page-info {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-sm:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

@media (max-width: 768px) {
  .search-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    top: 0;
    left: 0;
    transform: none;
    border-radius: 0;
  }
}

/* ═══════════════════════════════════════════════════
   REPLY / EDIT INDICATOR BAR
   ═══════════════════════════════════════════════════ */

.input-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  margin-bottom: 4px;
  background: var(--bg-input);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  animation: indicatorSlideIn 0.15s ease-out;
}

.input-indicator[hidden] {
  display: none !important;
}

.input-indicator.editing {
  border-left-color: var(--warning);
}

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

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

.input-indicator-text strong {
  color: var(--accent);
  font-weight: 600;
}

.input-indicator.editing .input-indicator-text strong {
  color: var(--warning);
}

.input-indicator-cancel {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.input-indicator-cancel:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* ═══════════════════════════════════════════════════
   MESSAGE ACTION BUTTONS (hover toolbar)
   ═══════════════════════════════════════════════════ */

.message-actions {
  position: absolute;
  top: -12px;
  right: 8px;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

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

.message-action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

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

.message-action-btn.bookmark-btn.bookmarked {
  color: var(--accent);
}
.message-action-btn.bookmark-btn.bookmarked:hover {
  color: var(--error);
}

/* ═══════════════════════════════════════════════════
   REPLY CONTEXT (above message content)
   ═══════════════════════════════════════════════════ */

.message-reply-context {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 4px 0;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 52px;
}

.message-reply-context:hover {
  color: var(--text-secondary);
}

.message-reply-context .reply-icon {
  flex-shrink: 0;
  opacity: 0.6;
}

.message-reply-context .reply-author {
  font-weight: 600;
  color: var(--text-secondary);
}

.message-reply-context .reply-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
}

/* ═══════════════════════════════════════════════════
   USER PROFILE POPUP
   ═══════════════════════════════════════════════════ */

.profile-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  animation: modalFadeIn 0.15s ease-out;
}

.profile-popup[hidden] {
  display: none !important;
}

.profile-popup-card {
  position: relative;
  width: 340px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.2s ease-out;
}

.profile-popup-banner {
  height: 60px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--bg-tertiary) 100%);
}

.profile-popup-body {
  padding: 0 20px 20px;
  text-align: center;
}

.profile-popup-avatar {
  position: relative;
  display: inline-block;
  margin-top: -28px;
  margin-bottom: 8px;
}

.profile-popup-avatar .avatar-circle {
  width: 56px;
  height: 56px;
  font-size: 22px;
  border: 3px solid var(--bg-secondary);
}

.profile-popup-avatar .presence-dot {
  width: 14px;
  height: 14px;
  border-width: 3px;
  border-color: var(--bg-secondary);
  bottom: 0;
  right: 0;
}

.profile-popup-displayname {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.profile-popup-username {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.profile-popup-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--bot-badge);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 8px;
}

.profile-popup-badge[hidden] {
  display: none !important;
}

.profile-popup-meta {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 12px 0;
  margin: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.profile-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-meta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.profile-meta-value {
  font-size: 13px;
  color: var(--text-secondary);
}

.profile-dm-btn {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  font-size: 14px;
}

.profile-popup-badge-admin {
  background: var(--accent) !important;
}

.profile-popup-custom-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0;
}

.profile-popup-custom-status[hidden] { display: none !important; }

.profile-popup-bio {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0;
  line-height: 1.4;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-popup-bio[hidden] { display: none !important; }

.profile-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  color: rgba(255, 255, 255, 0.7);
  z-index: 1;
}

.profile-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* ═══════════════════════════════════════════════════
   SETTINGS OVERLAY
   ═══════════════════════════════════════════════════ */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  animation: modalFadeIn 0.15s ease-out;
}

.settings-overlay[hidden] {
  display: none !important;
}

.settings-panel {
  width: 480px;
  max-width: 95vw;
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.2s ease-out;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.settings-field {
  margin-bottom: 16px;
}

.settings-field:last-child {
  margin-bottom: 0;
}

.settings-field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.settings-input-row {
  display: flex;
  gap: 8px;
}

.settings-input-row input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.settings-input-row input[type="text"]:focus {
  border-color: var(--accent);
}

.settings-input-row .btn-primary {
  width: auto;
  padding: 8px 16px;
  font-size: 13px;
  flex-shrink: 0;
}

.settings-field-hint {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  min-height: 16px;
  color: var(--text-muted);
}

.settings-field-hint.success {
  color: var(--success);
}

.settings-field-hint.error {
  color: var(--error);
}

/* Toggle switch */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-toggle-row > label:first-child {
  margin-bottom: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border-light);
  border-radius: 11px;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

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

/* Volume / range slider */
.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.settings-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-secondary);
}

.settings-slider-value {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

/* Select dropdown */
.settings-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%235a6577'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.settings-select:focus {
  border-color: var(--accent);
}
.settings-select:focus:not(:focus-visible) {
  outline: none;
}

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

/* Font size classes applied to body */
body.font-small { font-size: 13px; }
body.font-medium { font-size: 14px; }
body.font-large { font-size: 16px; }

/* Clickable usernames in messages/members for profile popup */
.message-author.clickable,
.member-item.clickable {
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════
   CONTEXT MENU
   ═══════════════════════════════════════════════════ */

.context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  animation: contextMenuFadeIn 0.1s ease-out;
}

.context-menu[hidden] {
  display: none !important;
}

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

.context-menu-list {
  padding: 6px 0;
  list-style: none;
  margin: 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.context-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.context-menu-item.context-menu-danger {
  color: var(--error);
}

.context-menu-item.context-menu-danger:hover {
  background: rgba(240, 71, 71, 0.1);
  color: var(--error);
}

.context-menu-item[hidden] {
  display: none !important;
}

.context-menu-separator {
  height: 1px;
  margin: 4px 8px;
  background: var(--border);
  list-style: none;
}

.context-submenu-arrow {
  margin-left: auto;
  opacity: 0.5;
}

.context-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  animation: contextMenuFadeIn 0.1s ease-out;
}

.context-submenu[hidden] {
  display: none !important;
}

/* ═══════════════════════════════════════════════════
   PINNED MESSAGES PANEL
   ═══════════════════════════════════════════════════ */

.pinned-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: searchSlideIn 0.2s ease-out;
}

.pinned-panel[hidden] {
  display: none !important;
}

.pinned-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pinned-panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.pinned-results {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.pinned-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.pinned-message-item {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.pinned-message-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.pinned-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.pinned-message-author {
  font-size: 13px;
  font-weight: 600;
}

.pinned-message-time {
  font-size: 10px;
  color: var(--text-muted);
}

.pinned-message-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pinned-message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.pinned-unpin-btn {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.pinned-unpin-btn:hover {
  background: rgba(240, 71, 71, 0.1);
  color: var(--error);
}

/* Pin indicator on messages */
.message-pin-indicator {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════
   CONFIRMATION DIALOG
   ═══════════════════════════════════════════════════ */

.confirm-dialog-card {
  max-width: 380px;
}

.confirm-dialog-message {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 0;
}

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

/* Responsive: pinned panel — see consolidated breakpoints */

/* ═══════════════════════════════════════════════════
   CHANNEL SETTINGS & ADMIN FEATURES
   ═══════════════════════════════════════════════════ */

/* Clickable channel name in header */
.channel-name-btn {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  display: inline-flex;
  align-items: center;
}

.channel-name-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.channel-name-btn:hover .channel-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Channel settings modal */
.channel-settings-card {
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Channel settings tabs */
.cs-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.cs-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.cs-tab:hover {
  color: var(--text-primary);
}

.cs-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.cs-tab-content {
  display: none;
}

.cs-tab-content.active {
  display: block;
}

/* Channel info stats grid */
.cs-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 16px;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.cs-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-info-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.cs-info-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Toggle switch */
.cs-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.cs-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.cs-toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.cs-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cs-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: background 0.2s;
}

.cs-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.cs-toggle-switch input:checked + .cs-toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.cs-toggle-switch input:checked + .cs-toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* Members tab */
.cs-members-header {
  margin-bottom: 12px;
}

.cs-invite-row {
  position: relative;
}

.cs-member-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cs-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}

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

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

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

.cs-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cs-member-role {
  font-size: 10px;
  color: var(--text-muted);
}

.cs-member-actions {
  flex-shrink: 0;
}

.cs-kick-btn {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--error);
  background: none;
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.cs-member-item:hover .cs-kick-btn {
  opacity: 1;
}

.cs-kick-btn:hover {
  background: var(--error);
  color: #fff;
}

/* Role badges in member list */
.cs-role-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cs-role-badge.admin {
  background: var(--warning);
  color: #000;
}

.cs-role-badge.bot {
  background: var(--accent);
  color: #fff;
}

.cs-role-badge.mod {
  background: #7c6de3;
  color: #fff;
}

/* Invite members components (shared between create + settings) */
.invite-members-search {
  position: relative;
}

.invite-search-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-sizing: border-box;
}

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

.invite-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 10;
  margin-top: 4px;
}

.invite-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.1s;
}

.invite-result-item:hover {
  background: var(--bg-primary);
}

.invite-result-item .avatar-circle {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.invited-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.invited-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.invited-tag-remove {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.1s;
  background: none;
  border: none;
  color: #fff;
  padding: 0 2px;
}

.invited-tag-remove:hover {
  opacity: 1;
}

/* Leave channel button (outline style) */
.btn-danger-outline {
  padding: 8px 16px;
  background: transparent;
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-danger-outline:hover {
  background: var(--error);
  color: #fff;
}

/* Header enhancements */
.channel-type-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

.channel-type-badge.type-private {
  background: #7c6de3;
  color: #fff;
}

.channel-type-badge.type-announcement {
  background: var(--warning);
  color: #000;
}

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

.header-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}

.header-stat svg {
  opacity: 0.6;
}

.header-pin-btn {
  position: relative;
}

.header-pin-count {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Announcement channel sidebar indicator */
.channel-hash-icon.announcement-icon {
  color: var(--warning);
  font-weight: 700;
}

.channel-announcement-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 4px;
}

/* Announcement channel input disabled state */
.announcement-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Search in channel button */
#header-search-in-channel-btn {
  display: none;
}
@media (min-width: 769px) {
  #header-search-in-channel-btn {
    display: flex;
  }
}

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

.form-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Danger button */
.btn-danger {
  padding: 8px 16px;
  background: var(--error);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-danger:hover {
  background: #d83a3a;
}

.btn-danger:active {
  transform: scale(0.98);
}

/* Confirm delete modal */
.confirm-delete-card {
  max-width: 440px;
}

.confirm-delete-text {
  padding: 0 24px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-delete-text strong {
  color: var(--text-primary);
}

/* Admin badge */
.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--warning);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
  flex-shrink: 0;
  line-height: 1.3;
}

/* Kick button in member list (admin only) */
.member-kick-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  margin-left: auto;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}

.admin-mode .member-kick-btn {
  display: block;
}

.member-item:hover .member-kick-btn {
  opacity: 0.6;
}

.member-kick-btn:hover {
  opacity: 1 !important;
  color: var(--error);
  background: rgba(240, 71, 71, 0.1);
}

/* ═══════════════════════════════════════════════════
   VOICE BAR — Floating controls at bottom of screen
   ═══════════════════════════════════════════════════ */

.voice-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-server-bar);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 20px;
  z-index: 500;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  animation: voiceBarSlideUp 0.25s ease-out;
  min-width: min(480px, calc(100vw - 16px));
}

.voice-bar[hidden] { display: none !important; }

@keyframes voiceBarSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(100%); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.voice-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.voice-bar-room {
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.voice-bar-participants {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 9px;
  flex-shrink: 0;
}

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

.voice-bar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

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

.voice-bar-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.voice-bar-btn.muted {
  background: rgba(240, 71, 71, 0.15);
  color: var(--error);
  border-color: var(--error);
}

/* PTT button — wider to fit label */
#voice-bar-ptt-btn {
  width: auto;
  border-radius: 18px;
  padding: 0 12px;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#voice-bar-ptt-btn.ptt-active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

#voice-bar-ptt-btn.ptt-talking {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(67, 181, 129, 0.5);
}

.voice-bar-btn-label {
  font-size: 11px;
}

.voice-bar-disconnect {
  background: rgba(240, 71, 71, 0.1);
  border-color: rgba(240, 71, 71, 0.3);
  color: var(--error);
}

.voice-bar-disconnect:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.voice-bar-right {
  display: flex;
  align-items: center;
}

.voice-bar-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════
   VOICE — Speaking Indicator (green glow)
   ═══════════════════════════════════════════════════ */

.voice-media-tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(67, 181, 129, 0.4), 0 0 24px rgba(67, 181, 129, 0.15);
}

.voice-channel-participant.speaking .vc-participant-avatar,
.vc-participant-entry.speaking .vc-participant-avatar {
  box-shadow: 0 0 0 2px var(--success), 0 0 8px rgba(67, 181, 129, 0.4);
  border-radius: 50%;
}

/* ═══════════════════════════════════════════════════
   VOICE — Audio Level Meter
   ═══════════════════════════════════════════════════ */

.voice-level-meter {
  width: 3px;
  height: 16px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.voice-level-meter-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: height 80ms linear;
}

.voice-level-meter-fill.level-high {
  background: var(--warning);
}

/* ═══════════════════════════════════════════════════
   VOICE — Sidebar Channel Participants
   ═══════════════════════════════════════════════════ */

.vc-participant-list {
  padding: 2px 8px 4px 28px;
  list-style: none;
}

.vc-participant-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.vc-participant-entry.speaking {
  color: var(--success);
}

.vc-participant-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: box-shadow var(--transition-fast);
}

.vc-participant-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════
   VOICE — Screenshare Auto-Maximize
   ═══════════════════════════════════════════════════ */

.voice-media-grid.has-screenshare {
  flex-direction: column;
  align-items: stretch;
}

.voice-media-grid.has-screenshare .voice-media-tile.screenshare {
  width: 100%;
  height: auto;
  max-height: 50vh;
  flex: 1 1 auto;
}

.voice-media-grid.has-screenshare .voice-media-tile.screenshare video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.voice-media-grid.has-screenshare .voice-media-thumbnails {
  display: flex;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  justify-content: center;
  flex-shrink: 0;
}

.voice-media-grid.has-screenshare .voice-media-thumbnails .voice-media-tile {
  width: 120px;
  height: 80px;
  flex: 0 0 120px;
}

.voice-media-container.screenshare-active {
  max-height: 60vh;
}

/* ═══════════════════════════════════════════════════
   VOICE — Picture-in-Picture Window
   ═══════════════════════════════════════════════════ */

.voice-pip {
  position: fixed;
  bottom: 60px;
  right: 16px;
  width: 280px;
  background: var(--bg-server-bar);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  overflow: hidden;
  animation: pipFadeIn 0.2s ease-out;
  resize: both;
  min-width: 200px;
  min-height: 120px;
}

.voice-pip[hidden] { display: none !important; }

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

.voice-pip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  cursor: move;
}

.voice-pip-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

.voice-pip-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  background: none;
  border: none;
}

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

.voice-pip-content {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  min-height: 60px;
  background: #0a0e1a;
}

.voice-pip-content .pip-participant {
  position: relative;
  flex: 1 1 45%;
  min-width: 60px;
  min-height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-primary);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-pip-content .pip-participant.speaking {
  border-color: var(--success);
  box-shadow: 0 0 8px rgba(67, 181, 129, 0.3);
}

.voice-pip-content .pip-participant video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.voice-pip-content .pip-participant .pip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.voice-pip-content .pip-participant .pip-name {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 4px;
  border-radius: 2px;
}

.voice-pip-controls {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.voice-pip-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.voice-pip-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.voice-pip-btn.muted {
  background: rgba(240, 71, 71, 0.15);
  color: var(--error);
  border-color: var(--error);
}

.voice-pip-disconnect {
  background: rgba(240, 71, 71, 0.1);
  border-color: rgba(240, 71, 71, 0.3);
  color: var(--error);
}

.voice-pip-disconnect:hover {
  background: var(--error);
  color: #fff;
}

/* Add bottom padding to app when voice bar is visible */
.app.voice-active {
  padding-bottom: 52px;
}

/* Voice bar responsive — see consolidated breakpoints */

/* ═══════════════════════════════════════════════════
   FORGE Tools Navigation
   ═══════════════════════════════════════════════════ */

/* Server-bar forge-tool icon styles removed — tools now in sidebar only */

/* Tool Panel (iframe container) — hidden by default, shown via .content-area.tool-open */
.tool-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background: var(--bg-primary);
}
.tool-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.tool-panel-header span {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
}
.tool-panel-actions {
  display: flex;
  gap: 4px;
}
.tool-iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
}

/* ═══════════════════════════════════════════════════
   Settings Flyout Panel
   ═══════════════════════════════════════════════════ */
.settings-flyout-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 299;
}
.settings-flyout {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-secondary);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}
.settings-flyout.open {
  transform: translateX(0);
}
.settings-flyout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.settings-flyout-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-flyout-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.settings-section {
  padding: 8px 0;
}
.settings-section + .settings-section {
  border-top: 1px solid var(--border);
}
.settings-section-title {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.settings-item:hover {
  background: var(--bg-hover);
}
.settings-item.active {
  background: rgba(88, 101, 242, 0.12);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}
.settings-chevron {
  font-size: 18px;
  color: var(--text-secondary);
  margin-left: auto;
}
.settings-inline {
  cursor: default;
}
.settings-inline:hover {
  background: transparent;
}
.settings-inline input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}
.settings-about {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: default;
}
.settings-about:hover {
  background: transparent;
}
.settings-logout {
  color: var(--error, #e74c3c);
  font-weight: 600;
}
.settings-logout:hover {
  background: rgba(231, 76, 60, 0.1);
}

/* Settings flyout responsive — see consolidated breakpoints */

/* ═══════════════════════════════════════════════════
   SHARED TOAST NOTIFICATIONS
   (replaces per-page inline .toast styles)
   ═══════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.toast.warning {
  border-color: var(--warning);
  color: var(--warning);
}

.toast.error {
  border-color: var(--error);
  color: var(--error);
}

/* Filled toast variant — solid background */
.toast.toast-filled {
  border: none;
}

.toast.toast-filled.success {
  background: var(--success);
  color: #fff;
}

.toast.toast-filled.warning {
  background: var(--warning);
  color: #000;
}

.toast.toast-filled.error {
  background: var(--error);
  color: #fff;
}

/* ═══════════════════════════════════════════════════
   FORM INPUTS — Consistent Shared Styling
   ═══════════════════════════════════════════════════ */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"],
textarea,
select {
  font-family: var(--font-main);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Select arrow for dark styling */
select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%239ca3af'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — Consolidated Breakpoints
   ═══════════════════════════════════════════════════ */

/* ── Tablet: <=1023px (hide member list inline, mobile uses slide-over) ─ */
@media (max-width: 1023px) and (min-width: 769px) {
  .member-list {
    display: none;
  }
}

@media (max-width: 1023px) {
  .voice-media-tile.screenshare {
    width: 100%;
    height: auto;
  }
}

/* ── Phone / small tablet: <=768px ─────────────────── */
@media (max-width: 768px) {
  .app {
    padding-bottom: 0;
    position: relative;
    width: 100vw;
    overflow: hidden;
  }

  /* Sidebar: hidden by default, slides in as overlay when toggled */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 1000;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Override desktop collapsed state on mobile — sidebar is always off-screen or overlay */
  .sidebar.collapsed,
  .sidebar.desktop-collapsed {
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
  }

  .sidebar.collapsed.open,
  .sidebar.desktop-collapsed.open {
    transform: translateX(0);
  }

  /* Chat area: always 100% width since sidebar is overlay */
  .main-content {
    width: 100%;
    flex: 1;
    min-width: 0;
  }

  /* Content area fills remaining space */
  .content-area {
    flex: 1;
    min-width: 0;
  }

  /* Content body: flex column for proper stacking */
  .content-body {
    flex: 1;
    min-height: 0;
  }

  /* Messages wrapper: fill available space, push input to bottom */
  .messages-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .messages-scroll {
    flex: 1;
    min-height: 0;
  }

  /* Message input: sticky at bottom, never pushed off screen */
  .message-input-wrapper {
    flex-shrink: 0;
    padding: 0 8px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    position: relative;
    z-index: 10;
    background: var(--bg-tertiary);
  }

  /* Formatting toolbar: single scrollable row on mobile */
  .formatting-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px 4px;
    gap: 1px;
  }

  .formatting-toolbar::-webkit-scrollbar {
    display: none;
  }

  /* Groups inline on mobile */
  .fmt-group {
    flex-shrink: 0;
  }

  /* No spacer on mobile — everything scrolls inline */
  .fmt-spacer {
    flex: 0;
    min-width: 4px;
  }

  /* Audio group: no left border on mobile, just spacing */
  .fmt-group-audio {
    border-left: none;
    padding-left: 2px;
    margin-left: 0;
  }

  /* Hide less-essential toolbar items on mobile to reduce clutter */
  .formatting-toolbar .fmt-codeblock-group,
  .formatting-toolbar .fmt-preview-btn {
    display: none;
  }

  .fmt-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .fmt-sep {
    margin: 0 1px;
    height: 16px;
  }

  /* Compose input: full-width, better tap target */
  .message-input-container {
    padding: 4px 6px;
  }

  .message-input {
    min-height: 40px;
  }

  /* Hamburger menu button visible — 44px touch target for mobile */
  .mobile-menu-btn {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  /* Hide topic on mobile to prevent header overflow */
  .channel-topic {
    display: none;
  }

  /* Header: compact layout, prevent wrapping */
  .channel-header {
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
    min-height: var(--header-height);
    padding: 0 6px;
    gap: 2px;
  }

  .channel-header-left {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .channel-header-right {
    flex-shrink: 0;
    gap: 0;
  }

  /* Hide less-critical header buttons on mobile */
  .channel-header-right #header-search-in-channel-btn,
  .channel-header-right .header-pin-btn {
    display: none;
  }

  /* Tool panel: fills content-area above persistent input on mobile */
  .content-area.tool-open .tool-panel {
    flex: 1;
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: auto;
  }

  .persistent-input {
    z-index: 160;
  }

  .tool-panel-header {
    min-height: 44px;
    padding: 6px 12px;
  }

  /* Search and pinned panels: full-width */
  .search-panel:not(.search-modal),
  .pinned-panel {
    width: 100vw;
  }

  /* Settings flyout (legacy): full-width on mobile if ever re-added */
  .settings-flyout {
    width: 100vw;
    max-width: 100vw;
  }

  /* Voice bar: prevent overflow, use full width positioning */
  .voice-bar {
    min-width: auto;
    left: 8px;
    right: 8px;
    transform: none;
    padding: 6px 12px;
    gap: 8px;
  }

  .voice-bar-room { max-width: 80px; }
  .voice-bar-time { display: none; }

  /* Voice controls bar: stack vertically on narrow screens */
  .voice-btn-row {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
  }

  .voice-pip {
    width: 200px;
    bottom: 56px;
    right: 8px;
  }

  /* Message images: viewport-relative, not fixed px */
  .message-image {
    max-width: 90%;
  }

  /* Message bubbles: proper max-width */
  .message-content {
    max-width: 90vw;
  }

  .message-content pre {
    max-width: calc(90vw - 80px);
    overflow-x: auto;
  }

  /* Modals: fit viewport */
  .modal-card {
    max-width: calc(100vw - 24px);
    margin: 12px;
  }

  /* Emoji picker: constrain to viewport */
  .emoji-picker-popup {
    width: calc(100vw - 16px);
    max-width: 340px;
  }

  /* Thread panel: full-width overlay (already set at 768px elsewhere, reinforce) */
  .thread-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    z-index: 200;
    border-left: none;
  }

  /* Login: fit within viewport without scrolling */
  .login-screen {
    padding: 16px;
    min-height: 100vh;
    height: auto;
    overflow-y: auto;
  }

  .login-card {
    max-height: none;
    padding: 28px 20px;
    margin: 0;
  }

  /* Channel switcher: full-width */
  .channel-categories-container {
    width: 100%;
  }

  /* Member list: slide-over from right on mobile */
  .member-list {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
  }

  .member-list.hidden {
    transform: translateX(100%);
    width: 280px;
    min-width: 280px;
    padding: 12px 8px;
    overflow: hidden;
    border: none;
  }

  .member-list.mobile-open {
    transform: translateX(0);
  }

  /* Custom status modal: fit mobile viewport */
  .custom-status-card {
    width: calc(100vw - 32px);
    max-width: 360px;
  }

  /* Schedule popover: fit viewport */
  .schedule-popover {
    left: 0;
    right: 0;
    width: auto;
    max-width: calc(100vw - 16px);
  }
}

/* Formatting toolbar: 44px touch target on coarse-pointer devices (ab49362e) */
@media (max-width: 768px) and (pointer: coarse) {
  .fmt-btn {
    width: 44px;
    height: 44px;
  }
}

/* ── Phone portrait: <=480px ───────────────────────── */
@media (max-width: 480px) {
  :root {
    --sidebar-width: 280px;
    --header-height: 44px;
  }

  body {
    font-size: 14px;
  }

  .login-card {
    padding: 24px 16px;
    margin: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }

  .login-logo h1 {
    font-size: 20px;
  }

  .login-logo {
    margin-bottom: 20px;
  }

  .channel-header {
    padding: 0 8px;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .channel-header-left {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .channel-header-right {
    flex-shrink: 0;
    gap: 2px;
  }

  /* Members toggle stays visible on all mobile sizes for slide-over panel */
  .channel-header-right #toggle-members-btn {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .channel-name {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .messages-container {
    padding: 0 10px 8px;
  }

  .message-input-wrapper {
    padding: 0 6px 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  /* ab49362e: removed 30px override — it defeated the 44px coarse-pointer rule above */

  /* Voice combo popover opens upward — ensure it stays visible on small screens */
  .voice-combo-popover {
    right: -4px;
    min-width: 180px;
  }

  .message {
    gap: 8px;
  }

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

  .message-avatar {
    width: 32px;
  }

  .message-reply-context {
    margin-left: 40px;
  }

  /* Message images: use viewport-relative max-width */
  .message-image {
    max-width: 90vw;
  }

  /* Message content: ensure proper wrapping */
  .message-content {
    max-width: 90vw;
    font-size: 14px;
  }

  .message-content pre {
    max-width: calc(90vw - 60px);
    overflow-x: auto;
  }

  /* 84aa8167: URLs have no natural break points -- force wrap at viewport edge */
  .message-content a {
    word-break: break-all;
  }

  .voice-bar {
    padding: 4px 8px;
    gap: 6px;
    min-width: auto;
  }

  .voice-bar-participants {
    display: none;
  }

  .voice-pip {
    width: 180px;
    right: 4px;
    bottom: 52px;
  }

  .settings-panel {
    max-width: 100vw;
  }

  /* Settings flyout: full-width on small phones */
  .settings-flyout {
    width: 100vw;
    max-width: 100vw;
  }

  .profile-popup-card {
    width: 95vw;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }

  /* Emoji picker: fit viewport */
  .emoji-picker-popup {
    width: calc(100vw - 16px);
    max-width: 340px;
    left: 8px !important;
    right: 8px !important;
  }

  /* Voice controls: stack vertically on narrow */
  .voice-btn-row {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Channel switcher full width */
  .channel-categories-container {
    width: 100%;
  }

  /* Thread panel input */
  .thread-panel-input-wrapper {
    padding: 8px;
  }

  .thread-panel-input-wrapper .message-input-container {
    padding: 4px 6px;
  }
}

/* ── Landscape phone ───────────────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar {
    bottom: 0;
  }

  .login-card {
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* ═══════════════════════════════════════════════════
   PRINT — Hide navigation/sidebar for clean output
   ═══════════════════════════════════════════════════ */

@media print {
  .sidebar,
  .user-panel,
  .sidebar-overlay,
  .sidebar-backdrop,
  .member-list-backdrop,
  .voice-bar,
  .voice-pip,
  .voice-controls,
  .voice-media-container,
  .channel-header,
  .member-list,
  .message-input-wrapper,
  .typing-indicator,
  .message-actions,
  .reaction-add-btn,
  .new-messages-btn,
  .connection-toast,
  .toast,
  .modal-overlay,
  .settings-overlay,
  .settings-flyout,
  .settings-flyout-backdrop,
  .search-panel,
  .pinned-panel,
  .context-menu,
  .profile-popup,
  .mobile-menu-btn,
  .forge-tools-section,
  .tool-panel-header {
    display: none !important;
  }

  body, html {
    height: auto;
    overflow: visible;
  }

  .app {
    display: block;
    height: auto;
    overflow: visible;
  }

  .main-content {
    overflow: visible;
  }

  .content-body {
    overflow: visible;
  }

  .messages-scroll {
    overflow: visible;
  }

  .messages-wrapper {
    overflow: visible;
  }

  .message {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  * {
    color: #000 !important;
    background: #fff !important;
    box-shadow: none !important;
    border-color: #ccc !important;
  }

  a {
    text-decoration: underline !important;
    color: #0066cc !important;
  }
}

/* ═══════════════════════════════════════════════════
   TOUCH-DEVICE TARGETS — Issues #21, #22, #10, #18
   Min 44px for all interactive elements on touch
   ═══════════════════════════════════════════════════ */

@media (pointer: coarse), (max-width: 768px) {
  /* #21 — Voice control buttons: 36px → 44px */
  .voice-ctrl-btn {
    width: 44px;
    height: 44px;
  }

  .voice-bar-btn {
    width: 44px;
    height: 44px;
  }

  #voice-bar-ptt-btn {
    min-height: 44px;
  }

  /* #22 — Icon buttons: 28px → 44px */
  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .icon-btn-sm {
    width: 36px;
    height: 36px;
  }

  .voice-pip-btn {
    width: 44px;
    height: 44px;
  }

  /* Generic interactive elements — min 44px touch targets */
  button:not(.fmt-btn):not(.emoji-tab):not(.status-custom-clear),
  [role="button"],
  .btn-secondary,
  .btn-primary,
  .btn-danger {
    min-height: 44px;
    min-width: 44px;
  }

  /* Formatting toolbar buttons: min floor (ab49362e 44px via coarse+768 block takes precedence) */
  .fmt-btn {
    min-height: 32px;
    min-width: 32px;
  }

  /* Navigation links */
  .sidebar-section-header,
  .channel-list a,
  .member-item,
  .forge-tool-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Input elements */
  input,
  textarea,
  select,
  .form-group input {
    min-height: 44px;
  }

  /* #10 — Modal min-width breaks on small phones */
  .modal-card {
    max-width: calc(100vw - 24px);
    margin: 12px;
  }
}

/* ═══════════════════════════════════════════════════
   SWIPE GESTURE — real-time sidebar tracking
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .sidebar.swiping {
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════
   UNREAD DOT INDICATOR (for channels with new activity)
   ═══════════════════════════════════════════════════ */

.channel-item .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-left: auto;
}

.dm-item .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-left: auto;
}

/* ═══════════════════════════════════════════════════
   CHANNEL DRAG REORDER
   ═══════════════════════════════════════════════════ */

.channel-item .drag-handle {
  cursor: grab;
  opacity: 0;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: opacity var(--transition-fast);
  margin-right: 2px;
  display: flex;
  align-items: center;
}

.channel-item:hover .drag-handle {
  opacity: 0.5;
}

.channel-item .drag-handle:hover {
  opacity: 1;
}

.channel-item .drag-handle:active {
  cursor: grabbing;
}

.channel-item.dragging {
  opacity: 0.4;
  background: var(--accent-dim);
}

.channel-item.drag-over {
  border-top: 2px solid var(--accent);
  margin-top: -2px;
}

/* ═══════════════════════════════════════════════════
   COMMAND PALETTE (Ctrl+K quick-switch)
   ═══════════════════════════════════════════════════ */

.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdPaletteIn 0.15s ease-out;
}

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

.command-palette-input {
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
}

.command-palette-input::placeholder {
  color: var(--text-muted);
}

.command-palette-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background var(--transition-fast);
}

.command-palette-item:hover,
.command-palette-item.selected {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.command-palette-item .cmd-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.6;
  font-size: 14px;
}

.command-palette-item.selected .cmd-icon {
  opacity: 1;
}

.command-palette-item .cmd-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-palette-item .cmd-hint {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.command-palette-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.command-palette-footer {
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.command-palette-footer kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
}

/* ═══════════════════════════════════════════════════
   SIDEBAR SECTION COLLAPSE ANIMATION
   ═══════════════════════════════════════════════════ */

.channel-list {
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  max-height: 2000px;
  opacity: 1;
}

.channel-list.section-collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding: 0 8px;
}

/* ═══════════════════════════════════════════════════════════
   UI POLISH — Emoji Picker, Code Blocks, Links, Timestamps
   ═══════════════════════════════════════════════════════════ */

/* ── Emoji Button (input bar) ─────────────────────────── */
.emoji-btn {
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

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

/* ── Emoji Picker Popup ───────────────────────────────── */
.emoji-picker-popup {
  position: fixed;
  z-index: 1100;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,0.4));
  width: 340px;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  animation: pickerFadeIn 0.15s ease-out;
}

.emoji-picker-popup[hidden] {
  display: none !important;
}

.emoji-picker-popup-header {
  padding: 8px 10px 4px;
  border-bottom: 1px solid var(--border);
}

.emoji-picker-tabs {
  display: flex;
  gap: 2px;
}

.emoji-tab {
  flex: 1;
  padding: 6px 4px;
  font-size: 18px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: center;
  line-height: 1;
}

.emoji-tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.emoji-tab.active {
  background: var(--accent-dim);
}

.emoji-picker-popup-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  max-height: 320px;
}

.emoji-grid-item {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), transform 0.1s ease;
  background: none;
  border: none;
  line-height: 1;
}

.emoji-grid-item:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.2);
}

/* ── Code Block Language Label ────────────────────────── */
.message-content pre.code-block {
  position: relative;
  padding-top: 28px;
}

.code-lang-label {
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 10px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-md);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}

/* Syntax highlighting — keyword coloring for common languages */
.message-content pre code {
  color: #d4d4d4;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-all;
}

.syn-kw  { color: #c586c0; font-weight: 600; }
.syn-str { color: #ce9178; }
.syn-num { color: #b5cea8; }
.syn-cmt { color: #6a9955; font-style: italic; }
.syn-fn  { color: #dcdcaa; }

/* ── Markdown Block Elements ─────────────────────────── */

.message-content blockquote {
  border-left: 3px solid var(--text-muted, #666);
  margin: 4px 0;
  padding: 2px 12px;
  color: var(--text-muted, #999);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0 var(--radius-sm, 3px) var(--radius-sm, 3px) 0;
}

.message-content blockquote + blockquote { margin-top: 0; }

.message-content h1.md-header,
.message-content h2.md-header,
.message-content h3.md-header,
.message-content h4.md-header,
.message-content h5.md-header,
.message-content h6.md-header {
  margin: 6px 0 2px;
  line-height: 1.3;
}
.message-content h1.md-header { font-size: 1.4em; }
.message-content h2.md-header { font-size: 1.25em; }
.message-content h3.md-header { font-size: 1.1em; }
.message-content h4.md-header,
.message-content h5.md-header,
.message-content h6.md-header { font-size: 1em; }

.message-content hr {
  border: none;
  border-top: 1px solid var(--border, #444);
  margin: 8px 0;
}

.message-content del {
  text-decoration: line-through;
  opacity: 0.65;
}

.message-content ul,
.message-content ol {
  margin: 4px 0;
  padding-left: 24px;
}

.message-content ul { list-style: disc; }
.message-content ol { list-style: decimal; }

.message-content li {
  margin: 1px 0;
  line-height: 1.45;
}

.message-content ul.md-task-list {
  list-style: none;
  padding-left: 4px;
}

.message-content .md-task-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.message-content .md-task-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted, #888);
  border-radius: 3px;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  top: 2px;
  cursor: default;
}

.message-content .md-task-item input[type="checkbox"]:checked {
  background: var(--accent, #7b68ee);
  border-color: var(--accent, #7b68ee);
}

.message-content .md-task-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 0;
  width: 5px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ── Markdown Tables ─────────────────────────────────── */

.message-content table.md-table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
  width: auto;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

.message-content table.md-table th,
.message-content table.md-table td {
  border: 1px solid var(--border, #444);
  padding: 4px 10px;
  text-align: left;
}

.message-content table.md-table th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

.message-content table.md-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Markdown Images ─────────────────────────────────── */

.message-content img.md-image {
  max-width: 100%;
  border-radius: var(--radius-md, 6px);
  margin: 4px 0;
  display: block;
}

/* ── Link Styling ─────────────────────────────────────── */
.message-content a.message-link {
  color: var(--text-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  word-break: break-all;
}

.message-content a.message-link:hover {
  border-bottom-color: var(--text-link);
  text-decoration: none;
}

.message-content a.message-link::after {
  content: ' \2197';
  font-size: 10px;
  opacity: 0.6;
  vertical-align: super;
}

/* ── Timestamp Tooltip Enhancement ────────────────────── */
.message-timestamp {
  cursor: default;
  position: relative;
}

.message-compact-time {
  cursor: default;
}

@keyframes newMsgBtnAppear {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Reaction Pills — enhanced hover state ────────────── */
.reaction {
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 0.1s ease;
}

.reaction:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.05);
}

.reaction.reaction-mine:hover {
  background: var(--accent-dim);
  filter: brightness(1.1);
}

/* ── Emoji Picker popup scrollbar styling ─────────────── */
.emoji-picker-popup-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-picker-popup-grid::-webkit-scrollbar-track {
  background: transparent;
}

.emoji-picker-popup-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.emoji-picker-popup-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ═══════════════════════════════════════════════════
   THREAD PANEL
   ═══════════════════════════════════════════════════ */

.thread-panel {
  width: 400px;
  min-width: 400px;
  max-width: 400px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal), min-width var(--transition-normal);
}

.thread-panel[hidden] {
  display: none !important;
}

.thread-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  height: var(--header-height);
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.thread-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.thread-panel-title svg {
  color: var(--text-muted);
}

.thread-panel-parent {
  padding: 16px;
  border-bottom: none;
  background: var(--bg-secondary);
  flex-shrink: 0;
  max-height: 40%;
  overflow-y: auto;
}

.thread-panel-parent .thread-parent-msg {
  display: flex;
  gap: 12px;
}

.thread-panel-parent .thread-parent-msg .avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.thread-panel-parent .thread-parent-body {
  flex: 1;
  min-width: 0;
}

.thread-panel-parent .thread-parent-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.thread-panel-parent .thread-parent-author {
  font-weight: 600;
  font-size: 14px;
}

.thread-panel-parent .thread-parent-time {
  font-size: 11px;
  color: var(--text-muted);
}

.thread-panel-parent .thread-parent-content {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.thread-panel-parent .thread-parent-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.thread-panel-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.thread-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.thread-panel-messages .thread-reply {
  display: flex;
  gap: 12px;
  padding: 6px 16px;
  transition: background var(--transition-fast);
}

.thread-panel-messages .thread-reply:hover {
  background: var(--bg-message-hover);
}

.thread-panel-messages .thread-reply .avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.thread-panel-messages .thread-reply-body {
  flex: 1;
  min-width: 0;
}

.thread-panel-messages .thread-reply-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.thread-panel-messages .thread-reply-author {
  font-weight: 600;
  font-size: 13px;
}

.thread-panel-messages .thread-reply-time {
  font-size: 11px;
  color: var(--text-muted);
}

.thread-panel-messages .thread-reply-content {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.thread-panel-messages .thread-reply-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.thread-panel-messages .thread-reply-new-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

.thread-panel-input-wrapper {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.thread-panel-input-wrapper .message-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  border: 1px solid var(--border);
}

.thread-panel-input-wrapper .message-input-container:focus-within {
  border-color: var(--accent);
}

.thread-panel-input-wrapper .message-input {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  padding: 8px 4px;
  min-height: 20px;
  max-height: 120px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
}

/* ── Thread reply indicator on main messages ──────── */

.message-thread-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 2px 0;
  font-size: 12px;
  cursor: pointer;
  color: var(--accent);
  transition: color var(--transition-fast);
  margin-left: 0;
}

.message-thread-indicator:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.message-thread-indicator svg {
  flex-shrink: 0;
}

.message-thread-indicator .thread-new-badge {
  display: inline-block;
  background: var(--error);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── Thread panel responsive ─────────────────────── */

@media (max-width: 768px) {
  .thread-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    z-index: 200;
    border-left: none;
  }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .thread-panel {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
  }
}

/* ═══════════════════════════════════════════════════════════
   CHANNEL CATEGORIES
   ═══════════════════════════════════════════════════════════ */

.channel-categories-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Category reassignment dropdown (admin only) */
.channel-category-dropdown {
  display: none;
  margin-left: auto;
  padding: 1px 4px;
  font-size: 10px;
  background: var(--bg-tertiary, var(--bg-secondary));
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  max-width: 90px;
  flex-shrink: 0;
}

.channel-item:hover .channel-category-dropdown {
  display: inline-block;
}

.channel-category-dropdown:focus {
  outline: 1px solid var(--accent);
}

/* Category Manager Modal */
.category-manager-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
}

.category-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.category-manager-item:last-child {
  border-bottom: none;
}

.category-manager-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.category-manager-actions {
  display: flex;
  gap: 6px;
}

.category-manager-add {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.category-manager-add .form-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.category-manager-add .form-input:focus {
  border-color: var(--accent);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  font-weight: 600;
}

.btn-sm.btn-secondary {
  background: var(--bg-tertiary, var(--bg-secondary));
  color: var(--text-secondary);
}

.btn-sm.btn-secondary:hover {
  background: var(--border);
}

.btn-sm.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-sm.btn-danger:hover {
  opacity: 0.85;
}

/* Form select (for category dropdown in create channel modal) */
.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

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

/* ─── Scheduled Messages ─── */

.schedule-btn {
  color: var(--text-muted);
  transition: color 0.15s;
}
.schedule-btn:hover {
  color: var(--accent);
}

.schedule-popover {
  position: absolute;
  bottom: 100%;
  right: 8px;
  width: 300px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  margin-bottom: 8px;
}

.schedule-popover-header {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.schedule-presets {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.schedule-preset-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.schedule-preset-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.schedule-custom {
  margin-bottom: 12px;
}
.schedule-custom label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.schedule-datetime-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  color-scheme: dark;
}
.schedule-datetime-input:focus {
  border-color: var(--accent);
}

.schedule-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.schedule-actions .btn-secondary {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
}
.schedule-actions .btn-secondary:hover {
  background: var(--bg-hover);
}
.schedule-actions .btn-primary {
  padding: 6px 14px;
  font-size: 13px;
}

.schedule-pending-link {
  margin-top: 10px;
  text-align: center;
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
}
.btn-link:hover {
  opacity: 0.8;
}

/* Scheduled messages panel */
.scheduled-messages-panel {
  position: absolute;
  bottom: 100%;
  right: 8px;
  width: 380px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
}

.scheduled-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.scheduled-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.scheduled-messages-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}

.scheduled-msg-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.scheduled-msg-card:last-child {
  margin-bottom: 0;
}

.scheduled-msg-channel {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.scheduled-msg-content {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 6px;
  word-break: break-word;
  white-space: pre-wrap;
}

.scheduled-msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.scheduled-msg-actions {
  display: flex;
  gap: 6px;
}
.scheduled-msg-actions button {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.scheduled-msg-actions button:hover {
  background: var(--bg-hover);
}
.scheduled-msg-actions .cancel-btn {
  color: var(--error);
  border-color: var(--error);
}
.scheduled-msg-actions .cancel-btn:hover {
  background: rgba(255,0,0,0.1);
}

/* Clock icon on messages that were scheduled */
.message-scheduled-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  margin-left: 6px;
  vertical-align: middle;
}
.message-scheduled-indicator svg {
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════
   KEYBOARD SHORTCUTS OVERLAY
   ═══════════════════════════════════════════════════ */

.shortcuts-modal {
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.shortcuts-modal .modal-header {
  flex-shrink: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.shortcuts-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shortcuts-vim-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.shortcuts-vim-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.shortcuts-body {
  overflow-y: auto;
  padding: 16px 0 8px;
  flex: 1;
  min-height: 0;
}

.shortcuts-category {
  margin-bottom: 20px;
}

.shortcuts-category:last-child {
  margin-bottom: 0;
}

.shortcuts-category-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 2px;
}

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

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.1s;
}

.shortcut-row:hover {
  background: var(--bg-hover);
}

.shortcut-label {
  font-size: 13px;
  color: var(--text-primary);
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.shortcut-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
  line-height: 1;
}

.shortcut-keys .kbd-plus {
  font-size: 10px;
  color: var(--text-muted);
  margin: 0 1px;
}

/* Vim mode category — hidden by default */
.shortcuts-category-vim {
  display: none;
}
.shortcuts-category-vim.active {
  display: block;
}

/* ── Customize panel ──────────────────────── */

.shortcuts-customize-panel {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

.shortcuts-customize-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.shortcuts-customize-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.shortcuts-customize-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.shortcut-customize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
}

.shortcut-customize-label {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}

.shortcut-capture-btn {
  min-width: 120px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.shortcut-capture-btn:hover {
  border-color: var(--accent);
}

.shortcut-capture-btn.capturing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
  color: var(--accent);
}

.shortcuts-customize-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Floating ? button ────────────────────── */

.shortcuts-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.shortcuts-fab:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.08);
}

/* Hide FAB on login screen */
.login-screen:not([hidden]) ~ .shortcuts-fab {
  display: none;
}

@media (max-width: 768px) {
  .shortcuts-modal {
    max-width: calc(100vw - 32px);
    max-height: 85vh;
  }
  .shortcut-row {
    flex-wrap: wrap;
    gap: 4px;
  }
  .shortcuts-fab {
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}


/* ═══════════════════════════════════════════════════
   TRANSLATION
   ═══════════════════════════════════════════════════ */

/* ── Translate dropdown (language picker) ────────── */
.translate-dropdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  max-height: 360px;
  overflow-y: auto;
  animation: translate-dropdown-in 120ms ease-out;
}

@keyframes translate-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.translate-dropdown-header {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.translate-dropdown-list {
  display: flex;
  flex-direction: column;
  padding: 4px;
}

.translate-lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  text-align: left;
  width: 100%;
}

.translate-lang-option:hover {
  background: var(--bg-hover);
}

.translate-lang-option.default-lang {
  background: var(--accent-dim);
}

.translate-lang-flag {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.translate-lang-name {
  flex: 1;
}

.translate-lang-default-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

/* ── Translation result block (below message) ───── */
.message-translation {
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(83, 168, 182, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  line-height: 1.45;
  animation: translation-in 200ms ease-out;
}

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

.message-translation.loading {
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border-left-color: var(--text-muted);
}

.message-translation.error {
  color: var(--error);
  font-style: italic;
  border-left-color: var(--error);
  background: rgba(240, 71, 71, 0.06);
}

.translation-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.translation-label svg {
  opacity: 0.6;
  flex-shrink: 0;
}

.translation-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 2px;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.translation-dismiss:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.translation-text {
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Translate spinner ───────────────────────────── */
.translate-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: translate-spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes translate-spin {
  to { transform: rotate(360deg); }
}

/* ── Language indicator badge on message header ──── */
.lang-indicator {
  font-size: 13px;
  margin-left: 6px;
  cursor: default;
  vertical-align: middle;
  opacity: 0.75;
  transition: opacity var(--transition-fast);
}

.lang-indicator:hover {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════
   INLINE IMAGE WRAPPER & LOADING PLACEHOLDER
   ═══════════════════════════════════════════════════ */

.inline-image-wrapper {
  position: relative;
  display: inline-block;
  margin: 6px 0;
  max-width: 400px;
  max-height: 300px;
  line-height: 0;
}

.inline-image-wrapper .message-image {
  max-width: 400px;
  max-height: 300px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition-fast);
  object-fit: contain;
  display: block;
}

.inline-image-wrapper .message-image:hover {
  opacity: 0.85;
}

.image-loading-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-width: 120px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
}

.image-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: img-spin 0.7s linear infinite;
}

@keyframes img-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════
   IMAGE LIGHTBOX
   ═══════════════════════════════════════════════════ */

.image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-lightbox.active {
  opacity: 1;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

/* Close X button — top right */
.lightbox-close-x {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lightbox-close-x:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Navigation arrows */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.lightbox-nav-prev { left: 16px; }
.lightbox-nav-next { right: 16px; }

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 80vh;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.lightbox-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 13px;
  z-index: 2;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
  transition: opacity 0.15s ease;
  transform-origin: center center;
  user-select: none;
}

/* Info bar — filename, sender, counter */
.lightbox-info-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #ccc;
  white-space: nowrap;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-info-filename {
  font-weight: 600;
  color: #eee;
}

.lightbox-info-sender {
  color: #999;
  font-size: 12px;
}

.lightbox-info-counter {
  color: #999;
  font-size: 12px;
  margin-left: auto;
}

.lightbox-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-md);
}

.lightbox-zoom-label {
  font-size: 12px;
  color: #999;
  min-width: 36px;
  text-align: center;
  user-select: none;
}

.lightbox-toolbar-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

.lightbox-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: #ccc;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  background: none;
  border: none;
  text-decoration: none;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ═══════════════════════════════════════════════════
   VIDEO PLAYER WRAPPER
   ═══════════════════════════════════════════════════ */

.video-player-wrapper {
  position: relative;
  display: inline-block;
  max-width: min(480px, 90vw);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  cursor: pointer;
}

.video-player-wrapper .message-video {
  display: block;
  max-width: min(480px, 90vw);
  max-height: 360px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════
   MEDIA EMBEDS (YouTube, Vimeo)
   ═══════════════════════════════════════════════════ */

.message-embed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
  max-width: min(480px, 90vw);
}

.message-embed-iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #000;
}

.message-embed-link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.message-embed-link:hover {
  color: var(--text-link);
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════
   AUDIO PLAYER
   ═══════════════════════════════════════════════════ */

.attachment-audio {
  max-width: 380px;
}

.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 260px;
}

.audio-player.playing .audio-play-btn {
  color: var(--accent);
}

.audio-play-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.audio-play-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent);
}

.audio-waveform-container {
  flex: 1;
  position: relative;
  height: 36px;
  min-width: 100px;
}

.audio-waveform {
  display: block;
  width: 100%;
  height: 36px;
  border-radius: 4px;
}

.audio-scrubber {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

.audio-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 70px;
  text-align: right;
}

/* ═══════════════════════════════════════════════════
   FILE DOWNLOAD CARDS
   ═══════════════════════════════════════════════════ */

.file-download-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 360px;
  transition: background var(--transition-fast);
}

.file-download-card:hover {
  background: rgba(255, 255, 255, 0.07);
}

.file-card-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.file-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-link);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-name:hover {
  text-decoration: underline;
}

.file-card-ext {
  font-size: 11px;
  color: var(--text-muted);
}

.file-card-download {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.file-card-download:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   MESSAGE ACTION BUTTON — PIN & DELETE STYLING
   ═══════════════════════════════════════════════════ */

.message-action-btn.pin-btn {
  color: var(--text-muted);
}

.message-action-btn.delete-btn {
  color: var(--text-muted);
}

.message-action-btn.delete-btn:hover {
  color: var(--error);
  background: rgba(240, 71, 71, 0.12);
}

/* ═══════════════════════════════════════════════════
   MOBILE: LONG-PRESS AFFORDANCE & RESPONSIVE IMAGES
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .inline-image-wrapper .message-image {
    max-width: 90vw;
    max-height: 250px;
  }

  .inline-image-wrapper {
    max-width: 90vw;
  }

  .file-download-card {
    max-width: calc(100vw - 80px);
  }

  .lightbox-image {
    max-width: 95vw;
    max-height: calc(90vh - 100px);
  }

  .lightbox-nav {
    width: 36px;
    height: 36px;
  }

  .lightbox-nav-prev { left: 8px; }
  .lightbox-nav-next { right: 8px; }

  .lightbox-close-x {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
  }

  .lightbox-info-bar {
    top: 8px;
    font-size: 11px;
    padding: 4px 10px;
    max-width: 60vw;
  }

  .audio-player {
    min-width: 200px;
  }

  .audio-time {
    font-size: 10px;
    min-width: 58px;
  }

  .video-player-wrapper .message-video {
    max-width: 90vw;
  }

  .message-embed {
    max-width: 90vw;
  }
}

/* ═══════════════════════════════════════════════════
   MOBILE UX — Keyboard, Safe Areas, PWA, Gestures
   ═══════════════════════════════════════════════════ */

/* ── Safe area insets for notched devices ─────────── */
html {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ── PWA standalone display mode ──────────────────── */
@media (display-mode: standalone) {
  .login-screen {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  .channel-header {
    padding-top: env(safe-area-inset-top);
    min-height: calc(var(--header-height) + env(safe-area-inset-top));
  }

  .sidebar {
    padding-top: env(safe-area-inset-top);
  }

  .message-input-wrapper {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* ── Mobile keyboard handling (JS sets --keyboard-height) ─ */
.app.keyboard-open .messages-scroll {
  /* scroll-behavior: smooth; -- disabled: breaks programmatic scrollToBottom */
}

.app.keyboard-open .message-input-wrapper {
  transition: transform 0.15s ease-out;
}

/* ── Mobile message input: 16px prevents iOS auto-zoom ──── */
@media (max-width: 768px) {
  .message-input {
    font-size: 16px;
    line-height: 1.4;
    max-height: 72px; /* ~3 lines at 16px * 1.4 + padding */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .messages-scroll {
    -webkit-overflow-scrolling: touch;
    /* scroll-behavior: smooth; -- disabled: breaks programmatic scrollToBottom */
    overscroll-behavior-y: contain;
  }
}

/* ── Pull-to-refresh indicator ────────────────────── */
.pull-to-refresh-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
  color: var(--text-muted);
  font-size: 13px;
}

.pull-to-refresh-indicator.active {
  max-height: 48px;
  padding: 12px 0;
  opacity: 1;
}

.pull-to-refresh-indicator.refreshing .ptr-spinner {
  animation: ptrSpin 0.8s linear infinite;
}

.pull-to-refresh-indicator.refreshing .ptr-text {
  display: none;
}

.pull-to-refresh-indicator.refreshing::after {
  content: 'Loading...';
  font-size: 13px;
}

.ptr-spinner {
  transition: transform 0.2s ease;
}

@keyframes ptrSpin {
  to { transform: rotate(360deg); }
}

/* ── Swipe-to-reply indicator on messages ─────────── */
.message {
  position: relative;
  overflow: visible;
}

.message .swipe-reply-indicator {
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  color: var(--accent);
}

.message.swiping .swipe-reply-indicator {
  opacity: 1;
}

/* ── Long-press visual feedback ───────────────────── */
.message.long-press-active {
  background: var(--bg-hover) !important;
  transition: background 0.2s ease;
}

/* ── Double-tap react flash ───────────────────────── */
.message.double-tap-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  opacity: 0;
  animation: doubleTapFlash 0.4s ease-out;
  pointer-events: none;
}

@keyframes doubleTapFlash {
  0% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* ── Context menu mobile: bottom sheet style ──────── */
@media (max-width: 768px) {
  .context-menu.mobile-sheet {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100%;
    min-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheetSlideUp 0.2s ease-out;
  }

  .context-menu.mobile-sheet .context-menu-item {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 48px;
  }

  .context-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    animation: fadeIn 0.15s ease-out;
  }
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

/* ═══════════════════════════════════════════════════
   Tool Page Header — Unified Navigation Bar
   Used by all standalone pages (not index.html)
   ═══════════════════════════════════════════════════ */

.tool-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 20px;
  background: var(--bg-surface, #16213e);
  border-bottom: 1px solid var(--border, #1e3054);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  font-family: var(--font-main, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.tool-page-header .tool-page-nav-link {
  color: var(--text-secondary, #8e9aaf);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  transition: color 150ms ease;
}

.tool-page-header .tool-page-nav-link:hover {
  color: var(--accent, #53a8b6);
  text-decoration: none;
}

.tool-page-header .tool-page-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent, #53a8b6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-page-header .tool-page-spacer {
  flex: 1;
}

.tool-page-header .tool-page-user {
  font-size: 12px;
  color: var(--text-secondary, #8e9aaf);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.tool-page-header .tool-page-logout {
  background: none;
  border: 1px solid var(--border, #1e3054);
  color: var(--text-secondary, #8e9aaf);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}

.tool-page-header .tool-page-logout:hover {
  color: var(--error, #f04747);
  border-color: var(--error, #f04747);
}

/* Hamburger toggle — hidden on desktop */
.tool-page-header .tool-page-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary, #e8e8e8);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* Right-side group for user + logout */
.tool-page-header .tool-page-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Responsive: stack on mobile ─────────────────── */
@media (max-width: 600px) {
  .tool-page-header {
    flex-wrap: wrap;
    height: auto;
    min-height: 48px;
    padding: 8px 12px;
    gap: 6px;
  }

  .tool-page-header .tool-page-hamburger {
    display: inline-block;
    order: -1;
  }

  .tool-page-header .tool-page-title {
    font-size: 14px;
    flex: 1;
    min-width: 0;
  }

  .tool-page-header .tool-page-right {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border, #1e3054);
  }

  .tool-page-header .tool-page-nav-link {
    display: none;
  }

  /* When hamburger is toggled open */
  .tool-page-header.mobile-open .tool-page-right {
    display: flex;
  }

  .tool-page-header.mobile-open .tool-page-nav-link {
    display: inline-block;
  }
}

/* ── Print: hide translation UI ──────────────────── */
@media print {
  .translate-dropdown,
  .message-translation,
  .lang-indicator,
  .translate-btn,
  .image-lightbox,
  .message-actions {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════
   TTS / STT / Handsfree Mode
   ═══════════════════════════════════════════════════ */

/* ── STT Microphone Button ──────────────────────── */
.stt-mic-btn {
  position: relative;
}
.stt-mic-btn.recording {
  color: var(--error) !important;
  animation: stt-pulse 1.2s ease-in-out infinite;
}
.stt-recording-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  animation: stt-dot-pulse 1s ease-in-out infinite;
}
@keyframes stt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes stt-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ── Voice Message Button ─────────────────────── */
.voice-msg-btn {
  position: relative;
}
.voice-msg-btn.recording {
  color: var(--warning) !important;
  animation: stt-pulse 1.2s ease-in-out infinite;
}
.voice-msg-recording-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: stt-dot-pulse 1s ease-in-out infinite;
}

/* ── TTS Play Button on Messages ────────────────── */
.tts-play-btn {
  position: relative;
}
.tts-play-btn.playing {
  color: var(--accent) !important;
  animation: tts-playing-pulse 1s ease-in-out infinite;
}
@keyframes tts-playing-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Member Count Badge (on toggle-members button) ── */
.member-count-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  pointer-events: none;
}

/* ── TTS Toggle Button ──────────────────────────── */
.tts-toggle-btn {
  position: relative;
}
.tts-toggle-btn.active {
  color: var(--accent) !important;
  background: rgba(88, 101, 242, 0.15);
  border-radius: var(--radius-sm);
}

/* ── Handsfree Toggle Button ────────────────────── */
.handsfree-toggle-btn {
  position: relative;
}
.handsfree-toggle-btn.active {
  color: var(--success) !important;
  background: rgba(67, 181, 129, 0.15);
  border-radius: var(--radius-sm);
}
.handsfree-indicator {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: handsfree-pulse 2s ease-in-out infinite;
}
@keyframes handsfree-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ── Combined Voice Button + Popover ───────────────── */
.voice-combo-wrapper {
  position: relative;
}
.voice-combo-btn {
  position: relative;
}
.voice-combo-btn.has-active {
  color: var(--accent) !important;
}
.voice-combo-btn.recording {
  color: var(--error) !important;
  animation: stt-pulse 1.2s ease-in-out infinite;
}
.voice-combo-active-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
}
.voice-combo-active-dot.recording {
  background: var(--error);
  animation: stt-dot-pulse 1s ease-in-out infinite;
}
.voice-combo-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-secondary, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  padding: 4px;
  z-index: 100;
  animation: voice-popover-in 0.12s ease-out;
}
.voice-combo-popover[hidden] {
  display: none !important;
}
@keyframes voice-popover-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.voice-combo-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  color: var(--text-primary, var(--fg));
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background 0.1s;
  text-align: left;
  white-space: nowrap;
}
.voice-combo-option:hover {
  background: var(--bg-hover, rgba(255,255,255,0.06));
}
.voice-combo-option.active {
  background: rgba(88, 101, 242, 0.12);
}
.voice-combo-option.active .voice-combo-option-icon {
  color: var(--accent);
}
.voice-combo-option.active[data-voice-mode="handsfree"] .voice-combo-option-icon {
  color: var(--success);
}
.voice-combo-option.recording {
  background: rgba(237, 66, 69, 0.12);
}
.voice-combo-option.recording .voice-combo-option-icon {
  color: var(--error);
  animation: stt-pulse 1.2s ease-in-out infinite;
}
.voice-combo-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted, var(--muted));
}
.voice-combo-option-label {
  flex: 1;
}
.voice-combo-option-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.voice-combo-option-status.on {
  color: var(--accent);
}
.voice-combo-option-status.recording-label {
  color: var(--error);
}
.voice-combo-option-status.handsfree-on {
  color: var(--success);
}
.voice-combo-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* ── Handsfree Status Bar (Conversational Voice Mode) ── */
.handsfree-bar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px;
  background: rgba(67, 181, 129, 0.08);
  border-bottom: 2px solid rgba(67, 181, 129, 0.3);
  font-size: 12px;
  color: var(--success);
}
.hf-bar-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.handsfree-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: handsfree-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.hf-bar-title {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.hf-bar-state {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}
.hf-bar-state-listening {
  background: rgba(67, 181, 129, 0.2);
  color: var(--success);
}
.hf-bar-state-processing {
  background: rgba(250, 176, 5, 0.2);
  color: var(--warning);
  animation: hf-processing-pulse 1s ease-in-out infinite;
}
.hf-bar-state-speaking {
  background: rgba(88, 101, 242, 0.2);
  color: var(--accent);
  animation: hf-speaking-pulse 0.8s ease-in-out infinite;
}
.hf-bar-state-idle {
  background: rgba(185, 187, 190, 0.2);
  color: var(--text-muted);
}
@keyframes hf-processing-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes hf-speaking-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
/* ── Mic Level Bar ───────────────────────────────── */
.hf-level-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.hf-level-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.05s linear;
}
.hf-bar-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 16px;
}
.hf-bar-hint strong {
  color: var(--text-secondary);
}
.handsfree-bar-stop {
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
.handsfree-bar-stop:hover {
  background: var(--error);
  color: #fff;
}

/* ── Handsfree Active: Glowing border on chat area ── */
.handsfree-active .channel-content {
  box-shadow: inset 0 0 0 2px rgba(67, 181, 129, 0.3);
  transition: box-shadow 0.3s ease;
}
.handsfree-active.hf-state-listening .channel-content {
  box-shadow: inset 0 0 0 2px rgba(67, 181, 129, 0.4), 0 0 15px rgba(67, 181, 129, 0.1);
  animation: hf-glow-listening 2s ease-in-out infinite;
}
.handsfree-active.hf-state-processing .channel-content {
  box-shadow: inset 0 0 0 2px rgba(250, 176, 5, 0.4), 0 0 15px rgba(250, 176, 5, 0.1);
}
.handsfree-active.hf-state-speaking .channel-content {
  box-shadow: inset 0 0 0 2px rgba(88, 101, 242, 0.4), 0 0 15px rgba(88, 101, 242, 0.1);
  animation: hf-glow-speaking 1s ease-in-out infinite;
}
@keyframes hf-glow-listening {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(67, 181, 129, 0.3), 0 0 10px rgba(67, 181, 129, 0.05); }
  50% { box-shadow: inset 0 0 0 2px rgba(67, 181, 129, 0.5), 0 0 20px rgba(67, 181, 129, 0.15); }
}
@keyframes hf-glow-speaking {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(88, 101, 242, 0.3), 0 0 10px rgba(88, 101, 242, 0.05); }
  50% { box-shadow: inset 0 0 0 2px rgba(88, 101, 242, 0.5), 0 0 20px rgba(88, 101, 242, 0.15); }
}

/* ── TTS Queue Indicator ────────────────────────── */
.tts-queue-badge {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
  box-shadow: var(--shadow-md);
  transition: opacity var(--transition-normal);
}
.tts-queue-badge svg {
  flex-shrink: 0;
}
.tts-queue-stop {
  background: none;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 10px;
  cursor: pointer;
  margin-left: 4px;
}
.tts-queue-stop:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ── STT Live Transcription Indicator ───────────── */
.stt-live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(240, 71, 71, 0.08);
  border-top: 1px solid rgba(240, 71, 71, 0.15);
  font-size: 11px;
  color: var(--error);
}
.stt-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--error);
  animation: stt-dot-pulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
.stt-live-label {
  opacity: 0.7;
}

/* ── Whisper Recording Bar ─────────────────────── */
.whisper-recording-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(237, 66, 69, 0.1);
  border: 1px solid rgba(237, 66, 69, 0.3);
  border-radius: var(--radius-md, 8px);
  margin-bottom: 4px;
  animation: whisper-bar-fade-in 0.2s ease;
}
@keyframes whisper-bar-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.whisper-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error, #ed4245);
  animation: stt-dot-pulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
.whisper-rec-label {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}
.whisper-rec-timer {
  font-size: 13px;
  color: var(--error, #ed4245);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}
.whisper-rec-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Voice Message Display ─────────────────────── */
.attachment-audio.voice-message {
  background: rgba(88, 101, 242, 0.08);
  border: 1px solid rgba(88, 101, 242, 0.15);
  border-radius: var(--radius-md, 8px);
  padding: 8px 10px;
}
.voice-message-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent, #5865f2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.voice-message-header svg {
  opacity: 0.7;
}
.voice-message-transcription {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--accent, #5865f2);
  border-radius: 2px;
  line-height: 1.4;
  font-style: italic;
}

/* ── Wake Word Listening Badge ──────────────────── */
.wake-word-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  margin-left: 4px;
}
.wake-word-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--warning);
  animation: stt-dot-pulse 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════
   DISPLAY SETTINGS — applied via body classes from JS
   ═══════════════════════════════════════════════════════ */

/* ── Compact Mode ──────────────────────────────────── */
body.compact-mode .message {
  padding: 1px 0;
  margin-top: 0;
  gap: 8px;
}
body.compact-mode .message-avatar .avatar-circle {
  width: 28px;
  height: 28px;
  font-size: 11px;
}
body.compact-mode .message-content {
  gap: 1px;
}
body.compact-mode .channel-item {
  padding: 4px 10px;
}
body.compact-mode .member-item {
  padding: 4px 8px;
}

/* ── Reduced Motion ────────────────────────────────── */
body.reduced-motion,
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* ═══════════════════════════════════════════════════
   Welcome / Onboarding Overlay
   ═══════════════════════════════════════════════════ */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  animation: welcomeFadeIn 0.3s ease;
}

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

.welcome-card {
  position: relative;
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 40px 36px 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: welcomeSlideUp 0.35s ease;
}

@keyframes welcomeSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-skip {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.welcome-skip:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.welcome-logo {
  text-align: center;
  margin-bottom: 16px;
}

.welcome-step h2 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.welcome-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 24px;
}

/* Feature cards */
.welcome-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.welcome-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}
.welcome-feature:hover {
  border-color: var(--accent);
}

.welcome-feature-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 8px;
}

.welcome-feature div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.welcome-feature strong {
  color: var(--text-primary);
  font-size: 0.95rem;
}
.welcome-feature span {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Theme grid */
.welcome-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding: 2px;
}

.welcome-theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  background: var(--bg-primary);
}
.welcome-theme-swatch:hover {
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}
.welcome-theme-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.welcome-theme-colors {
  display: flex;
  gap: 4px;
}
.welcome-theme-colors span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
}

.welcome-theme-swatch label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  pointer-events: none;
  line-height: 1.2;
}

/* Ready step */
.welcome-ready-icon {
  text-align: center;
  font-size: 48px;
  margin-bottom: 12px;
}

.welcome-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.welcome-tip {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.88rem;
}
.welcome-tip kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 0.78rem;
  font-family: var(--font-mono, monospace);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
}

/* Navigation */
.welcome-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.welcome-dots {
  display: flex;
  gap: 8px;
}

.welcome-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  transition: background 0.2s, transform 0.2s;
}
.welcome-dot.active {
  background: var(--accent);
  transform: scale(1.25);
}

.welcome-buttons {
  display: flex;
  gap: 8px;
}

/* Responsive */
@media (max-width: 540px) {
  .welcome-card {
    padding: 28px 20px 20px;
  }
  .welcome-theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ═══════════════════════════════════════════════════
   KLAUS FIX: Mobile portrait mode — sidebar access,
   button overflow, voice combo visibility
   ═══════════════════════════════════════════════════ */

/* ── Portrait: voice combo always visible ─────────── */
@media (max-width: 768px) and (orientation: portrait) {
  /* Pull voice combo out of scroll flow, pin to right of toolbar */




  /* Input actions: ensure buttons don't overflow */
  .input-actions-right {
    flex-shrink: 0;
    gap: 2px;
  }

  .input-actions-right .icon-btn {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
  }

  .input-actions-left .icon-btn {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
  }

  /* Message input container: prevent overflow */
  .message-input-container {
    flex-wrap: nowrap;
    overflow: hidden;
  }

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

/* ── Member list mobile-open state ──────────────── */
@media (max-width: 768px) {
  .member-list.mobile-open {
    transform: translateX(0) !important;
  }

  /* When member list is open but also has hidden class toggled off, show it */
  .member-list:not(.hidden).mobile-open {
    display: flex !important;
    transform: translateX(0) !important;
  }
}

/* Per-channel voice join button in sidebar */
.channel-voice-join-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
  margin-left: auto;
  border-radius: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.channel-item:hover .channel-voice-join-btn {
  opacity: 1;
}
.channel-voice-join-btn:hover {
  color: var(--success, #3ba55c);
  background: var(--bg-modifier-hover, rgba(79,84,92,0.16));
}
.channel-voice-join-btn:active {
  transform: scale(0.9);
}

/* =======================================================
   CHAT TOOLS PANEL -- fixed bottom-right (mirrors left Tools panel)
   ======================================================= */

/* Chat tools panel: popup above input (inside message-input-wrapper) */
.chat-tools-panel {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatToolsSlideIn 0.2s ease-out;
}

.chat-tools-panel[hidden] {
  display: none !important;
}

.chat-tools-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.chat-tools-panel-header .icon-btn {
  width: 24px;
  height: 24px;
  padding: 3px;
}

.chat-tools-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Formatting toolbar inside the fixed panel: wrapped flex layout */
.chat-tools-panel .formatting-toolbar {
  border: none;
  border-radius: 0;
  flex-wrap: wrap;
  padding: 10px 12px;
  gap: 6px;
  overflow-y: auto;
}

/* The message-input-wrapper still needs position:relative */
.message-input-wrapper {
  position: relative;
}



/* Toggle button styling */
.chat-tools-toggle-btn {
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.chat-tools-toggle-btn:hover {
  color: var(--accent);
}

.chat-tools-toggle-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
}

@keyframes chatToolsSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Mobile: chat tools panel adjustments */
@media (max-width: 768px) {
  .chat-tools-panel {
    max-height: 50vh;
  }
}

/* ═══════════════════════════════════════════════════
   Chat Options: pinned to bottom of right sidebar
   (mirrors left sidebar Tools pattern: flex column,
    scrollable content above, fixed section below)
   ═══════════════════════════════════════════════════ */
.member-list {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.member-list-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  min-height: 0;
}

#chat-options-section {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 8px;
  margin-top: 0 !important;
  background: var(--bg-secondary);
  overflow-y: auto;
}

/* When chat-options has been resized by drag, use fixed height */
#chat-options-section.resized {
  flex: none;
}

/* Chat Options resize handle (horizontal, mirrors forge-tools-resize-handle) */
.chat-options-resize-handle {
  height: 4px;
  cursor: row-resize;
  flex-shrink: 0;
  background: transparent;
  transition: background 0.15s ease;
}

.chat-options-resize-handle:hover,
.chat-options-resize-handle.dragging {
  background: var(--border);
}

/* ── Persistent input responsive width ─────────────────── */
/* When member list is visible, shrink input to not overlap */
.persistent-input {
  transition: margin-right 200ms ease;
}

.persistent-input.members-visible {
  margin-right: var(--member-list-width);
}

/* When member list is hidden (collapsed), input takes full width */
.persistent-input:not(.members-visible) {
  margin-right: 0;
}



/* ── Member Panel Collapse Toggle ──────────────────── */
.member-list-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  min-width: 20px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  z-index: 5;
}
.member-list-toggle:hover {
  color: var(--text-primary);
  background: var(--surface-hover, var(--bg-tertiary));
}
.member-list-toggle svg {
  transition: transform 0.2s ease;
}
.member-list-toggle.collapsed svg {
  transform: rotate(180deg);
}

/* Hide member panel toggle strip on mobile — header button handles it */
@media (max-width: 768px) {
  .member-list-toggle {
    display: none;
  }
}

/* ── Health Status Bar ──────────────────────────── */
.health-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  overflow: visible;
  min-height: 26px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9998;
}
.health-bar.collapsed {
  min-height: 0;
  height: 0;
  padding: 0;
  border-top: none;
  overflow: hidden;
}
.health-bar.collapsed .health-dot {
  display: none;
}
/* Push page content above the fixed health bar */
body:has(.health-bar:not(.collapsed)) .app,
body:has(.health-bar:not(.collapsed)) #app {
  padding-bottom: 28px;
}
.health-bar-toggle {
  position: fixed;
  bottom: 10px;
  right: 14px;
  z-index: 9999;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: box-shadow 0.3s ease, transform 0.15s ease;
}
.health-bar-toggle:hover { transform: scale(1.1); }
.health-bar-toggle.all-ok {
  color: #43b581;
  border-color: rgba(67,181,129,0.4);
  animation: medkit-pulse-green 2s ease-in-out infinite;
}
.health-bar-toggle.has-error {
  color: #f04747;
  border-color: rgba(240,71,71,0.4);
  animation: medkit-pulse-red 1s ease-in-out infinite;
}
@keyframes medkit-pulse-green {
  0%, 100% { box-shadow: 0 0 6px rgba(67,181,129,0.2), 0 2px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 16px rgba(67,181,129,0.5), 0 2px 8px rgba(0,0,0,0.3); }
}
@keyframes medkit-pulse-red {
  0%, 100% { box-shadow: 0 0 6px rgba(240,71,71,0.2), 0 2px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 18px rgba(240,71,71,0.6), 0 2px 8px rgba(0,0,0,0.3); }
}
.health-dot {
  position: relative;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease;
  filter: grayscale(0);
}
.health-dot:hover { transform: scale(1.3); }
.health-dot.ok {
  animation: health-pulse-green 3s ease-in-out infinite;
}
.health-dot.error,
.health-dot.down {
  animation: health-pulse-red 0.7s ease-in-out infinite;
}
.health-dot.degraded {
  animation: health-pulse-orange 1.6s ease-in-out infinite;
}
@keyframes health-pulse-green {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(67,181,129,0.4)); }
  50% { filter: drop-shadow(0 0 10px rgba(67,181,129,0.95)) brightness(1.15); }
}
@keyframes health-pulse-red {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(240,71,71,0.4)); }
  50% { filter: drop-shadow(0 0 12px rgba(240,71,71,1.0)) brightness(1.2); }
}
@keyframes health-pulse-orange {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(250,166,26,0.4)); }
  50% { filter: drop-shadow(0 0 10px rgba(250,166,26,0.9)) brightness(1.1); }
}
.health-tooltip {
  display: none;
  position: fixed;
  bottom: 40px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 10000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: auto;
  min-width: 140px;
  max-width: 300px;
}
.health-dot:hover .health-tooltip,
.health-tooltip:hover { display: block; }
.health-tooltip .ht-title { font-weight: 600; margin-bottom: 4px; }
.health-tooltip .ht-detail { color: var(--text-secondary); font-size: 10px; }
.health-tooltip .ht-link { color: var(--accent); margin-top: 4px; font-size: 10px; }
