:root,
html[data-theme="obsidian"] {
  color-scheme: dark;
  --bg-rail: #090908;
  --bg-sidebar: #10100e;
  --bg-stage: #151512;
  --bg-elevated: #1c1b17;
  --bg-card: #191815;
  --bg-input: #0e0e0c;
  --bg-hover: rgba(242, 239, 233, 0.045);
  --bg-active: rgba(217, 155, 56, 0.13);

  --border-hairline: #1f1e1b;
  --border-subtle: #272520;
  --border-strong: #38352e;

  --text-primary: #f2efe9;
  --text-secondary: #aba69c;
  --text-muted: #6e6a61;

  --accent: #d99b38;
  --accent-bright: #eab860;
  --accent-soft: rgba(217, 155, 56, 0.14);
  --accent-border: rgba(217, 155, 56, 0.36);

  --success: #38a169;
  --success-soft: rgba(56, 161, 105, 0.15);
  --warning: #dd6b20;
  --danger: #e53e3e;
  --danger-soft: rgba(229, 62, 62, 0.15);

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.28);
}

html[data-theme="carbon"] {
  color-scheme: dark;
  --bg-rail: #08090b;
  --bg-sidebar: #0e1014;
  --bg-stage: #13161b;
  --bg-elevated: #1a1e25;
  --bg-card: #171a20;
  --bg-input: #0b0d10;
  --bg-hover: rgba(255, 255, 255, 0.045);
  --bg-active: rgba(224, 122, 95, 0.14);
  --border-hairline: #1c2026;
  --border-subtle: #242932;
  --border-strong: #323946;
  --text-primary: #eef0f4;
  --text-secondary: #9ba3b0;
  --text-muted: #646c7a;
  --accent: #e07a5f;
  --accent-bright: #eb947d;
  --accent-soft: rgba(224, 122, 95, 0.14);
  --accent-border: rgba(224, 122, 95, 0.38);
}

html[data-theme="moss"] {
  color-scheme: dark;
  --bg-rail: #070b09;
  --bg-sidebar: #0c120f;
  --bg-stage: #101814;
  --bg-elevated: #16211c;
  --bg-card: #131d18;
  --bg-input: #090e0b;
  --bg-hover: rgba(236, 244, 240, 0.045);
  --bg-active: rgba(56, 161, 105, 0.15);
  --border-hairline: #19241e;
  --border-subtle: #213028;
  --border-strong: #2e4237;
  --text-primary: #ebf2ee;
  --text-secondary: #97aba0;
  --text-muted: #5e7267;
  --accent: #38a169;
  --accent-bright: #48bb78;
  --accent-soft: rgba(56, 161, 105, 0.15);
  --accent-border: rgba(56, 161, 105, 0.38);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg-rail: #e6e2d8;
  --bg-sidebar: #f0ede6;
  --bg-stage: #faf8f5;
  --bg-elevated: #ffffff;
  --bg-card: #f3f0e8;
  --bg-input: #ffffff;
  --bg-hover: rgba(20, 19, 17, 0.05);
  --bg-active: rgba(181, 124, 34, 0.13);
  --border-hairline: #e2ddd2;
  --border-subtle: #d6d0c4;
  --border-strong: #b8b0a0;
  --text-primary: #181715;
  --text-secondary: #57534c;
  --text-muted: #878278;
  --accent: #b57c22;
  --accent-bright: #9c6816;
  --accent-soft: rgba(181, 124, 34, 0.12);
  --accent-border: rgba(181, 124, 34, 0.35);
  --shadow-lg: 0 20px 50px rgba(24, 23, 21, 0.15);
  --shadow-sm: 0 4px 14px rgba(24, 23, 21, 0.06);
}

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

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-stage);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ========================================================================== */
/* MAIN APPLICATION GRID                                                      */
/* ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-stage);
}

/* ========================================================================== */
/* 1. LEFT NAVIGATION RAIL                                                    */
/* ========================================================================== */
.space-rail {
  width: 68px;
  flex-shrink: 0;
  background: var(--bg-rail);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 10px;
  z-index: 30;
}

.space-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.rail-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: border-radius 0.22s var(--ease-out), background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.rail-btn:hover {
  border-radius: 11px;
  color: var(--text-primary);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.rail-btn.active {
  border-radius: 11px;
  background: var(--space-accent, var(--accent));
  color: #0b0b09;
  border-color: transparent;
  font-weight: 800;
}

.space-short {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.rail-indicator {
  position: absolute;
  left: -12px;
  width: 4px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: var(--space-accent, var(--accent));
  transition: height 0.2s var(--ease-out);
}

.rail-btn:hover .rail-indicator {
  height: 18px;
}

.rail-btn.active .rail-indicator {
  height: 32px;
}

.rail-divider {
  width: 28px;
  height: 1px;
  background: var(--border-subtle);
  margin: 2px 0;
}

.rail-add-btn {
  background: transparent;
  border-style: dashed;
  color: var(--accent);
}
.rail-add-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.rail-spacer {
  flex: 1;
}

.rail-util-btn {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: transparent;
  border-color: transparent;
}
.rail-util-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

/* ========================================================================== */
/* 2. CHANNEL & VOICE SIDEBAR                                                 */
/* ========================================================================== */
.channel-sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  min-width: 0;
  z-index: 25;
}

.sidebar-top {
  height: 56px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.space-title-wrap h2 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.sidebar-search-bar {
  padding: 10px 12px 6px;
}

.quick-jump-trigger {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.quick-jump-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.quick-jump-trigger span {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-jump-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.channel-category {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.category-add-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
.category-add-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-row {
  position: relative;
  display: flex;
  flex-direction: column;
}

.channel-row-main {
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.14s ease;
}
.channel-row-main:hover {
  background: var(--bg-hover);
}
.channel-row-main.active {
  background: var(--bg-active);
}

.channel-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.91rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.14s ease;
}

.channel-row-main:hover .channel-item {
  color: var(--text-primary);
}

.channel-row-main.active .channel-item,
.channel-item.active {
  color: var(--text-primary);
  font-weight: 600;
}

.channel-symbol {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-muted);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.channel-row-main.active .channel-symbol,
.channel-item.active .channel-symbol {
  color: var(--accent);
}

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

.channel-count-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.channel-row-actions {
  display: none;
  align-items: center;
  padding-right: 6px;
  gap: 2px;
}
.channel-row-main:hover .channel-row-actions {
  display: flex;
}
.channel-row-main:hover .channel-count-pill {
  display: none;
}

.ch-mini-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
}
.ch-mini-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}
.ch-mini-btn.danger:hover {
  color: var(--danger);
}

/* Voice room nested participants in sidebar */
.voice-tree-members {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px 8px 6px 28px;
}

.voice-tree-user {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.voice-tree-avatar {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent);
  color: #0b0b09;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.voice-tree-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.voice-tree-user.speaking .voice-tree-avatar {
  box-shadow: 0 0 0 2px var(--success);
}

.voice-tree-badges {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
}

.live-mini-tag {
  background: var(--danger);
  color: #fff;
  font-weight: 800;
  font-size: 0.62rem;
  padding: 1px 4px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

/* Connected Voice Room Dock */
.voice-connection-dock {
  margin: 0 8px 8px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid rgba(56, 161, 105, 0.32);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-dock-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-signal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
  flex-shrink: 0;
}

.voice-dock-info {
  flex: 1;
  min-width: 0;
}
.voice-dock-info strong {
  display: block;
  font-size: 0.78rem;
  color: var(--success);
  line-height: 1.2;
}
.voice-dock-info span {
  display: block;
  font-size: 0.76rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-leave-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.voice-leave-btn:hover {
  background: var(--danger);
  color: #fff;
}

.voice-dock-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.dock-action-btn {
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}
.dock-action-btn:hover,
.dock-action-btn.active {
  background: var(--accent-soft);
  color: var(--accent-bright);
  border-color: var(--accent-border);
}

/* User Pod at Bottom of Sidebar */
.user-pod {
  padding: 10px;
  background: var(--bg-rail);
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.user-pod-identity {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}
.user-pod-identity:hover {
  background: var(--bg-hover);
}

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #0b0b09;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}
.avatar.small {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.avatar.large {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 1.15rem;
}

.presence-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-rail);
  background: var(--success);
}
.presence-dot.online { background: var(--success); }
.presence-dot.idle { background: #eab308; }
.presence-dot.dnd { background: var(--danger); }
.presence-dot.offline,
.presence-dot.invisible { background: var(--text-muted); }

.user-pod-text {
  min-width: 0;
  flex: 1;
}
.user-pod-text strong {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-pod-text small {
  display: block;
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pod-buttons {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pod-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.pod-icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.pod-icon-btn.muted {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ========================================================================== */
/* 3. MAIN CHAT & VOICE STAGE                                                 */
/* ========================================================================== */
.chat-stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-stage);
  position: relative;
}

.stage-header {
  height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-stage);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
}

.stage-header-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.mobile-nav-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-channel-icon {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.stage-header-left h1 {
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 700;
  white-space: nowrap;
}

.header-topic-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.header-channel-topic {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-tool-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.header-tool-btn:hover,
.header-tool-btn.active {
  color: var(--text-primary);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.tool-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--accent-bright);
}

.header-search-box {
  height: 32px;
  width: 185px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  transition: width 0.2s var(--ease-out), border-color 0.15s ease;
}
.header-search-box:focus-within {
  width: 240px;
  border-color: var(--accent);
  color: var(--text-primary);
}
.header-search-box input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.82rem;
  color: var(--text-primary);
}

/* ========================================================================== */
/* VOICE & SCREEN-SHARE STAGE PANEL                                           */
/* ========================================================================== */
.voice-stage-panel {
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 58vh;
  overflow-y: auto;
}

.voice-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.voice-stage-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-pill {
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}

.soundboard-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.sb-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 4px;
}
.sb-btn {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.sb-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-border);
  color: var(--text-primary);
}

.stage-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
}

.voice-screen-viewport {
  position: relative;
  background: #000;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  max-height: 340px;
  display: flex;
  flex-direction: column;
}
.voice-screen-viewport video {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: #000;
}
.screen-viewport-bar {
  padding: 6px 12px;
  background: rgba(15, 15, 13, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}

.voice-participants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
}

.voice-tile {
  position: relative;
  height: 118px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.voice-tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 2px var(--success-soft);
}
.voice-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.voice-tile-name {
  position: relative;
  z-index: 2;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(9, 9, 8, 0.72);
}

.voice-stage-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.stage-ctrl-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.stage-ctrl-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-bright);
}
.stage-ctrl-btn.danger {
  background: var(--danger-soft);
  border-color: rgba(229, 62, 62, 0.35);
  color: var(--danger);
}
.stage-ctrl-btn.danger:hover {
  background: var(--danger);
  color: #fff;
}

/* ========================================================================== */
/* MESSAGE STREAM                                                             */
/* ========================================================================== */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 8px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-hairline);
}

.message-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.message-card.group-start {
  margin-top: 8px;
}

.message-card.group-follow {
  padding-top: 3px;
  padding-bottom: 3px;
}

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

.message-card.pinned {
  background: rgba(217, 155, 56, 0.055);
  border-left: 3px solid var(--accent);
}

.message-card.highlight-flash {
  animation: highlightPulse 1.6s ease;
}

@keyframes highlightPulse {
  0%, 30% { background: var(--accent-soft); border-color: var(--accent-border); }
  100% { background: transparent; border-color: transparent; }
}

.msg-follow-gutter {
  width: 36px;
  flex-shrink: 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: transparent;
  padding-top: 3px;
  user-select: none;
}
.message-card:hover .msg-follow-gutter {
  color: var(--text-muted);
}

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

/* Reply Reference Bar above message */
.msg-reply-ref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border-left: 2px solid var(--accent);
  cursor: pointer;
  max-width: 100%;
}
.msg-reply-ref:hover {
  color: var(--text-primary);
}
.msg-reply-ref span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.msg-author-btn {
  background: none;
  border: none;
  padding: 0;
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--text-primary);
  cursor: pointer;
}
.msg-author-btn:hover {
  text-decoration: underline;
}

.role-badge {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.role-badge.role-admin {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-bright);
}
.role-badge.role-team {
  background: var(--success-soft);
  border-color: rgba(56, 161, 105, 0.35);
  color: var(--success);
}

.msg-time {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-muted);
}

.edited-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pin-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-bright);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Message Rich Text & Markdown */
.message-text {
  color: var(--text-primary);
  font-size: 0.94rem;
  line-height: 1.52;
  word-break: break-word;
}

.message-text p + p {
  margin-top: 6px;
}

.message-text code.inline-code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-bright);
}

.code-block-wrap {
  margin: 8px 0;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  overflow: hidden;
}
.code-block-header {
  padding: 5px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-secondary);
}
.copy-code-btn {
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-stage);
  color: var(--text-secondary);
  font-size: 0.72rem;
  cursor: pointer;
}
.copy-code-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}
.code-block-wrap pre {
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.msg-quote {
  margin: 4px 0;
  padding: 4px 10px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 6px 6px 0;
}

.spoiler-span {
  background: var(--border-strong);
  color: transparent;
  border-radius: 4px;
  padding: 0 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.spoiler-span.revealed {
  background: var(--bg-elevated);
  color: var(--text-primary);
  user-select: text;
}

.mention {
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 5px;
  cursor: pointer;
}

.channel-link {
  background: rgba(59, 130, 246, 0.14);
  color: #60a5fa;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 5px;
  cursor: pointer;
}

/* Minecraft Player Embed Card */
.mc-embed-card {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.mc-embed-card img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  image-rendering: pixelated;
}

/* Interactive Poll Card inside Message */
.poll-card {
  margin-top: 8px;
  max-width: 460px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.poll-question {
  font-weight: 700;
  font-size: 0.92rem;
}
.poll-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.poll-option-btn {
  position: relative;
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: border-color 0.15s ease;
}
.poll-option-btn:hover {
  border-color: var(--accent-border);
}
.poll-option-btn.voted {
  border-color: var(--accent);
}
.poll-option-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent-soft);
  transition: width 0.3s var(--ease-out);
  pointer-events: none;
}
.poll-option-label,
.poll-option-meta {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
}
.poll-option-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
}
.poll-footer {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Attachments & Voice Memos */
.attachment-box {
  margin-top: 8px;
}
.attachment-img-wrap {
  display: inline-block;
  max-width: 380px;
  max-height: 280px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  cursor: zoom-in;
}
.attachment-img-wrap img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: cover;
}
.attachment-file-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.85rem;
}
.attachment-file-card:hover {
  border-color: var(--accent);
}

.voice-memo-card {
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
}
.voice-memo-card audio {
  height: 32px;
  max-width: 240px;
}

/* Reactions & Thread Row under Message */
.msg-reactions-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.reaction-pill {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.reaction-pill:hover,
.reaction-pill.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.thread-chip-btn {
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--accent-bright);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.thread-chip-btn:hover {
  border-color: var(--accent);
}

/* Floating Hover Action Toolbar on Message */
.message-hover-bar {
  position: absolute;
  top: -12px;
  right: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2px;
  display: none;
  align-items: center;
  gap: 2px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.message-card:hover .message-hover-bar {
  display: flex;
}

.hover-act-btn {
  height: 26px;
  min-width: 26px;
  padding: 0 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hover-act-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.hover-act-btn.danger:hover {
  color: var(--danger);
}

/* Inline Message Editor */
.inline-edit-box {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inline-edit-box textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--bg-input);
  color: var(--text-primary);
  resize: vertical;
  min-height: 60px;
}
.inline-edit-actions {
  display: flex;
  gap: 6px;
}

/* Empty State */
.empty-state {
  margin: auto;
  padding: 32px;
  text-align: center;
  max-width: 380px;
}
.empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 4px;
}
.empty-state p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Dropzone Overlay */
.dropzone-overlay {
  position: absolute;
  inset: 12px;
  border-radius: 14px;
  background: rgba(14, 14, 12, 0.88);
  border: 2px dashed var(--accent);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--accent-bright);
}
.dropzone-box span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ========================================================================== */
/* COMPOSER DOCK                                                              */
/* ========================================================================== */
.typing-bar {
  min-height: 20px;
  padding: 0 22px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.composer-dock {
  padding: 0 18px 16px;
  position: relative;
}

.composer-context-bar {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}
.reply-context-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.reply-badge {
  color: var(--accent-bright);
  white-space: nowrap;
}
.reply-preview-text {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.context-close-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
}

/* Voice Recorder Bar */
.voice-recorder-bar {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--danger);
  border-radius: 10px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: recBlink 1s infinite;
}
@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.rec-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}
.rec-wave span {
  width: 3px;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: waveBounce 0.8s infinite ease-in-out alternate;
}
.rec-wave span:nth-child(2n) { animation-delay: 0.2s; height: 60%; }
.rec-wave span:nth-child(3n) { animation-delay: 0.4s; height: 85%; }
@keyframes waveBounce {
  from { transform: scaleY(0.35); }
  to { transform: scaleY(1); }
}

/* Autocomplete Popover */
.autocomplete-popover {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(100% + 4px);
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 35;
  max-height: 220px;
  overflow-y: auto;
}
.ac-item {
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  cursor: pointer;
  text-align: left;
}
.ac-item:hover,
.ac-item.active {
  background: var(--accent-soft);
  color: var(--accent-bright);
}
.ac-item small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s ease;
}
.composer:focus-within {
  border-color: var(--accent-border);
}

.composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  max-height: 150px;
  padding: 5px 4px;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.composer-icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.composer-send-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0b0b09;
  font-weight: 700;
  font-size: 0.84rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: filter 0.14s ease, transform 0.12s ease;
}
.composer-send-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* ========================================================================== */
/* 4. CONTEXTUAL DRAWER (Threads, Pins, Search)                               */
/* ========================================================================== */
.context-drawer {
  width: 330px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  z-index: 22;
}

.drawer-header {
  height: 56px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-composer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  gap: 6px;
}
.drawer-composer input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  outline: none;
  font-size: 0.85rem;
}

/* ========================================================================== */
/* 5. RIGHT MEMBER & NETWORK SIDEBAR                                          */
/* ========================================================================== */
.member-sidebar {
  width: 262px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.network-status-card {
  margin: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.net-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.net-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
}

.net-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.net-ip-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-bright);
  cursor: pointer;
}

.net-servers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.net-server-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.77rem;
  color: var(--text-secondary);
}
.net-server-row strong {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-primary);
}

.members-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.member-group-title {
  padding: 0 6px 4px;
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.member-row {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s ease;
}
.member-row:hover {
  background: var(--bg-hover);
}
.member-row.offline {
  opacity: 0.55;
}

.member-info {
  min-width: 0;
  flex: 1;
}
.member-name-line {
  display: flex;
  align-items: center;
  gap: 5px;
}
.member-name-line strong {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-subtext {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================================================== */
/* MODALS, POPOVERS & TOASTS                                                  */
/* ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 4, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-card.modal-sm {
  max-width: 380px;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 18px;
  gap: 14px;
}
.modal-tab {
  padding: 10px 2px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-tab.active {
  color: var(--accent-bright);
  border-bottom-color: var(--accent);
}

.modal-tab-pane,
#channelForm,
#spaceForm,
#pollForm {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-preview-banner {
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
}
.profile-preview-banner strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 3px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-row label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-row input[type="text"],
.form-row input[type="password"],
.form-row select,
.form-row textarea,
.poll-opt-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  font-size: 0.88rem;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
.poll-opt-input:focus {
  border-color: var(--accent);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.poll-options-inputs {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.type-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.type-card {
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.type-card input {
  display: none;
}
.type-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.type-card strong {
  display: block;
  font-size: 0.84rem;
}
.type-card small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.theme-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.theme-option {
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}
.theme-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.swatch-obsidian { background: linear-gradient(135deg, #0e0e0c 50%, #d99b38 50%); }
.swatch-carbon { background: linear-gradient(135deg, #0e1014 50%, #e07a5f 50%); }
.swatch-moss { background: linear-gradient(135deg, #0c120f 50%, #38a169 50%); }
.swatch-light { background: linear-gradient(135deg, #faf8f5 50%, #b57c22 50%); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.86rem;
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}
.auth-mode-btn {
  padding: 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-mode-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}
.btn-primary {
  background: var(--accent);
  color: #0b0b09;
}
.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* Quick Switcher Modal */
.quick-switcher-card {
  max-width: 520px;
}
.qs-input-wrap {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}
.qs-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.96rem;
}
.qs-input-wrap kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.qs-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.qs-item {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}
.qs-item:hover {
  background: var(--accent-soft);
}

/* Emoji Popover & User Card Popover */
.emoji-popover,
.user-card-popover {
  position: fixed;
  z-index: 95;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
}
.emoji-popover {
  width: 288px;
}
.emoji-search-wrap input {
  width: 100%;
  padding: 6px 9px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  outline: none;
  font-size: 0.82rem;
  margin-bottom: 8px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  max-height: 210px;
  overflow-y: auto;
}
.emoji-cell {
  height: 34px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 1.15rem;
  cursor: pointer;
}
.emoji-cell:hover {
  background: var(--bg-hover);
  transform: scale(1.12);
}

.user-card-popover {
  width: 270px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Lightbox */
.lightbox-backdrop {
  flex-direction: column;
  gap: 12px;
}
.lightbox-backdrop img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-sidebar);
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
}

.confirm-text {
  padding: 16px 18px 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Toast Notifications */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast-item {
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-border);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.2s var(--ease-out);
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Compact Mode */
body.compact-mode .message-card {
  padding: 4px 10px;
  gap: 8px;
}
body.compact-mode .avatar.small {
  width: 26px;
  height: 26px;
  font-size: 0.7rem;
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .member-sidebar {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    box-shadow: var(--shadow-lg);
  }
  .tool-label {
    display: none;
  }
}

@media (max-width: 820px) {
  .mobile-nav-btn {
    display: inline-flex;
  }
  .channel-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 68px;
    transform: translateX(-120%);
    transition: transform 0.22s var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .channel-sidebar.mobile-open {
    transform: translateX(0);
  }
  .header-channel-topic,
  .header-topic-divider {
    display: none;
  }
  .header-search-box {
    width: 130px;
  }
}
