@keyframes speakez-load {
  0%   { transform: rotate(0deg) }
  20%  { transform: rotate(360deg) }
  60%  { transform: rotate(360deg) }
  80%  { transform: rotate(720deg) }
  100% { transform: rotate(720deg) }
}
.chat-spinner {
  display: flex; align-items: center; justify-content: center;
  height: 100%; opacity: 0.35;
}
.chat-spinner-img {
  width: 72px; height: 72px;
  animation: speakez-load 2.4s ease-in-out infinite;
}

html.no-session body { visibility: hidden }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

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

.logo { font-weight: 600; color: var(--accent); font-size: var(--text-lg); }
.logo-btn { background: none; border: none; padding: 0; cursor: pointer; font-weight: 600; color: var(--accent); font-size: var(--text-lg); display: flex; align-items: center; gap: 0.25rem; line-height: 1; }
.logo-btn:hover, .logo-btn:hover:not(:disabled) { background: none; color: var(--accent-hover); }
.logo-btn::after { content: '▾'; font-size: 0.65em; opacity: 0.7; }
.logo-menu { position: absolute; top: calc(100% + 6px); left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 0.25rem 0; z-index: 200; min-width: 130px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.logo-menu-item { display: block; width: 100%; background: none; border: none; color: var(--text); font-size: var(--text-sm); font-weight: 400; text-align: left; padding: 0.4rem 0.75rem; cursor: pointer; border-radius: 0; }
.logo-menu-item:hover, .logo-menu-item:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 0.75rem; }

.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  display: none;
}

.avatar-placeholder-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.me-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0;
}

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

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 200px;
  border-right: 1px solid var(--border);
  padding: 1rem;
  flex-shrink: 0;
  overflow-y: auto;
}

/* categories + channels */
.category { margin-bottom: 0.25rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

.category-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0 0.2rem;
  cursor: pointer;
  user-select: none;
}

.category-chevron { font-size: 0.6rem; color: var(--muted); flex-shrink: 0; transition: transform 0.15s; }
.category-chevron.collapsed { transform: rotate(-90deg); }

.category-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
}

.category-header:hover .category-name,
.category-header:hover .category-chevron { color: var(--text); }

.category-add {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1;
  padding: 0 0.1rem;
  opacity: 0;
  transition: opacity 0.1s;
}

.category-header:hover .category-add { opacity: 1; }
.category-add:hover { color: var(--accent); background: none !important; }

.channel-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-base);
  color: var(--muted);
  padding: 0.25rem 0.3rem;
  border-radius: 3px;
  cursor: pointer;
}

.channel-item:hover { color: var(--text); background: var(--surface-2); }
.channel-item.active { color: var(--text); background: var(--surface-2); }
.channel-item.voice { cursor: default; }

.channel-icon { flex-shrink: 0; color: var(--muted); font-size: 1.05rem; line-height: 1; }
.channel-item.active .channel-icon,
.channel-item:hover .channel-icon { color: var(--text); }

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

.channel-del, .category-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 0.85rem; font-weight: 300; line-height: 1; padding: 0 0.1rem;
  opacity: 0; transition: opacity 0.1s; flex-shrink: 0;
}
.channel-item:hover .channel-del { opacity: 1; }
.channel-del:hover, .category-del:hover, .channel-del:hover:not(:disabled), .category-del:hover:not(:disabled) { color: var(--danger); background: none !important; }
.category-header:hover .category-del { opacity: 1; }

.sidebar-footer { padding: 0.75rem 0 0.25rem; border-top: 1px solid var(--border); margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-add-btn { background: none; border: none; color: var(--muted); font-size: var(--text-sm); font-weight: 400; cursor: pointer; text-align: left; padding: 0.2rem 0.3rem; border-radius: 3px; }
.sidebar-add-btn:hover { color: var(--accent); background: none !important; }
.sidebar-invite-btn { background: none; border: none; color: var(--muted); font-size: var(--text-sm); font-weight: 400; cursor: pointer; text-align: left; padding: 0.2rem 0.3rem; border-radius: 3px; display: flex; align-items: center; gap: 0.35rem; }
.sidebar-invite-btn:hover { color: var(--accent); background: none !important; }
.sidebar-invite-btn svg { flex-shrink: 0; }

/* invite modal */
.invite-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.invite-row { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0.6rem 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.invite-code { font-size: var(--text-sm); color: var(--text); font-family: monospace; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-meta { font-size: 0.78rem; color: var(--muted); flex-shrink: 0; }
.invite-status-used { color: var(--muted); }
.invite-status-expired { color: var(--danger); }
.invite-status-fresh { color: var(--ok); }
.invite-copy-btn { background: none; border: 1px solid var(--border); color: var(--muted); font-size: 0.78rem; padding: 0.2rem 0.5rem; border-radius: 3px; cursor: pointer; flex-shrink: 0; }
.invite-copy-btn:hover { color: var(--accent); border-color: var(--accent); background: none; }
.invite-del-btn { background: none; border: none; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 0.15rem; cursor: pointer; flex-shrink: 0; }
.invite-del-btn:hover { color: var(--danger); background: none; }
.invite-empty { color: var(--muted); font-size: var(--text-sm); margin-top: 1rem; text-align: center; }
.invite-generate { width: 100%; margin-bottom: 0.25rem; }
.invite-modal-msg { font-size: var(--text-sm); margin-top: 0.75rem; min-height: 1.2rem; text-align: center; }

/* context menu */
.ctx-menu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 0.25rem 0; z-index: 200; min-width: 140px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.ctx-item { display: block; width: 100%; background: none; border: none; color: var(--text); font-size: var(--text-sm); text-align: left; padding: 0.4rem 0.85rem; cursor: pointer; }
.ctx-item:hover { background: var(--surface-2); color: var(--text); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--surface-2); }
.ctx-item:disabled { opacity: 0.4; cursor: default; }

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

.chat-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--muted);
  flex-shrink: 0;
}

.chat-header span { color: var(--text); font-weight: 500; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.8;
}

.chat-input-row {
  padding: 0.6rem 1rem 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}

.chat-input-inner {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0 0.4rem 0 0.65rem;
}

.chat-input-inner:focus-within {
  background: var(--surface);
}

.chat-input-row textarea {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  resize: none;
  overflow-y: auto;
  min-height: 2.5rem;
  max-height: 12rem;
  line-height: 1.4;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  border: none !important;
  outline: none !important;
  border-radius: 0;
  width: auto;
}

#send {
  flex-shrink: 0;
  padding: 0.3rem 0.6rem;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: var(--text-sm);
}
#send:hover:not(:disabled) { background: none !important; color: var(--text); }
#send:disabled { background: none !important; opacity: 0.3; }

/* modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  max-width: 480px;
}

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

.modal-header h2 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
  font-weight: 300;
}

.modal-close:hover { color: var(--text); background: none; }

.modal-body { padding: 1.25rem; }

.avatar-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.avatar-drop-target { position: relative; flex-shrink: 0; cursor: pointer; }
.avatar-drop-target:hover .avatar-drop-hint, .avatar-drop-target.drag-over .avatar-drop-hint { opacity: 1; }
.avatar-drop-hint {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; color: #fff; text-align: center; line-height: 1.3; letter-spacing: 0.01em;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.avatar-drop-target.drag-over .modal-avatar-img,
.avatar-drop-target.drag-over .modal-avatar-placeholder { outline: 2px solid var(--accent); outline-offset: 2px; }

.modal-avatar-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: none;
}

.modal-avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.25rem;
}

.pubkey-label { font-size: var(--text-sm); color: var(--muted); margin-bottom: 0.35rem; }

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

.pubkey {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
  flex: 1;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 400;
}

.copy-btn:hover { border-color: var(--accent); color: var(--accent); background: none; }

.modal-actions { display: flex; gap: 0.75rem; margin-top: 1.75rem; }
.modal-actions button { flex: 1; }

.modal-msg { font-size: var(--text-sm); margin-top: 1rem; min-height: 1.2rem; text-align: center; }

/* emoji picker */
.emoji-picker {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0;
  z-index: 300;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: var(--text-sm);
  text-align: left;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}
.picker-item span:first-child { font-size: 1.5em; line-height: 1; }
.picker-item.active, .picker-item:hover { background: var(--surface-2); color: var(--text); }

/* reactions */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.15rem; }
.reaction-pill {
  background: none;
  border: none;
  padding: 0.1rem 0.3rem;
  border-radius: 999px;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.reaction-pill .pe { font-size: 1em; line-height: 1; }
.reaction-pill span:last-child:not(.pe) { font-size: 0.8rem; color: var(--muted); }
.reaction-pill.own { opacity: 1; filter: drop-shadow(0 0 3px var(--accent)); }
.reaction-pill:hover, .reaction-pill:hover:not(:disabled) { opacity: 1; background: rgba(255,255,255,0.06) !important; }
.reaction-add {
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.15rem 0.4rem;
  font-size: 1.3em;
  cursor: pointer;
  color: var(--muted);
  display: none;
  line-height: 1.6;
}
.msg-reactions:has(.reaction-pill) .reaction-add { display: inline-flex; }
.reaction-add:hover, .reaction-add:hover:not(:disabled) { background: rgba(255,255,255,0.06) !important; filter: none; }

/* react input */
.react-input-wrap { padding: 0.2rem 0 0.1rem 56px; }
.react-input { width: 150px; padding: 0.25rem 0.5rem; font-size: var(--text-sm); }

/* reply bar */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.25rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--muted);
  flex-shrink: 0;
}
.reply-bar-label { color: var(--accent); flex-shrink: 0; }
.reply-bar-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-cancel { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0; flex-shrink: 0; }
.reply-bar-cancel:hover { color: var(--text); background: none; }

.typing-bar { height: 1.3rem; padding: 0 1.25rem; display: flex; align-items: center; }
.typing-text { font-size: 0.75rem; color: var(--muted); font-style: italic; }

/* reply quote in messages */
.msg-reply {
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0;
  padding: 0.2rem 0.5rem;
  margin-bottom: 0.25rem;
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-reply:hover { color: var(--text); }
.msg-reply-author { color: var(--accent); font-weight: 500; margin-right: 0.35rem; }

/* messages */
.msg-row { display: flex; gap: 1rem; padding: 1.25rem 0 0.1rem; border-radius: 3px; }
.msg-row.consecutive { padding: 0.05rem 0; }
.msg-row:hover { background: rgba(255,255,255,0.025); margin: 0 -1.25rem; padding-left: 1.25rem; padding-right: 1.25rem; }
.msg-avatar-col { width: 40px; flex-shrink: 0; padding-top: 0.15rem; }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; }
.msg-avatar-placeholder { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; color: var(--muted); }
.msg-avatar-spacer { width: 40px; flex-shrink: 0; }
.msg-body { flex: 1; min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.2rem; }
.msg-author { font-weight: 500; color: var(--accent); font-size: var(--text-base); }
.msg-author.own { color: var(--text); }
.msg-ts { font-size: 0.72rem; color: var(--muted); }
.msg-text { font-size: var(--text-base); color: var(--text); line-height: 1.5; word-break: break-word; }
.msg-text p { margin: 0 0 0.4em; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text strong { font-weight: 600; }
.msg-text em { font-style: italic; }
.msg-text code { font-family: monospace; background: var(--surface-2); border-radius: 3px; padding: 0.1em 0.35em; font-size: 0.88em; }
.msg-text pre { background: var(--surface-2); border-radius: 6px; padding: 0.75rem 1rem; overflow-x: auto; margin: 0.4em 0; }
.msg-text pre code { background: none; padding: 0; font-size: 0.85em; }
.msg-text blockquote { border-left: 3px solid var(--border); margin: 0.4em 0; padding-left: 0.75rem; color: var(--muted); }
.msg-text ul, .msg-text ol { margin: 0.4em 0; padding-left: 1.5em; }
.msg-text li { margin: 0.15em 0; }
.msg-text h1, .msg-text h2, .msg-text h3 { font-weight: 600; margin: 0.5em 0 0.25em; line-height: 1.3; }
.msg-text h1 { font-size: 1.2em; }
.msg-text h2 { font-size: 1.1em; }
.msg-text h3 { font-size: 1em; }
.msg-edited { font-size: 0.72rem; color: var(--muted); margin-left: 0.25rem; }

.edit-input { background: var(--surface-2); border: 1px solid var(--accent); border-radius: 4px; color: var(--text); font-size: var(--text-base); padding: 0.35rem 0.4rem; width: 100%; outline: none; font-family: inherit; resize: none; overflow-y: hidden; line-height: 1.4; }

.unread-divider { display: flex; align-items: center; gap: 0.5rem; margin: 0.75rem 0; font-size: 0.7rem; color: var(--muted); }
.unread-divider::before, .unread-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.members-panel { width: 160px; flex-shrink: 0; border-left: 1px solid var(--border); padding: 1rem 0.75rem; overflow-y: auto; }
@media (max-width: 768px) { .members-panel { display: none; } }
.online-section-title { font-size: 0.65rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.online-member { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; overflow: hidden; cursor: pointer; border-radius: 4px; }
.online-member:hover { background: var(--surface-2); }
.online-member-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-base); color: var(--text); }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #4caf50; flex-shrink: 0; position: absolute; bottom: 0; right: 0; border: 1px solid var(--surface); }
.online-member.offline { opacity: 0.45; }
.online-avatar-wrap { position: relative; flex-shrink: 0; width: 34px; height: 34px; }
.online-avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: block; }
.online-avatar-placeholder { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; color: #fff; }

/* mobile sidebar */
.hamburger { display: none; background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.2rem; line-height: 1; }
.hamburger:hover { color: var(--text); background: none; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; }
@media (max-width: 640px) {
  .hamburger { display: flex; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100dvh; z-index: 50; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
}

/* unread dot on channel */
.channel-unread { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-left: auto; }

/* chat header with search */
.chat-header { display: flex; align-items: center; gap: 0.5rem; }
.chat-header-prefix { color: var(--muted); font-weight: 600; font-size: 1.1em; flex-shrink: 0; }
.chat-header-name { flex-shrink: 0; font-weight: 600; }
.chat-header-desc { flex: 1; min-width: 0; color: var(--muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.7; }
.chat-header-desc:not(:empty)::before { content: '•'; margin: 0 0.5rem; }
.chat-header-desc.admin-editable { cursor: pointer; }
.chat-header-desc.admin-editable:empty::before { content: 'add description…'; opacity: 0.4; margin: 0; padding-left: 0.25rem; }
.search-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.2rem; display: flex; line-height: 1; }
.search-btn:hover { color: var(--accent); background: none; }
.search-bar { display: none; flex: 1; align-items: center; gap: 0.5rem; }
.search-bar.open { display: flex; }
.search-bar input { flex: 1; margin-bottom: 0; padding: 0.3rem 0.5rem; font-size: var(--text-sm); }
.search-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.1rem 0.25rem; font-size: 1rem; line-height: 1; }
.search-close:hover { color: var(--text); background: none; }

/* search results */
.search-results { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.search-result { background: var(--surface-2); border-radius: 4px; padding: 0.5rem 0.75rem; cursor: pointer; }
.search-result:hover { border-color: var(--accent); background: var(--surface); }
.search-result-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.search-result-text { font-size: var(--text-sm); color: var(--text); white-space: pre-wrap; word-break: break-word; }
.search-result-text mark { background: rgba(168,142,120,0.3); color: var(--text); border-radius: 2px; }
.search-empty { color: var(--muted); font-size: var(--text-sm); text-align: center; margin-top: 2rem; }

/* member profile popover */
.member-popover {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem; z-index: 300; width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.member-popover-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; display: block; }
.member-popover-placeholder { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #fff; }
.member-popover-name { font-weight: 600; color: var(--text); margin: 0.5rem 0 0.2rem; }
.member-popover-key { font-size: 0.7rem; color: var(--muted); font-family: monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.member-popover-key:hover { color: var(--accent); }
.member-popover-actions { position: absolute; top: 0.6rem; right: 0.6rem; display: flex; gap: 0.3rem; }
.member-popover-action { background: none; border: none; cursor: pointer; color: var(--muted); padding: 0.35rem; border-radius: 4px; display: flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; }
.member-popover-action:hover, .member-popover-action:hover:not(:disabled) { background: none !important; color: var(--text); }
.member-popover-action.danger:hover, .member-popover-action.danger:hover:not(:disabled) { background: none !important; color: #e57373; }

/* upload button */
.upload-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.2rem 0.4rem; display: flex; align-items: center; flex-shrink: 0; line-height: 1; }
.upload-btn:hover { color: var(--accent); background: none !important; }
.upload-btn:disabled { opacity: 0.4; cursor: default; }
.upload-btn.recording { color: #e57373; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.msg-audio-player { display: inline-flex; align-items: center; gap: 0.6rem; margin-top: 0.35rem; background: var(--surface-2); border-radius: 20px; padding: 0.35rem 0.9rem 0.35rem 0.5rem; width: 320px; max-width: 100%; }
.audio-play-btn { background: none; border: none; color: var(--text); cursor: pointer; padding: 0; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; outline: none; }
.audio-play-btn:hover { color: var(--accent); }
.audio-scrub { flex: 1; height: 20px; display: flex; align-items: center; cursor: pointer; position: relative; min-width: 0; }
.audio-scrub-track { position: absolute; left: 0; right: 0; height: 4px; background: var(--border); border-radius: 2px; pointer-events: none; }
.audio-scrub-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; pointer-events: none; }
.audio-scrub-thumb { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); transform: translate(-50%, -50%); pointer-events: none; left: 0%; opacity: 0; transition: opacity 0.1s; }
.audio-scrub:hover .audio-scrub-thumb { opacity: 1; }
.audio-time { font-size: 0.68rem; color: var(--text); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.audio-dl-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; outline: none; }
.audio-dl-btn:hover { color: var(--accent); }

/* drag overlay */
.chat { position: relative; }
.drag-overlay { display: none; position: absolute; inset: 0; background: rgba(168,142,120,0.12); border: 2px dashed var(--accent); border-radius: 4px; z-index: 10; pointer-events: none; align-items: center; justify-content: center; font-size: 1rem; color: var(--accent); }
.chat.drag-over .drag-overlay { display: flex; }

/* inline image in messages */
.msg-img { display: block; max-width: 100%; max-height: 400px; border-radius: 4px; margin-top: 0.35rem; cursor: zoom-in; object-fit: contain; }

/* message hover actions */
.msg-row { position: relative; }
#voice-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem; background: var(--surface); border-top: 1px solid var(--accent);
  z-index: 200; gap: 1rem; min-height: 56px;
}
.voice-bar-left { display: flex; align-items: center; gap: 0.4rem; min-width: 0; flex: 1; }
.voice-bar-channel { font-size: 0.72rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.voice-bar-avatars { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.voice-avatar-wrap { position: relative; flex-shrink: 0; }
.voice-rec-dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: #e57373; border: 1.5px solid var(--bg); animation: pulse 1s ease-in-out infinite; }
.voice-avatar, .voice-avatar-placeholder {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 2px solid transparent; transition: border-color 0.15s;
}
.voice-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; color: #fff;
}
.voice-avatar-wrap.speaking .voice-avatar,
.voice-avatar-wrap.speaking .voice-avatar-placeholder { border-color: var(--av-color, var(--accent)); box-shadow: 0 0 6px var(--av-color, var(--accent)); }
.voice-avatar-name { font-size: 0.65rem; color: var(--muted); text-align: center; max-width: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.voice-bar-controls { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: center; }
.voice-ctrl-btn { padding: 0.3rem 0.6rem; display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; }
.voice-ctrl-btn.muted { color: var(--muted); }
#voice-rec-btn { color: var(--muted); }
#voice-rec-btn.recording { color: #e57373; animation: pulse 1s ease-in-out infinite; }
.voice-device-menu { position: absolute; bottom: calc(100% + 6px); right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 -4px 12px rgba(0,0,0,0.4); min-width: 220px; z-index: 300; overflow: hidden; }
.voice-device-item { padding: 0.5rem 0.75rem; font-size: 0.8rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.voice-device-item:hover { background: var(--surface-2); }
.voice-device-item.active { color: var(--accent); }
.voice-dsp-section { padding: 0.35rem 0.75rem 0.25rem; font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.voice-dsp-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.75rem; font-size: 0.8rem; color: var(--fg); cursor: pointer; white-space: nowrap; user-select: none; }
.voice-dsp-row:hover { background: var(--surface-2); }
.voice-dsp-row input[type=checkbox] { accent-color: var(--accent); cursor: pointer; width: 13px; height: 13px; flex-shrink: 0; margin: 0; }
.voice-dsp-slider-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.75rem; font-size: 0.8rem; color: var(--fg); }
.voice-dsp-slider-row input[type=range] { flex: 1; accent-color: var(--accent); }
.voice-level-wrap { padding: 0.25rem 0.75rem 0.1rem; }
.voice-level-track { height: 5px; background: var(--border); border-radius: 3px; position: relative; }
.voice-level-fill { height: 100%; width: 0; background: var(--muted); border-radius: 3px; transition: width 0.06s linear; }
.voice-level-gate { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg); border-radius: 1px; transform: translateX(-50%); opacity: 0.7; pointer-events: none; }
.voice-vol-popover { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 -4px 12px rgba(0,0,0,0.4); padding: 0.5rem 0.75rem; z-index: 400; min-width: 130px; }
.voice-vol-popover label { font-size: 0.75rem; color: var(--muted); display: block; margin-bottom: 0.4rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-vol-popover input[type=range] { width: 100%; accent-color: var(--accent); }
.voice-vol-popover .vol-val { font-size: 0.75rem; color: var(--accent); text-align: center; display: block; margin-top: 0.25rem; }
.voice-avatar-wrap.peer { cursor: pointer; }
.voice-video { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.voice-avatar-wrap.has-video .voice-avatar,
.voice-avatar-wrap.has-video .voice-avatar-placeholder { display: none; }
.voice-avatar-wrap.has-video { width: 120px; cursor: pointer; padding-bottom: 4px; }
.voice-avatar-wrap.video-hidden .voice-video { display: none; }
.voice-avatar-wrap.video-hidden .voice-avatar,
.voice-avatar-wrap.video-hidden .voice-avatar-placeholder { display: block !important; }
#voice-cam-btn.active { color: var(--accent); }

/* floating avatar cluster */
#voice-float { display: none; }

/* video tile name overlay */
.voice-avatar-wrap { overflow: visible; }
.voice-avatar-wrap.has-video .voice-avatar-name { display: none; }
.voice-video-overlay {
  position: absolute; bottom: -12px; left: -12px;
  display: flex; align-items: center; gap: 1px;
  pointer-events: none; z-index: 2;
}
.voice-video-mini-av {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 1.5px solid var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 600; color: #fff;
}
.voice-video-name-tag {
  font-size: 0.62rem; color: rgba(255,255,255,0.92); white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,1);
  background: rgba(0,0,0,0.45); padding: 1px 5px; border-radius: 3px;
}

/* grid overlay */
#voice-grid {
  position: fixed; inset: 0; background: rgba(12,12,12,0.96);
  z-index: 350; display: none; flex-direction: column;
}
#voice-grid.open { display: flex; }
#vg-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#vg-ch { font-weight: 600; color: var(--accent); flex: 1; font-size: 0.9rem; }
.vg-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.3rem; display: flex; align-items: center; }
.vg-btn:hover, .vg-btn:hover:not(:disabled) { color: var(--text); background: none !important; }
#vg-tiles {
  flex: 1; display: grid;
  grid-template-columns: repeat(var(--vg-cols, 1), 1fr);
  grid-auto-rows: 1fr;
  gap: 8px; padding: 12px; overflow: hidden; min-height: 0;
}
.vg-tile {
  position: relative; border-radius: 10px; overflow: hidden;
  background: var(--surface); border: 2px solid transparent;
  transition: border-color 0.1s; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.vg-tile.speaking { border-color: var(--av-color, var(--accent)); box-shadow: 0 0 12px var(--av-color, var(--accent)); }
.vg-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vg-avatar { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 600; color: #fff; }
.vg-name { position: absolute; bottom: 0; left: 0; right: 0; padding: 0.25rem 0.6rem; font-size: 0.72rem; background: rgba(0,0,0,0.65); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-item.voice .voice-members { font-size: 0.7rem; color: var(--muted); margin-left: auto; margin-right: 0.25rem; }
body.in-voice { height: calc(100dvh - var(--voice-bar-h, 72px)); }
.load-more { width: 100%; padding: 8px; margin-bottom: 8px; color: var(--muted); font-size: 0.8rem; background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.load-more:hover { color: var(--fg); border-color: var(--muted); }
.load-more:disabled { opacity: 0.5; cursor: default; }
.msg-actions { display: none; position: absolute; top: -1px; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.35); flex-direction: row; gap: 0; z-index: 10; }
.msg-row:hover .msg-actions { display: flex; }
.msg-row:has(.edit-input) .msg-actions { display: none !important; }
.msg-action-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0.35rem 0.45rem; display: flex; align-items: center; min-width: 2rem; justify-content: center; font-size: 1.2rem; }
.msg-action-btn svg { width: 19px; height: 19px; }
.msg-action-btn:first-child { border-radius: 8px 0 0 8px; }
.msg-action-btn:last-child { border-radius: 0 8px 8px 0; }
.msg-action-btn:only-child { border-radius: 8px; }
.msg-action-btn:hover { color: var(--text); background: var(--surface-2); }
.msg-action-btn.danger:hover { color: #e57373; background: var(--surface-2); }

/* OG preview card */
.og-card { display: flex; gap: 0.75rem; margin-top: 0.5rem; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 4px; padding: 0.5rem 0.75rem; background: var(--surface-2); max-width: 420px; overflow: hidden; text-decoration: none; }
.og-card:hover { border-left-color: var(--text); }
.og-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.og-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.og-site { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.og-title { font-size: var(--text-sm); font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.og-desc { font-size: 0.72rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* image lightbox */
.img-lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 500; align-items: center; justify-content: center; cursor: zoom-out; }
.img-lightbox.open { display: flex; }
.img-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; object-fit: contain; box-shadow: 0 8px 40px rgba(0,0,0,0.6); }
.msg-text a { color: var(--accent); text-decoration: underline; word-break: break-all; }

.custom-emoji { width: 2.5em; height: 2.5em; vertical-align: -0.65em; display: inline-block; object-fit: contain; }

/* @mention */
.mention { color: var(--accent); font-weight: 500; }
.mention-picker { position: absolute; bottom: 100%; left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; min-width: 180px; max-height: 180px; overflow-y: auto; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.mention-picker-item { padding: 0.4rem 0.75rem; cursor: pointer; font-size: var(--text-sm); color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.mention-picker-item:hover, .mention-picker-item.active { background: var(--surface-2); color: var(--accent); }
.chat-input-row { position: relative; }

#voice-bar.ice-failed { border-top-color: #e57373; }
#voice-bar.ice-failed::before { content: 'connection failed'; position: absolute; top: -1.4rem; left: 50%; transform: translateX(-50%); background: #e57373; color: #fff; font-size: 0.7rem; padding: 0.1rem 0.5rem; border-radius: 3px 3px 0 0; white-space: nowrap; pointer-events: none; }

@media (max-width: 540px) {
  #voice-bar { padding: 0.4rem 0.6rem; gap: 0.5rem; }
  .voice-bar-controls { gap: 0.25rem; }
  .voice-ctrl-btn { padding: 0.25rem 0.35rem; }
  .voice-device-menu { right: 0; left: auto; max-width: calc(100vw - 0.75rem); }
}
