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

:root {
  --bg-base: #0f1117;
  --bg-surface: #1a1d27;
  --bg-raised: #252836;
  --bg-elevated: #2e3145;
  --bg-hover: rgba(255,255,255,0.04);
  --bg-active: rgba(255,255,255,0.08);
  --bg-selected: rgba(108,99,255,0.15);

  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b8;
  --text-faint: #5a6080;
  --text-heading: #f0f2ff;
  --text-link: #818cf8;

  --accent: #6c63ff;
  --accent-hover: #7c74ff;
  --accent-dim: rgba(108,99,255,0.18);

  --status-online: #34d399;
  --status-idle: #fbbf24;
  --status-dnd: #f87171;
  --status-offline: #4b5563;
  --status-positive: #34d399;
  --status-danger: #f87171;
  --status-warning: #fbbf24;

  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);

  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-round: 50%;

  --ease: 0.15s ease;
  --ease-md: 0.2s ease;

  --server-list-width: 68px;
  --channel-sidebar-width: 232px;
  --member-list-width: 232px;
  --header-height: 48px;
  --user-panel-height: 54px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', 'Noto Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }
::-webkit-scrollbar-corner { background: transparent; }

.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-track { background: var(--bg-surface); }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }

* { scrollbar-width: thin; scrollbar-color: var(--bg-elevated) transparent; }
.chat-scroll { scrollbar-color: var(--bg-elevated) var(--bg-surface); }

.app {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.server-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--server-list-width);
  min-width: var(--server-list-width);
  background: var(--bg-base);
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 6px;
  z-index: 10;
  border-right: 1px solid var(--border);
}

.server-list::-webkit-scrollbar { width: 0; display: none; }

#serverIcons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.server-icon {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-radius var(--ease-md), background var(--ease), color var(--ease);
  flex-shrink: 0;
  overflow: hidden;
}

.server-icon:hover {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-lg);
}

.server-icon.active {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-lg);
}

.server-icon.home { font-weight: 700; }

.server-pill {
  position: absolute;
  left: -8px;
  width: 4px;
  height: 0;
  border-radius: 0 2px 2px 0;
  background: var(--text-heading);
  transition: height var(--ease-md);
}

.server-icon:hover .server-pill { height: 16px; }
.server-icon.active .server-pill { height: 36px; }

.server-separator {
  width: 28px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.server-icon.dragging { opacity: 0.4; transform: scale(0.9); }
.server-icon.drag-over { outline: 2px solid var(--accent); transform: scale(1.08); }

.server-icon.add-server {
  background: var(--bg-surface);
  color: var(--status-positive);
  font-size: 22px;
  font-weight: 300;
}

.server-icon.add-server:hover {
  background: var(--status-positive);
  color: #fff;
}

.channel-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--channel-sidebar-width);
  min-width: var(--channel-sidebar-width);
  background: var(--bg-surface);
  position: relative;
  z-index: 5;
  border-right: 1px solid var(--border);
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.server-header {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--ease);
  z-index: 2;
}

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

.server-header-dropdown { display: flex; align-items: center; gap: 4px; width: 100%; }
.server-header-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-header-chevron { font-size: 13px; color: var(--text-secondary); transition: transform var(--ease); flex-shrink: 0; }
.server-header:hover .server-header-chevron { color: var(--text-primary); }

.server-header-btn {
  width: 20px;
  height: 20px;
  margin-left: auto;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--ease), color var(--ease);
}

.server-header:hover .server-header-btn { opacity: 1; }
.server-header-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.server-boost-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #a78bfa, var(--accent));
  background-size: 200% 100%;
  animation: boostShimmer 3s linear infinite;
  flex-shrink: 0;
}

@keyframes boostShimmer { 0% { background-position: 0% 0%; } 100% { background-position: 200% 0%; } }

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 6px;
  padding-top: 12px;
}

.category-header {
  display: flex;
  align-items: center;
  padding: 14px 2px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  cursor: pointer;
  user-select: none;
  gap: 2px;
}

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

.category-header::before {
  content: '\25BE';
  font-size: 9px;
  margin-right: 2px;
  transition: transform var(--ease);
}

.category-header.collapsed::before { transform: rotate(-90deg); }

.category-arrow {
  width: 11px;
  height: 11px;
  margin-right: 2px;
  fill: currentColor;
  flex-shrink: 0;
  transition: transform var(--ease);
}

.category-header.collapsed .category-arrow { transform: rotate(-90deg); }
.category-arrow.collapsed { transform: rotate(-90deg); }
.category-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-header:has(.category-arrow)::before { display: none; }

.category-add-btn {
  margin-left: auto;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--ease), color var(--ease);
  line-height: 1;
  padding: 0;
}

.category-header:hover .category-add-btn { opacity: 1; }
.category-add-btn:hover { color: var(--text-primary); }

.channel-item {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  gap: 6px;
  position: relative;
}

.channel-item:hover { background: var(--bg-hover); color: var(--text-secondary); }
.channel-item.active { background: var(--bg-selected); color: var(--text-primary); }

.channel-icon { font-size: 17px; width: 18px; text-align: center; flex-shrink: 0; opacity: 0.65; }
.channel-item.active .channel-icon { opacity: 1; }

.ch-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  opacity: 0.65;
}

.channel-item.active .ch-icon, .channel-item:hover .ch-icon { opacity: 1; }
.ch-icon svg { width: 15px; height: 15px; fill: currentColor; }

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

.channel-item.unread .channel-name { color: var(--text-primary); font-weight: 600; }
.channel-item.unread::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 0 2px 2px 0;
  background: var(--text-primary);
}

.channel-mention-badge {
  margin-left: auto;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--status-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.channel-actions { display: none; align-items: center; gap: 2px; margin-left: auto; flex-shrink: 0; }
.channel-item:hover .channel-actions { display: flex; }
.channel-item:hover .channel-mention-badge { display: none; }

.channel-action-btn {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--ease);
}

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

.channel-item .channel-badge { font-size: 10px; font-weight: 700; color: var(--text-faint); margin-left: auto; }
.channel-item .thread-count { font-size: 10px; color: var(--text-faint); margin-left: auto; display: flex; align-items: center; gap: 2px; }

.channel-item.muted .channel-name { opacity: 0.35; }
.channel-item.muted .channel-icon { opacity: 0.25; }
.channel-item.muted:hover .channel-name { opacity: 0.6; }

.channel-item[draggable="true"] { cursor: grab; }
.channel-item[draggable="true"]:active { cursor: grabbing; }

.drop-indicator { height: 2px; background: var(--accent); margin: 2px 0; border-radius: 1px; pointer-events: none; }

.voice-users { padding-left: 26px; margin-top: 2px; margin-bottom: 4px; }

.voice-user {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-faint);
  cursor: default;
  transition: background var(--ease);
}

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

.voice-user-avatar {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-round);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.voice-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-user.speaking { color: var(--status-positive); }
.voice-user.speaking .voice-user-avatar { box-shadow: 0 0 0 2px var(--status-positive); }

.channel-item.voice-active { color: var(--status-positive); }
.channel-item.voice-connecting { color: var(--text-muted); }
.voice-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid var(--text-faint);
  border-top-color: var(--text-normal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.voice-panel {
  display: none;
  flex-direction: column;
  padding: 10px 8px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.voice-panel.visible { display: flex; }

.voice-panel-header { font-size: 12px; font-weight: 600; color: var(--status-positive); margin-bottom: 2px; }
.voice-panel-channel { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
.voice-panel-actions { display: flex; gap: 6px; }

.voice-panel-btn {
  flex: 1;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-panel-btn:hover { background: var(--bg-active); color: var(--text-primary); }
.voice-panel-btn.disconnect { background: rgba(248,113,113,0.12); color: var(--status-danger); }
.voice-panel-btn.disconnect:hover { background: rgba(248,113,113,0.24); }

.user-panel {
  height: var(--user-panel-height);
  min-height: var(--user-panel-height);
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  gap: 8px;
}

.user-panel-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-round);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.user-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-round);
  background: var(--status-online);
  border: 2px solid var(--bg-base);
}

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

.user-panel-info { flex: 1; min-width: 0; cursor: pointer; }
.user-panel-name { font-size: 13px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.user-panel-tag { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }

.user-panel-controls { display: flex; gap: 2px; flex-shrink: 0; }

.user-panel-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), color var(--ease);
}

.user-panel-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.user-panel-btn.active { color: var(--status-danger); }
.user-panel-btn.muted { color: var(--status-danger); }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
  position: relative;
}

.chat-header-bar {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  z-index: 2;
  gap: 8px;
  background: var(--bg-surface);
}

.chat-header-icon { font-size: 18px; color: var(--text-secondary); }
.chat-header-name { font-size: 15px; font-weight: 600; color: var(--text-heading); white-space: nowrap; }
.chat-header-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.chat-header-topic { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-header-toolbar { display: flex; gap: 2px; flex-shrink: 0; }

.toolbar-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--ease), background var(--ease);
}

.toolbar-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.toolbar-btn.active { color: var(--text-primary); }
.toolbar-btn.notif-active { color: var(--status-warning); }

.chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-messages-inner { padding: 16px 0; }

.msg-group {
  position: relative;
  padding: 4px 48px 4px 68px;
  margin-top: 16px;
  min-height: 44px;
  transition: background var(--ease);
}

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

.msg-group .msg-avatar {
  position: absolute;
  left: 16px;
  top: 4px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-round);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
}

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

.msg-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  cursor: pointer;
  display: inline;
  line-height: 1.5;
}

.msg-username:hover { text-decoration: underline; }

.msg-timestamp { font-size: 11px; color: var(--text-faint); margin-left: 8px; font-weight: 400; vertical-align: baseline; }
.msg-edited { font-size: 10px; color: var(--text-faint); margin-left: 4px; font-weight: 400; }

.msg-content { color: var(--text-primary); font-size: 14px; line-height: 1.5; word-wrap: break-word; overflow-wrap: break-word; }

.msg-cont {
  position: relative;
  padding: 1px 48px 1px 68px;
  transition: background var(--ease);
}

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

.msg-cont .msg-timestamp-hover,
.msg-cont .msg-hover-time {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  text-align: right;
  font-size: 10px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity var(--ease);
  pointer-events: none;
  padding-right: 4px;
}

.msg-cont:hover .msg-timestamp-hover,
.msg-cont:hover .msg-hover-time { opacity: 1; }

.msg-image { max-width: 380px; border-radius: var(--radius-md); margin-top: 4px; display: block; }
.msg-image img { max-width: 100%; max-height: 280px; border-radius: var(--radius-md); cursor: pointer; display: block; object-fit: contain; }
.msg-image img:hover { box-shadow: 0 0 0 2px var(--accent); }
.msg-image-wrapper { margin-top: 4px; }
.msg-image-caption { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.msg-file {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 4px;
  max-width: 400px;
}

.msg-file-icon { font-size: 26px; flex-shrink: 0; opacity: 0.6; }
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 500; color: var(--text-link); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-file-name:hover { text-decoration: underline; }
.msg-file-size { font-size: 11px; color: var(--text-secondary); }

.msg-file-download {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--ease), background var(--ease);
}

.msg-file-download:hover { color: var(--text-primary); background: var(--bg-hover); }

.msg-system { padding: 4px 48px 4px 68px; color: var(--text-faint); font-size: 13px; font-style: italic; }
.msg-system .msg-system-icon { margin-right: 6px; }

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

.msg-group:hover .msg-actions, .msg-cont:hover .msg-actions { display: flex; }

.msg-action-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), color var(--ease);
  position: relative;
}

.msg-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.msg-action-btn.danger:hover { background: rgba(248,113,113,0.12); color: var(--status-danger); }

.msg-action-btn[title]::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease);
  z-index: 20;
  box-shadow: var(--shadow-md);
}

.msg-action-btn:hover[title]::after { opacity: 1; }

.msg-reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 2px;
  padding-left: 0;
}

.msg-reply-bar::before {
  content: '';
  display: inline-block;
  width: 34px;
  height: 9px;
  border-top: 2px solid var(--text-faint);
  border-left: 2px solid var(--text-faint);
  border-top-left-radius: 5px;
  flex-shrink: 0;
  margin-top: 8px;
  margin-left: 14px;
}

.msg-reply-avatar { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 7px; font-weight: 700; color: #fff; }
.msg-reply-name { font-weight: 600; cursor: pointer; }
.msg-reply-name:hover { text-decoration: underline; }
.msg-reply-content { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; cursor: pointer; }
.msg-reply-content:hover { text-decoration: underline; color: var(--text-secondary); }

.reply-compose-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.reply-compose-name { color: var(--text-link); font-weight: 600; }

.reply-compose-close {
  margin-left: auto;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.reply-compose-close:hover { color: var(--text-primary); }

.msg-edit-area { margin-top: 4px; }

.msg-edit-input {
  width: 100%;
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 200px;
  line-height: 1.5;
}

.msg-edit-input:focus { box-shadow: 0 0 0 2px var(--accent); }

.msg-edit-hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.msg-edit-hint a { color: var(--text-link); cursor: pointer; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
  font-family: inherit;
}

.reaction-pill:hover { background: var(--bg-elevated); border-color: var(--accent); }
.reaction-pill.reacted { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.reaction-count { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.reaction-pill.reacted .reaction-count { color: var(--accent); }

.mention { background: rgba(108,99,255,0.18); color: #a5b4fc; border-radius: 3px; padding: 0 2px; font-weight: 500; cursor: pointer; transition: background var(--ease); }
.mention:hover { background: rgba(108,99,255,0.35); color: #fff; }
.mention.self { background: rgba(251,191,36,0.18); color: var(--status-warning); }
.mention.self:hover { background: rgba(251,191,36,0.35); }

.chat-input-wrapper {
  padding: 0 14px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 0 4px;
  min-height: 42px;
  border: 1px solid var(--border);
}

.attach-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--ease);
}

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

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 0;
  outline: none;
  min-width: 0;
}

.chat-input::placeholder { color: var(--text-faint); }

.input-buttons { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.input-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--ease);
}

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

.input-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--ease);
}

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

.member-list {
  width: var(--member-list-width);
  min-width: var(--member-list-width);
  background: var(--bg-surface);
  overflow-y: auto;
  padding: 20px 6px 0;
  border-left: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.member-role-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 8px 4px;
}

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

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

.member-avatar {
  position: relative;
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: var(--radius-round);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.member-avatar .member-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-round);
  background: var(--status-online);
  border: 2px solid var(--bg-surface);
}

.member-avatar .member-status.offline { background: var(--status-offline); }

.member-name { font-size: 13px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-item:hover .member-name { color: var(--text-primary); }
.member-item.speaking .member-avatar { box-shadow: 0 0 0 2px var(--status-positive); }
.member-item.speaking .member-name { color: var(--status-positive); }
.member-item .member-name.colored { color: inherit; }

.member-role-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: auto;
  flex-shrink: 0;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
}

.member-section-separator { height: 1px; background: var(--border); margin: 6px 8px; }

.member-list.open { display: flex; flex-direction: column; }

.voice-view {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
}

.voice-view.active { display: flex; }

.voice-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.voice-view-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.voice-view-actions { display: flex; gap: 4px; }

.voice-turn-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 24px;
  background: rgba(52,211,153,0.1);
  border-bottom: 1px solid rgba(52,211,153,0.25);
  font-size: 13px;
  font-weight: 600;
  color: var(--status-positive);
  flex-shrink: 0;
}

.voice-turn-banner.your-turn {
  background: rgba(108,99,255,0.12);
  border-bottom-color: rgba(108,99,255,0.25);
  color: var(--accent);
}

.voice-turn-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; animation: recBlink 1.2s ease-in-out infinite; }

.voice-turn-order {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.voice-turn-order::-webkit-scrollbar { display: none; }

.voice-turn-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--bg-hover);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--ease);
}

.voice-turn-chip.active { background: rgba(52,211,153,0.15); color: var(--status-positive); font-weight: 700; }
.voice-turn-chip.yours { background: var(--accent-dim); color: var(--accent); }

.voice-turn-avatar { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; }

.voice-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  justify-items: center;
  align-items: center;
  align-content: center;
  padding: 24px;
  overflow-y: auto;
}

.voice-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: background var(--ease);
  width: 100%;
  max-width: 196px;
}

.voice-tile:hover { background: var(--bg-elevated); }

.voice-tile-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-round);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  transition: box-shadow var(--ease-md);
  overflow: hidden;
}

.voice-tile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.voice-tile-avatar.speaking { box-shadow: 0 0 0 3px var(--status-positive); animation: speakingPulse 1.5s ease-in-out infinite; }

@keyframes speakingPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--status-positive); }
  50% { box-shadow: 0 0 0 3px rgba(52,211,153,0.4); }
}

.voice-tile-name { font-size: 13px; font-weight: 600; color: var(--text-heading); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.voice-tile-status { font-size: 11px; color: var(--text-secondary); }
.voice-tile-muted { font-size: 11px; color: var(--status-danger); font-weight: 500; }

.voice-controls { display: flex; gap: 10px; padding: 20px; justify-content: center; }

.voice-ctrl-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-round);
  border: none;
  background: var(--bg-raised);
  color: var(--text-primary);
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), color var(--ease);
  border: 1px solid var(--border);
}

.voice-ctrl-btn:hover { background: var(--bg-elevated); color: var(--text-heading); }
.voice-ctrl-btn.active { background: var(--status-positive); color: #fff; border-color: transparent; }
.voice-ctrl-btn.danger { background: rgba(248,113,113,0.15); color: var(--status-danger); border-color: rgba(248,113,113,0.2); }
.voice-ctrl-btn.danger:hover { background: var(--status-danger); color: #fff; border-color: transparent; }

.threaded-view { flex: 1; display: none; flex-direction: column; min-height: 0; }
.threaded-view.active { display: flex; }
.threaded-content { flex: 1; display: flex; min-height: 0; overflow: hidden; }

.threaded-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  gap: 16px;
}

.threaded-controls { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.ptt-btn {
  width: 112px;
  height: 112px;
  border-radius: var(--radius-round);
  border: 3px solid var(--accent);
  background: var(--bg-raised);
  color: var(--text-heading);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.ptt-btn:hover { background: var(--accent); color: #fff; }

.ptt-btn:active, .ptt-btn.recording {
  background: var(--status-danger);
  border-color: var(--status-danger);
  color: #fff;
  transform: scale(1.04);
  box-shadow: 0 0 0 8px rgba(248,113,113,0.2);
  animation: pttPulse 1s ease-in-out infinite;
}

@keyframes pttPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(248,113,113,0.2); }
  50% { box-shadow: 0 0 0 16px rgba(248,113,113,0.08); }
}

.ptt-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.ptt-status .rec-dot { width: 7px; height: 7px; border-radius: var(--radius-round); background: var(--text-faint); flex-shrink: 0; }
.ptt-status.recording { color: var(--status-danger); }
.ptt-status.recording .rec-dot { background: var(--status-danger); animation: recBlink 1s ease-in-out infinite; }
.ptt-status.listening { color: var(--status-positive); }
.ptt-status.listening .rec-dot { background: var(--status-positive); }

@keyframes recBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.ctrl-row { display: flex; align-items: center; gap: 8px; }
.ctrl-label { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; min-width: 30px; flex-shrink: 0; }
.ctrl-value { font-size: 11px; color: var(--text-secondary); min-width: 34px; text-align: right; flex-shrink: 0; }

input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; height: 4px; border-radius: 2px; background: var(--bg-elevated); outline: none; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 13px; height: 13px; border-radius: var(--radius-round); background: var(--accent); border: none; cursor: pointer; transition: transform var(--ease); }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: var(--radius-round); background: var(--accent); border: none; cursor: pointer; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--bg-elevated); }

select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-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'%3E%3Cpath fill='%239ca3b8' d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

select:focus { box-shadow: 0 0 0 2px var(--accent); border-color: transparent; }
select option { background: var(--bg-elevated); color: var(--text-primary); }

.ctrl-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
  white-space: nowrap;
}

.ctrl-btn:hover { background: var(--bg-elevated); color: var(--text-heading); border-color: var(--border-strong); }
.ctrl-btn:active { background: var(--bg-elevated); }
.ctrl-btn.active { background: var(--accent); color: #fff; border-color: transparent; }
.ctrl-btn.active:hover { background: var(--accent-hover); }
.ctrl-btn.danger { background: rgba(248,113,113,0.1); color: var(--status-danger); border-color: rgba(248,113,113,0.2); }
.ctrl-btn.danger:hover { background: rgba(248,113,113,0.2); }

.vad-container { width: 100%; max-width: 340px; padding: 4px 0; }
.vad-bar { position: relative; width: 100%; height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: visible; }
.vad-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--status-positive), var(--status-warning), var(--status-danger)); transition: width 0.05s linear; min-width: 0; }
.vad-threshold-marker { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--text-primary); border-radius: 1px; transform: translateX(-50%); pointer-events: none; z-index: 1; }

.webcam-preview { width: 100%; max-width: 340px; border-radius: var(--radius-md); overflow: hidden; background: #000; display: none; }
.webcam-preview.active { display: block; }
.webcam-preview video { width: 100%; display: block; border-radius: var(--radius-md); }

.queue-sidebar {
  width: 252px;
  min-width: 252px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.queue-sidebar.open { display: flex; }

.queue-header {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border);
}

.queue-list { flex: 1; overflow-y: auto; padding: 8px; }

.queue-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  border-left: 3px solid var(--text-faint);
  cursor: pointer;
  transition: background var(--ease);
}

.queue-item:hover { background: var(--bg-elevated); }
.queue-item.playing { border-left-color: var(--status-positive); }
.queue-item.pending { border-left-color: var(--accent); }
.queue-item.completed { border-left-color: var(--text-faint); }
.queue-item.error { border-left-color: var(--status-danger); }
.queue-item.replaying { border-left-color: var(--accent); background: var(--accent-dim); }

.queue-icon { font-size: 15px; flex-shrink: 0; width: 22px; text-align: center; }
.queue-info { flex: 1; min-width: 0; }
.queue-name { font-size: 12px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-meta { font-size: 10px; color: var(--text-secondary); }
.queue-actions { display: flex; gap: 4px; flex-shrink: 0; }

.queue-item-user { font-size: 12px; font-weight: 600; color: var(--text-heading); }
.queue-item-time { font-size: 10px; color: var(--text-secondary); }
.queue-item-controls { display: flex; gap: 4px; margin-top: 4px; }

.queue-item-btn {
  padding: 2px 7px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

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

.queue-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), color var(--ease);
}

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

.skip-btn {
  display: block;
  width: 100%;
  padding: 7px 12px;
  margin-bottom: 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease);
}

.skip-btn:hover { background: var(--accent-hover); }
.skip-btn.resume { background: var(--status-positive); }
.skip-btn.resume:hover { background: #2bb87c; }

.video-playback {
  display: none;
  position: fixed;
  bottom: 14px;
  right: 14px;
  width: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  background: #000;
  border: 1px solid var(--border);
}

.video-playback.active { display: block; }
.video-playback video { width: 100%; display: block; }

.video-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.65);
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-overlay.active, .modal-overlay.open { display: flex; }

.modal-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: modalIn 0.18s ease;
}

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

.modal-title { font-size: 22px; font-weight: 700; color: var(--text-heading); text-align: center; margin-bottom: 4px; }
.modal-subtitle { font-size: 13px; color: var(--text-secondary); text-align: center; margin-bottom: 20px; }

.modal-tabs {
  display: flex;
  margin-bottom: 16px;
  gap: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.modal-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.modal-tab:hover { color: var(--text-primary); }
.modal-tab.active { background: var(--bg-raised); color: var(--text-heading); }

.modal-error {
  display: none;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  color: var(--status-danger);
  font-size: 12px;
  margin-bottom: 12px;
}

.modal-error.visible { display: block; }

.modal-field { margin-bottom: 14px; }

.modal-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.modal-input::placeholder { color: var(--text-faint); }
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.modal-btn {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease);
  margin-top: 8px;
}

.modal-btn:hover { background: var(--accent-hover); }
.modal-btn.secondary { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.modal-btn.secondary:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-btn.danger { background: rgba(248,113,113,0.12); color: var(--status-danger); }
.modal-btn.danger:hover { background: rgba(248,113,113,0.22); }

#nostrConnectView, #nostrLoggedInView { display: flex; flex-direction: column; gap: 8px; }
.modal-divider { height: 1px; background: var(--border); margin: 4px 0; }

.user-profile { display: flex; flex-direction: column; align-items: center; padding: 20px 0; gap: 8px; }

.user-profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-round);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  overflow: hidden;
}

.user-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-profile-name { font-size: 18px; font-weight: 700; color: var(--text-heading); }
.user-profile-tag { font-size: 13px; color: var(--text-secondary); }

.image-modal {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.88);
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
  padding: 32px;
}

.image-modal img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }

.image-modal-content { position: relative; max-width: 90vw; max-height: 90vh; display: flex; align-items: center; justify-content: center; }
.image-modal-content img { max-width: 100%; max-height: 90vh; object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }

.image-modal-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-round);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: background var(--ease);
}

.image-modal-close:hover { background: var(--bg-hover); }

.settings-popover {
  display: none;
  position: fixed;
  bottom: 66px;
  left: calc(var(--server-list-width) + 8px);
  width: 272px;
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 1500;
  animation: popoverIn 0.14s ease;
}

.settings-popover.active, .settings-popover.open { display: block; }

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

.settings-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.context-menu {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 5px 6px;
  min-width: 152px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: popoverIn 0.1s ease;
}

.context-menu-item {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.context-menu-item:hover { background: var(--accent); color: #fff; }
.context-menu-item.danger { color: var(--status-danger); }
.context-menu-item.danger:hover { background: var(--status-danger); color: #fff; }

.toggle-switch { position: relative; display: inline-block; width: 38px; height: 21px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 10px;
  transition: background var(--ease);
  border: 1px solid var(--border);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 15px;
  width: 15px;
  left: 2px;
  bottom: 2px;
  background: var(--text-faint);
  border-radius: var(--radius-round);
  transition: transform var(--ease), background var(--ease);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: transparent; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(17px); background: #fff; }

.thread-panel {
  width: 0;
  min-width: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width var(--ease-md);
  border-left: 1px solid var(--border);
}

.thread-panel.open { width: 340px; min-width: 340px; }

.thread-panel-header {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-heading);
  flex-shrink: 0;
}

.thread-panel-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thread-panel-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.thread-list { flex: 1; overflow-y: auto; padding: 6px; }

.thread-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--ease);
  margin-bottom: 2px;
}

.thread-item:hover { background: var(--bg-hover); }
.thread-item.active { background: var(--bg-selected); }

.thread-item-header { display: flex; align-items: center; gap: 7px; }
.thread-item-icon { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.thread-item-name { font-size: 13px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.thread-item-meta { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-secondary); }
.thread-item-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 20px; }

.thread-create-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--ease), color var(--ease);
  font-family: inherit;
}

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

.forum-view { flex: 1; display: none; flex-direction: column; min-height: 0; }
.forum-view.active { display: flex; }

.forum-header-bar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.forum-search {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.forum-search::placeholder { color: var(--text-faint); }
.forum-search:focus { border-color: var(--accent); }

.forum-new-post-btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease);
  white-space: nowrap;
}

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

.forum-posts { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }

.forum-post-card {
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: background var(--ease);
  border: 1px solid var(--border);
}

.forum-post-card:hover { background: var(--bg-elevated); border-color: var(--border-strong); }

.forum-post-title { font-size: 15px; font-weight: 700; color: var(--text-heading); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.forum-post-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-secondary); }
.forum-post-preview { font-size: 12px; color: var(--text-secondary); margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.forum-tag { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 10px; font-size: 10px; font-weight: 600; background: var(--bg-elevated); color: var(--text-secondary); margin-right: 4px; border: 1px solid var(--border); }

.quality-dot { display: inline-block; width: 7px; height: 7px; border-radius: var(--radius-round); margin-left: 4px; vertical-align: middle; }
.quality-dot.excellent { background: var(--status-positive); }
.quality-dot.good { background: var(--status-positive); }
.quality-dot.poor { background: var(--status-warning); }
.quality-dot.lost { background: var(--status-danger); animation: recBlink 1s ease-in-out infinite; }
.quality-dot.reconnecting { background: var(--status-warning); animation: recBlink 1.5s ease-in-out infinite; }

.reconnect-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--status-warning);
  color: #000;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  transform: translateY(-100%);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.reconnect-banner.visible { transform: translateY(0); }

.mobile-header {
  display: none;
  align-items: center;
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 2;
  gap: 8px;
}

.mobile-hamburger {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-hamburger:hover { color: var(--text-primary); }
.mobile-title { flex: 1; font-size: 15px; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mobile-members-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-members-btn:hover { color: var(--text-primary); }

.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100; touch-action: none; }
.drawer-overlay.active, .drawer-overlay.open { display: block; }

.hidden { display: none !important; }

.hidden-input { position: absolute; width: 0; height: 0; opacity: 0; overflow: hidden; pointer-events: none; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; color: var(--text-secondary); font-size: 13px; text-align: center; min-height: 120px; }

.uiToast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9000;
  white-space: nowrap;
}

.uiToast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1024px) {
  .member-list { display: none; }

  .member-list.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  }

  .chat-input-wrapper {
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
    padding: 0 14px 14px;
  }
}

@media (max-width: 768px) {
  :root {
    --mobile-server-bar-height: 60px;
  }

  .server-list {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: var(--mobile-server-bar-height);
    min-width: unset;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 150;
    gap: 8px;
    scrollbar-width: none;
    background: var(--bg-base);
  }

  .server-list::-webkit-scrollbar { display: none; }

  #serverIcons {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .server-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .server-separator {
    width: 1px;
    height: 28px;
    flex-shrink: 0;
  }

  .channel-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: var(--mobile-server-bar-height);
    width: 85%;
    max-width: 290px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }

  .channel-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }

  .mobile-header { display: flex; }
  .chat-header-bar { display: none; }
  .member-list { display: none; }
  .queue-sidebar { display: none; }

  .queue-sidebar.open {
    display: flex;
    position: fixed;
    right: 0;
    top: 0;
    bottom: var(--mobile-server-bar-height);
    z-index: 200;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  }

  .main-content {
    width: 100%;
    padding-bottom: var(--mobile-server-bar-height);
  }

  .chat-input-wrapper {
    padding: 0 8px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
  }

  .chat-input-bar {
    min-height: 44px;
  }

  .attach-btn, .input-btn, .input-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .msg-group { padding-left: 56px; }
  .msg-group .msg-avatar { left: 10px; }
  .msg-cont { padding-left: 56px; }

  .voice-ctrl-btn {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  .voice-controls { padding: 16px; gap: 14px; }

  .channel-item { height: 44px; }

  .voice-panel-btn { height: 44px; }

  .settings-popover {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    max-width: 310px;
    margin: 0 auto;
    position: fixed;
  }

  .settings-popover.active, .settings-popover.open { display: block; }

  .context-menu-item { padding: 10px 8px; font-size: 15px; }

  .modal-overlay { padding-bottom: max(16px, calc(var(--mobile-server-bar-height) + 8px)); }
}

@media (max-width: 480px) {
  .voice-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; padding: 8px; }
  .voice-tile { padding: 12px 10px; }
  .voice-tile-avatar { width: 52px; height: 52px; font-size: 20px; }
  .voice-tile-name { font-size: 11px; }
  .voice-ctrl-btn { width: 40px; height: 40px; font-size: 16px; }
  .ptt-btn { width: 90px; height: 90px; font-size: 12px; border-width: 3px; }
  .threaded-main { padding: 10px; gap: 10px; }
  .threaded-controls { max-width: 100%; }
  .modal-box { padding: 18px; border-radius: var(--radius-md); }
  .modal-title { font-size: 18px; }
}

.announcement-msg { border-left: 3px solid #feb347; background: rgba(254,179,71,0.08); padding-left: 8px; }
.voice-tile-role-badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; color: #fff; margin-left: 4px; vertical-align: middle; }

.page-view-header{display:flex;align-items:center;gap:12px;margin-bottom:20px;padding-bottom:12px;border-bottom:1px solid var(--border)}
.page-view-title{font-size:22px;font-weight:700;color:var(--text)}
.page-edit-btn{margin-left:auto}
.page-view-body{color:var(--text-secondary);line-height:1.7;font-size:15px}
.page-view-body h1,.page-view-body h2,.page-view-body h3{color:var(--text);margin:16px 0 8px}
.page-view-body a{color:var(--accent)}
.page-view-body blockquote{border-left:3px solid var(--accent);padding-left:12px;margin:8px 0;color:var(--text-muted)}
.page-view-body ul,.page-view-body ol{padding-left:20px;margin:8px 0}
.page-tb-btn{background:var(--bg-raised);border:1px solid var(--border);color:var(--text);border-radius:4px;padding:4px 10px;cursor:pointer;font-size:13px}
.page-tb-btn:hover{background:var(--bg-surface)}
