:root {
  --bg-lowest: #1e1f22;
  --bg-low: #2b2d31;
  --bg-mid: #313338;
  --bg-high: #383a40;
  --bg-highest: #404249;
  --bg-modifier: rgba(79, 84, 92, 0.32);
  --text: #dbdee1;
  --text-muted: #949ba4;
  --text-strong: #f2f3f5;
  --header: #f2f3f5;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #23a559;
  --red: #ed4245;
  --yellow: #f0b232;
  --mention-bg: rgba(88, 101, 242, 0.3);
  --mention-me: rgba(240, 178, 50, 0.18);
  --radius: 8px;
  --font: "Noto Sans", "gg sans", "Segoe UI", sans-serif;
  --scrollbar-size: 8px;
  --scrollbar-thumb: rgba(79, 84, 92, 0.72);
  --scrollbar-thumb-hover: rgba(121, 127, 138, 0.9);
  --scrollbar-track: transparent;
  --ui-scale: 1;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg-lowest);
  color: var(--text);
  overflow: hidden;
}
/* Thin themed scrollbars (Firefox + Chromium/WebKit) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}
*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  min-height: 32px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}
.message-list,
.members,
.nav-section,
.admin-panels,
.admin-main,
.admin-media-list,
.emoji-picker-scroll,
.qs-results,
.modal-card,
.media-drawer,
#channel-list,
#dm-list {
  scrollbar-gutter: stable;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
ul { list-style: none; margin: 0; padding: 0; }

/* Auth */
.auth-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(88, 101, 242, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(235, 69, 158, 0.2), transparent 50%),
    linear-gradient(160deg, #1a1b1e 0%, #111214 100%);
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  background: var(--bg-mid);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.logo-mark {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 16px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 1.2rem;
}
.auth-brand h1 { margin: 0; color: var(--header); font-size: 1.6rem; }
.auth-tagline {
  margin: 8px 0 0; color: var(--text-muted); font-size: 0.95rem;
}
.auth-security-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.auth-security-label {
  margin: 0 0 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}
.auth-security {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 0; text-align: left;
}
.auth-security li {
  display: grid; grid-template-columns: auto 1fr; gap: 12px;
  align-items: start; padding: 11px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.8rem; line-height: 1.35; color: var(--text-muted);
}
.auth-security li:last-child { border-bottom: none; padding-bottom: 2px; }
.auth-security li > div { display: grid; gap: 2px; min-width: 0; }
.auth-security strong {
  color: var(--text-strong); font-weight: 650; font-size: 0.82rem;
}
.auth-security li > div > span { color: var(--text-muted); }
.auth-sec-icon {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: #3ba55d;
  box-shadow: inset 0 0 0 1px rgba(59, 165, 93, 0.28);
  flex-shrink: 0; margin-top: 1px;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 10px; border-radius: var(--radius);
  background: var(--bg-low); color: var(--text-muted); font-weight: 600;
}
.auth-tab.active { background: var(--accent); color: #fff; }
#auth-form { display: grid; gap: 14px; }
#auth-form label { display: grid; gap: 6px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
#auth-form input {
  padding: 12px; border-radius: var(--radius); border: none;
  background: var(--bg-lowest); color: var(--text-strong);
}
#auth-submit {
  margin-top: 8px; padding: 12px; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-weight: 600;
}
#auth-submit:hover { background: var(--accent-hover); }
.auth-error { color: var(--red); margin: 0; font-size: 0.9rem; }
#auth-submit:disabled { opacity: 0.6; cursor: wait; }
.secure-badge {
  background: rgba(35, 165, 89, 0.2) !important;
  color: #23a559 !important;
}
.remember-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; font-weight: 500; text-transform: none;
  color: var(--text); cursor: pointer; user-select: none;
}
.remember-row input {
  width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
}

/* App shell */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 72px 240px minmax(0, 1fr) 240px;
  min-width: 0;
  overflow: hidden;
  zoom: var(--ui-scale, 1);
}
.app.members-hidden:not(.view-dms),
.app.voice-no-members:not(.view-dms) {
  grid-template-columns: 72px 240px minmax(0, 1fr);
}
.app.members-hidden:not(.view-dms) .members,
.app.voice-no-members:not(.view-dms) .members {
  display: none !important;
}
.app.view-dms #btn-members-toggle,
.app.voice-no-members #btn-members-toggle,
.app.voice-no-members #btn-mobile-members {
  display: none !important;
}
.guild-rail {
  background: var(--bg-lowest);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 8px;
}
.guild-sep {
  width: 32px;
  height: 2px;
  border-radius: 1px;
  background: var(--bg-highest);
  margin: 4px 0;
}
.guild-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-mid); color: var(--text-strong); font-weight: 800;
  transition: border-radius 0.15s, background 0.15s, color 0.15s;
  overflow: hidden; padding: 0;
  display: grid; place-items: center;
  position: relative;
}
.guild-btn.home-btn {
  background: var(--bg-mid);
  color: var(--text);
  overflow: visible;
}
.guild-btn.home-btn.active,
.guild-btn.home-btn:hover {
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
}
.home-btn-icon { display: block; }
.guild-unread-badge {
  position: absolute;
  right: -2px; bottom: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font-size: 0.68rem; font-weight: 800;
  display: inline-grid; place-items: center;
  line-height: 1;
  border: 3px solid var(--bg-lowest);
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  pointer-events: none;
  z-index: 2;
}
.guild-unread-badge.is-hidden { display: none !important; }
.guild-btn.home-btn.has-unread {
  color: #fff;
}
.guild-btn.active, .guild-btn:hover {
  border-radius: 16px; background: var(--accent); color: #fff;
}
.guild-btn.has-icon {
  background: transparent;
}
.guild-btn.has-icon.active, .guild-btn.has-icon:hover {
  background: transparent;
}
.guild-btn img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.guild-btn-fallback { line-height: 1; }
.guild-btn.has-icon .guild-btn-fallback { display: none; }
.server-icon-row {
  display: flex; align-items: center; gap: 14px; margin-top: 8px;
}
.server-icon-preview {
  pointer-events: none; flex-shrink: 0;
}
.server-icon-actions {
  display: grid; gap: 6px; font-size: 0.85rem;
}
.server-icon-actions input[type="file"] { font-size: 0.8rem; max-width: 100%; }

.sidebar {
  background: var(--bg-low);
  display: flex; flex-direction: column; min-height: 0;
  --status-platform: var(--bg-low);
}
.sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-body.is-hidden { display: none !important; }
.sidebar-body .nav-section { flex: 1; overflow: auto; }
.dm-section { padding-top: 8px; }
.dm-nav-list { display: flex; flex-direction: column; gap: 1px; }
.dm-item-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
  position: relative;
}
.dm-item {
  flex: 1;
  min-width: 0;
  display: flex !important;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 8px !important;
  border-radius: 4px;
}
.dm-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}
.dm-item .avatar,
.dm-item .dm-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  border-radius: 50%;
}
.dm-item .avatar.premium { box-shadow: none; }
.dm-avatar-wrap .member-status-dot.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border: 3px solid var(--bg-low);
  box-sizing: content-box;
  margin: 0;
}
.dm-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}
.dm-item-wrap .dm-close {
  opacity: 0;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.dm-item-wrap:hover .dm-close,
.dm-item-wrap:focus-within .dm-close {
  opacity: 1;
}
.dm-item-wrap .dm-close:hover {
  background: var(--bg-modifier);
  color: var(--text-strong);
}
.dm-empty-hint {
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.35;
}
.dm-empty-state {
  position: absolute;
  inset: 48px 0 0;
  display: grid;
  place-items: center;
  background: var(--bg-mid);
  z-index: 5;
  padding: 24px;
}
.chat.has-dm-empty .composer-wrap,
.chat.has-dm-empty .typing,
.chat.has-dm-empty .message-wrap {
  visibility: hidden;
  pointer-events: none;
}
.dm-empty-card.is-denied h3 {
  color: var(--danger, #f23f42);
}
.dm-empty-card.is-denied .dm-empty-icon {
  color: var(--danger, #f23f42);
}

.feature-denied {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 24px;
}
.feature-denied-card {
  background: var(--bg-elev, #2b2d31);
  color: var(--text, #dbdee1);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 20px 22px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.feature-denied-card strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 8px;
  color: var(--danger, #f23f42);
}
.feature-denied-card p {
  margin: 0 0 16px;
  color: var(--text-muted, #b5bac1);
  line-height: 1.4;
}
.dm-empty-card {
  text-align: center;
  max-width: 360px;
  color: var(--text-muted);
}
.dm-empty-icon {
  width: 80px; height: 80px; margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-low);
  color: var(--text);
  display: grid; place-items: center;
}
.dm-empty-card h3 {
  margin: 0 0 8px;
  color: var(--header);
  font-size: 1.5rem;
}
.dm-empty-card p { margin: 0; font-size: 0.95rem; line-height: 1.4; }

.app.view-dms {
  grid-template-columns: 72px 240px minmax(0, 1fr);
}
.app.view-dms .members { display: none !important; }
.app.view-dms #btn-mobile-members { display: none !important; }

.sidebar-header {
  height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2); font-weight: 700;
}
.sidebar-header.is-hidden { display: none !important; }
.sidebar-header h2 { margin: 0; font-size: 1rem; flex: 1; }
.irc-badge {
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.04em;
  background: #3ba55d; color: #fff; padding: 2px 6px; border-radius: 4px;
}
.nav-section { padding: 16px 8px 8px; overflow: auto; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 6px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted);
}
.channels-toolbar-actions { display: flex; align-items: center; gap: 2px; }
.nav-list { display: grid; gap: 2px; }
.channel-nav { gap: 10px; }
.channel-category { display: grid; gap: 1px; }
.category-header {
  display: flex; align-items: center; gap: 4px;
  width: 100%; padding: 6px 6px 4px 4px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.02em; text-align: left;
  border-radius: 4px;
}
.category-header:hover { color: var(--text); }
.category-chevron {
  width: 12px; height: 12px; flex-shrink: 0;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.75;
  transition: transform 0.12s ease;
}
.channel-category.is-collapsed .category-chevron { transform: rotate(-90deg); }
.category-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.category-channels { display: grid; gap: 1px; }
.cat-unread { margin-left: auto; }

/* Discord-style channel/category reorder */
#channel-list.can-reorder .channel-row.is-draggable,
#channel-list.can-reorder .category-header[draggable="true"] { cursor: grab; }
#channel-list.can-reorder .channel-row.is-draggable:active,
#channel-list.can-reorder .category-header[draggable="true"]:active { cursor: grabbing; }
#channel-list.is-reordering .channel-row.is-dragging,
#channel-list.is-reordering .channel-category.is-dragging { opacity: 0.35; }
#channel-list .channel-row,
#channel-list .channel-category,
#channel-list .category-channels {
  position: relative;
}
#channel-list .channel-row.drag-over-before::before,
#channel-list .channel-category.drag-over-before::before,
#channel-list .channel-row.drag-over-after::after,
#channel-list .channel-category.drag-over-after::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent, #5865f2);
  pointer-events: none;
  z-index: 2;
}
#channel-list .channel-row.drag-over-before::before,
#channel-list .channel-category.drag-over-before::before { top: -1px; }
#channel-list .channel-row.drag-over-after::after,
#channel-list .channel-category.drag-over-after::after { bottom: -1px; }
#channel-list .category-channels.drag-over-into {
  outline: 1px dashed var(--accent, #5865f2);
  outline-offset: -1px;
  border-radius: 4px;
  min-height: 28px;
}
.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 4px; color: var(--text-muted);
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-modifier); color: var(--text); }
.nav-item.active { background: var(--bg-modifier); color: var(--text-strong); }
.nav-item .hash { font-weight: 700; opacity: 0.7; }
.pm-status {
  margin: 0 8px 8px; font-size: 0.75rem; color: var(--text-muted); line-height: 1.35;
}

.user-panel {
  position: relative;
  background: #232428; padding: 6px 8px;
  display: flex; align-items: center; gap: 4px;
  min-height: 52px;
  --status-platform: #232428;
}
.user-panel-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 4px;
  background: transparent; color: inherit; text-align: left;
  border: none; cursor: pointer;
}
.user-panel-main:hover { background: var(--bg-modifier); }
.user-panel-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.user-panel .avatar-wrap { position: relative; flex-shrink: 0; }
.user-panel .avatar { width: 32px; height: 32px; }
.user-meta { flex: 1; min-width: 0; display: grid; line-height: 1.15; }
.user-meta strong {
  font-size: 0.85rem; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-status-label {
  font-size: 0.7rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-transform: none;
}

.user-menu {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px);
  background: var(--bg-low); border: 1px solid var(--bg-highest);
  border-radius: 8px; padding: 6px; z-index: 40;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  display: grid; gap: 2px;
}
.user-menu[hidden], .user-menu.is-hidden { display: none !important; }
.user-menu-section { display: grid; gap: 2px; }
.user-menu-label {
  padding: 6px 10px 4px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-muted);
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 4px; text-align: left;
  background: transparent; color: var(--text); font-size: 0.875rem; font-weight: 500;
  border: none; cursor: pointer;
}
.user-menu-item:hover { background: var(--accent); color: #fff; }
.user-menu-item:hover .status-dot { border-color: transparent; }
.user-menu-item:hover .status-badge { background: transparent; }
.user-menu-item:hover .user-menu-hint { color: rgba(255,255,255,0.75); }
.user-menu-item.active { background: rgba(88,101,242,0.18); }
.user-menu-item .status-dot {
  position: static; width: 10px; height: 10px; border: none; flex-shrink: 0;
}
.user-menu-item .status-badge {
  position: static;
  width: 16px;
  height: 16px;
  background: transparent;
  flex-shrink: 0;
}
.user-menu-item-label { flex: 1; }
.user-menu-hint { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); }
.user-menu-sep {
  height: 1px; background: var(--bg-highest); margin: 4px 6px;
}
.user-menu-scale {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 4px 8px 6px;
}
.user-menu-scale-btn {
  width: 32px; height: 32px; border-radius: 4px;
  background: var(--bg-highest); color: var(--text-strong);
  font-size: 1.15rem; font-weight: 700; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  border: none;
}
.user-menu-scale-btn:hover:not(:disabled) { background: var(--accent); color: #fff; }
.user-menu-scale-btn:disabled { opacity: 0.35; cursor: default; }
.user-menu-scale-value {
  flex: 1; text-align: center;
  font-size: 0.85rem; font-weight: 700; color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.user-menu-logout { margin: 0; }
.user-menu-item.danger { color: #fff; background: var(--red); }
.user-menu-item.danger:hover { background: #a12828; color: #fff; }
.msg-day-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 16px 4px; user-select: none;
}
.msg-day-divider-line {
  flex: 1; height: 1px; background: var(--bg-highest);
}
.msg-day-divider-label {
  flex-shrink: 0;
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.message .time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; color: #fff;
  flex-shrink: 0; overflow: hidden;
}
.avatar.has-img { padding: 0; }
.avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.icon-btn {
  width: 32px; height: 32px; border-radius: 4px; color: var(--text-muted);
  display: inline-grid; place-items: center; flex-shrink: 0;
  position: relative;
}
.icon-btn:hover { background: var(--bg-modifier); color: var(--text); }
.ui-icon {
  display: block; flex-shrink: 0;
  stroke: currentColor; fill: none;
  pointer-events: none;
}
.attach-btn .ui-icon, .send-btn .ui-icon, .msg-act .ui-icon { display: block; }
.file-chip .ui-icon { flex-shrink: 0; opacity: 0.85; }
.dm-close { display: inline-grid; place-items: center; }
.send-btn { color: var(--accent); }
.send-btn:hover { color: var(--accent-hover); }

.chat {
  background: var(--bg-mid);
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  position: relative;
  overflow-x: clip;
  overflow-y: visible;
}
.chat-header {
  height: 48px; padding: 0 16px; display: flex; align-items: center;
  justify-content: space-between; box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  min-width: 0; gap: 8px;
}
.chat-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; overflow: hidden; }
.chat-title h3 {
  margin: 0; font-size: 1rem; color: var(--header);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#target-hash { font-weight: 700; color: var(--text-muted); }
#target-hash.is-thread { letter-spacing: -0.04em; }
.chat-actions { display: flex; align-items: center; gap: 2px; }
.header-count {
  position: absolute; top: 2px; right: 1px;
  min-width: 14px; height: 14px; padding: 0 4px;
  border-radius: 8px; font-size: 0.62rem; font-weight: 800;
  line-height: 14px; background: var(--accent); color: #fff;
}
.header-pop {
  position: absolute; top: 52px; right: 12px;
  width: min(420px, calc(100% - 24px));
  max-height: min(70vh, 520px);
  display: flex; flex-direction: column;
  background: var(--bg-low);
  border: 1px solid var(--bg-highest);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  z-index: 35; overflow: hidden;
}
.header-pop[hidden], .header-pop.is-hidden { display: none !important; }
.header-pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 10px; box-shadow: 0 1px 0 var(--bg-highest);
}
.header-pop-head h3 { margin: 0; font-size: 0.95rem; color: var(--header); }
.header-pop-body { overflow: auto; padding: 8px; display: grid; gap: 6px; }
.header-pop-empty {
  margin: 24px 12px; text-align: center; color: var(--text-muted); font-size: 0.9rem;
}
.pin-item, .thread-pop-item {
  display: grid; gap: 4px; width: 100%;
  padding: 10px; border-radius: 6px; text-align: left;
  background: var(--bg-mid); color: var(--text); border: none; cursor: pointer;
}
.pin-unpin { margin-left: auto; }
.pin-item:hover, .thread-pop-item:hover { background: var(--bg-modifier); }
.pin-item-head { display: flex; align-items: center; gap: 8px; }
.pin-item-head strong { flex: 1; font-size: 0.85rem; }
.pin-item-head span { font-size: 0.75rem; color: var(--text-muted); }
.pin-item p, .thread-pop-item span {
  margin: 0; font-size: 0.85rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thread-pop-item strong { font-size: 0.9rem; color: var(--header); }
.thread-pop-item.is-archived strong { opacity: 0.65; }
.thread-nav {
  list-style: none; margin: 0; padding: 2px 0 8px 22px;
  display: grid; gap: 1px;
}
.thread-item { padding: 5px 8px; font-size: 0.88rem; }
.thread-hash { color: var(--text-muted); font-weight: 700; }
.thread-item.is-archived { opacity: 0.6; }
.channel-row.has-open-thread > .nav-item:not(.active) { color: var(--text); }
.thread-banner {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--bg-highest);
  background: var(--bg-mid);
}
.thread-back {
  background: none; border: none; color: var(--text-muted);
  padding: 0; cursor: pointer; font-size: 0.8rem; font-weight: 600;
}
.thread-back:hover { color: var(--header); text-decoration: underline; }
.thread-banner-title { margin-top: 6px; font-size: 1.15rem; font-weight: 800; color: var(--header); }
.thread-banner-preview { margin: 6px 0 0; color: var(--text-muted); font-size: 0.9rem; }
.thread-archived {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  background: var(--bg-highest); color: var(--text-muted);
  padding: 2px 6px; border-radius: 4px; margin-left: 8px; vertical-align: middle;
}
.thread-reply-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 4px 0;
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 0.85rem; font-weight: 600;
}
.thread-reply-link:hover { text-decoration: underline; }
.thread-reply-icon { color: var(--text-muted); font-weight: 800; }
.message.is-pinned { box-shadow: inset 3px 0 0 var(--accent); }
#msg-input:disabled { opacity: 0.55; cursor: not-allowed; }
.divider { width: 1px; height: 20px; background: var(--bg-highest); }
#target-topic {
  margin: 0; color: var(--text-muted); font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conn-status {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  color: var(--yellow);
}
.conn-status.ok { color: var(--green); }
.conn-status.bad { color: var(--red); }

.message-list {
  flex: 1; min-width: 0; min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 16px 0;
  display: flex; flex-direction: column; gap: 2px;
  /* Prevent browser scroll-anchoring from jumping to growing videos/images */
  overflow-anchor: none;
}
.message {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px;
  padding: 6px 12px; border-radius: 4px; position: relative;
  max-width: 100%;
  min-width: 0;
  overflow-anchor: none;
}
.message:hover { background: rgba(0,0,0,0.08); }
.message.mention-highlight { background: var(--mention-me); }
.message.grouped { margin-top: -2px; }
.message.grouped .avatar, .message.grouped .meta { visibility: hidden; height: 0; margin: 0; }
.message.call-log {
  display: flex; align-items: center; gap: 12px;
  grid-template-columns: none;
  padding: 10px 12px;
  color: var(--text-muted);
}
.message.call-log:hover { background: transparent; }
.call-log-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: rgba(237, 66, 69, 0.15); color: #ed4245;
}
.call-log-cancelled .call-log-icon,
.call-log-completed .call-log-icon {
  background: rgba(35, 165, 89, 0.15); color: #23a559;
}
.call-log-declined .call-log-icon {
  background: rgba(128, 132, 142, 0.18); color: #949ba4;
}
.call-log-body {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0;
}
.call-log-text {
  font-weight: 600; font-size: 0.95rem;
  color: var(--text-strong, #f2f3f5);
}
.call-log-missed .call-log-text { color: #ed4245; }
.call-log-cancelled .call-log-text,
.call-log-completed .call-log-text { color: var(--text-strong, #f2f3f5); }
.call-log .time { font-size: 0.75rem; color: var(--text-muted); }
.message .body { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.meta {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
  min-width: 0; flex-wrap: wrap;
}
.meta .nick { font-weight: 600; color: var(--text-strong); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.meta .nick:hover .nick-label { text-decoration: underline; }
.meta .nick.is-premium:hover .nick-label { text-decoration: none; filter: brightness(1.12); }
.meta .nick .nick-label.nick-role {
  color: var(--role-color, var(--text-strong));
  font-weight: 700;
}
.meta .nick .nick-label.nick-premium,
.message .nick .nick-label.nick-premium {
  color: transparent !important;
  font-weight: 800;
  background: linear-gradient(90deg, var(--premium-accent, #ff73fa), #5865f2, #00d4ff, var(--premium-accent, #ff73fa));
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  animation: premium-shine 5s linear infinite;
}
.message .msg-avatar.premium {
  box-shadow:
    0 0 0 2px var(--bg-mid, #313338),
    0 0 0 3px var(--premium-accent, #ff73fa),
    0 0 12px color-mix(in srgb, var(--premium-accent, #ff73fa) 50%, transparent);
}
.message .body.is-premium-author {
  --premium-glow: color-mix(in srgb, var(--premium-accent, #ff73fa) 18%, transparent);
}
.message:hover .body.is-premium-author {
  /* soft premium wash on hover */
}
.meta .role-tag {
  font-size: 0.65rem; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  background: var(--accent); color: #fff; text-transform: uppercase;
}
.meta .role-tag.mod { background: var(--green); }
.meta .time { font-size: 0.7rem; color: var(--text-muted); }
.content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
  max-width: 100%;
  min-width: 0;
}
.mention {
  background: var(--mention-bg); color: #c9cdfb; font-weight: 600;
  border-radius: 3px; padding: 0 2px; cursor: pointer;
  display: inline;
}
.mention.me { background: var(--yellow); color: #111; }
.mention.everyone { background: rgba(237, 66, 69, 0.25); color: #f2b0b1; }
.mention.everyone.me { background: rgba(237, 66, 69, 0.45); color: #fff; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachments img {
  max-width: min(400px, 100%); max-height: 300px; border-radius: 8px;
  cursor: pointer; display: block;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg-low); border-radius: 8px;
  border: 1px solid var(--bg-highest); text-decoration: none; color: var(--text);
  max-width: 280px;
}
.file-chip:hover { background: var(--bg-high); }
.sys-msg {
  text-align: center; color: var(--text-muted); font-size: 0.8rem;
  padding: 8px; opacity: 0.85;
}

/* IRC-style private bot NOTICE (only visible to the recipient) */
.irc-notice {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px;
  padding: 4px 12px 4px 16px;
  font-size: 0.86rem; line-height: 1.4;
  color: #c9a227;
  border-left: 2px solid rgba(201, 162, 39, 0.45);
  margin: 2px 0;
}
.irc-notice-dash { opacity: 0.7; font-weight: 600; }
.irc-notice-nick {
  font-weight: 700; color: #e0b83a;
}
.irc-notice-body {
  color: #d5c48a; white-space: pre-wrap; overflow-wrap: anywhere;
}
.irc-notice-body strong { color: #f0d878; }
html[data-theme="light"] .irc-notice {
  color: #8a6d00; border-left-color: rgba(138, 109, 0, 0.35);
}
html[data-theme="light"] .irc-notice-nick { color: #6b5400; }
html[data-theme="light"] .irc-notice-body { color: #5c4a10; }
html[data-theme="light"] .irc-notice-body strong { color: #4a3c00; }

.typing {
  min-height: 22px; padding: 0 16px 4px; font-size: 0.8rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.typing.is-hidden { display: none; }
.typing-text strong { color: var(--text); font-weight: 600; }
.typing-dots {
  display: inline-flex; align-items: center; gap: 3px; height: 14px;
}
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted);
  opacity: 0.45; animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.msg-embeds {
  display: grid; gap: 8px; margin-top: 8px; max-width: min(520px, 100%);
}
.msg-embed {
  position: relative;
  background: var(--bg-low);
  border-radius: 4px;
  padding: 10px 12px 12px 14px;
  border-left: 4px solid var(--embed-color, var(--accent));
  overflow: hidden;
}
.msg-embed-provider {
  font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 4px;
}
.msg-embed-title {
  display: inline-block; color: #00a8fc; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; line-height: 1.3; margin-bottom: 2px;
}
.msg-embed-title:hover { text-decoration: underline; }
.msg-embed-author {
  font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px;
}
.msg-embed-desc {
  font-size: 0.85rem; color: var(--text); line-height: 1.35;
  white-space: pre-wrap; word-break: break-word; margin-bottom: 8px;
}
.msg-embed-thumb {
  display: block; margin-top: 6px; border-radius: 4px; overflow: hidden;
  max-width: 100%;
}
.msg-embed-thumb img {
  display: block; max-width: 100%; max-height: 280px; object-fit: cover;
  border-radius: 4px;
}
.msg-embed-player {
  position: relative; margin-top: 8px; width: 100%;
  aspect-ratio: 16 / 9; background: #000; border-radius: 4px; overflow: hidden;
}
.msg-embed-player iframe,
.msg-embed-player video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.msg-embed-player.file { aspect-ratio: 16 / 9; }
html[data-theme="light"] .msg-embed { background: #f2f3f5; }
.msg-seen {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  min-height: 16px;
}
.msg-seen-avatars {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-direction: row-reverse;
  gap: 0;
}
.msg-seen-avatars .seen-avatar {
  position: relative;
  width: 14px;
  height: 14px;
  font-size: 0.45rem;
  font-weight: 700;
  border-radius: 50%;
  border: 2px solid var(--bg-mid);
  margin-left: -5px;
  padding: 0;
  color: #fff;
  display: inline-grid;
  place-items: center;
  overflow: visible;
  flex-shrink: 0;
  cursor: pointer;
  line-height: 1;
  z-index: 1;
}
.msg-seen-avatars .seen-avatar:first-child { margin-left: 0; }
.msg-seen-avatars .seen-avatar:hover { z-index: 5; }
.msg-seen-avatars .seen-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  overflow: hidden;
}
.msg-seen-avatars .seen-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  padding: 4px 8px;
  border-radius: 4px;
  background: #111214;
  color: #f2f3f5;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
}
.msg-seen-avatars .seen-avatar:hover .seen-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.msg-seen-avatars .seen-more {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
  line-height: 1;
}
html[data-theme="light"] .msg-seen-avatars .seen-avatar {
  border-color: #fff;
}
html[data-theme="light"] .msg-seen-avatars .seen-tip {
  background: #fff;
  color: #060607;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.composer {
  margin: 0 16px 24px; background: var(--bg-high); border-radius: 8px;
  display: flex; align-items: flex-end; gap: 4px; padding: 4px;
  position: relative;
}
.attach-btn, .send-btn {
  width: 40px; height: 40px; border-radius: 8px; color: var(--text-muted); font-size: 1.2rem;
  display: inline-grid; place-items: center; flex-shrink: 0;
}
.attach-btn:hover, .send-btn:hover { color: var(--text-strong); background: var(--bg-modifier); }
.composer-main { flex: 1; position: relative; min-width: 0; overflow: visible; }
#msg-input {
  width: 100%; border: none; outline: none; resize: none;
  background: transparent; padding: 10px 8px; max-height: 160px;
  line-height: 1.35;
}
.attach-preview {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 8px 4px;
}
.attach-preview .chip {
  position: relative; background: var(--bg-lowest); border-radius: 8px; overflow: hidden;
  border: 1px solid var(--bg-highest); min-width: 0;
}
.attach-preview .chip.file-chip-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 28px 8px 10px; min-width: 160px; max-width: 240px;
}
.attach-preview .chip-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.attach-preview .chip-meta { min-width: 0; display: grid; gap: 2px; }
.attach-preview .chip-name {
  font-size: 0.8rem; font-weight: 600; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-preview .chip-size { font-size: 0.7rem; color: var(--text-muted); }
.attach-preview img { width: 100px; height: 100px; object-fit: cover; display: block; }
.attach-preview .rm {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,0.72); color: #fff; font-size: 0.7rem;
  display: grid; place-items: center; border: none; cursor: pointer;
}
.attach-preview .rm:hover { background: var(--red); }

.mention-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px);
  width: min(360px, 100%);
  max-height: min(320px, 50vh);
  background: var(--bg-low);
  border: 1px solid var(--bg-highest); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 120;
}
.mention-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; text-align: left; color: var(--text);
}
.mention-menu button:hover, .mention-menu button.active { background: var(--accent); color: #fff; }

.members {
  background: var(--bg-low);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  --status-platform: var(--bg-low);
}
.members-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 20px;
  -webkit-overflow-scrolling: touch;
}
.members-empty {
  margin: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}
.member-group { margin: 0; }
.member-group-title {
  margin: 0;
  padding: 24px 8px 4px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-group + .member-group .member-group-title {
  padding-top: 16px;
}
.member-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 8px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 42px;
  padding: 1px 8px;
  border-radius: 4px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
}
.member-item:hover,
.member-item:focus-visible {
  background: var(--bg-modifier);
  outline: none;
}
.member-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}
.member-item .avatar,
.member-item .member-avatar {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  border-radius: 50%;
}
.member-status-dot.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 3px solid var(--bg-low);
  box-sizing: content-box;
  margin: 0;
  z-index: 1;
}
.member-item:hover .member-status-dot.status-dot,
.member-item:focus-visible .member-status-dot.status-dot {
  border-color: color-mix(in srgb, var(--bg-low) 70%, var(--bg-modifier));
}

/* Discord-style avatar status badges */
.status-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--status-platform, var(--bg-low));
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
  color: var(--green);
  box-sizing: border-box;
}
.status-badge svg {
  width: 10px;
  height: 10px;
  display: block;
}
.status-badge.online { color: var(--green); }
.status-badge.away { color: var(--yellow); }
.status-badge.busy { color: var(--red); }
.status-badge.offline,
.status-badge.invisible { color: #80848e; }
.member-item:hover .status-badge,
.member-item:focus-visible .status-badge,
.dm-item:hover .status-badge,
.dm-item:focus-visible .status-badge {
  background: color-mix(in srgb, var(--status-platform, var(--bg-low)) 55%, var(--bg-modifier));
}
.user-panel .status-badge#me-status-dot,
.avatar-wrap > .status-badge#me-status-dot {
  right: -2px;
  bottom: -2px;
}
.member-info {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}
.member-name {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.member-item.is-offline {
  opacity: 0.3;
}
.member-item.is-offline:hover,
.member-item.is-offline:focus-visible {
  opacity: 1;
}
.member-item.is-offline .member-name {
  color: var(--text-muted);
}
.member-item.is-offline .avatar,
.member-item.is-offline .member-avatar {
  filter: grayscale(1);
}
.member-item .nitro-badge { flex-shrink: 0; }
.member-item .avatar.premium {
  box-shadow: none; /* Discord member list: no nitro ring on avatars */
}
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  margin-left: auto; flex-shrink: 0;
}

/* Modal */
.modal {
  border: none; border-radius: 12px; padding: 0; background: transparent;
  max-width: 640px; width: calc(100% - 32px); color: var(--text);
}
.modal::backdrop { background: rgba(0,0,0,0.7); }
.modal-card {
  background: var(--bg-mid); border-radius: 12px; padding: 20px;
  max-height: 85vh; overflow: auto;
}
.modal-card header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.modal-card h2, .modal-card h3 { margin: 0; color: var(--header); }
.modal-card h3 { margin: 20px 0 10px; font-size: 0.95rem; }
.modal-help { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 16px; }
fieldset {
  border: 1px solid var(--bg-highest); border-radius: 8px; padding: 12px;
  display: grid; gap: 8px;
}
legend { padding: 0 6px; color: var(--text-muted); font-size: 0.8rem; }
.radio { display: flex; gap: 8px; align-items: center; }
.allowlist-users, .admin-users { display: grid; gap: 6px; }
.admin-users-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin: 0 0 12px; padding: 10px 12px;
  background: #1e1f22; border-radius: 8px;
}
.admin-select-all {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.85rem; font-weight: 600; color: #dbdee1; cursor: pointer;
  user-select: none;
}
.admin-select-all input { accent-color: #5865f2; width: 16px; height: 16px; }
.admin-users-selected {
  font-size: 0.8rem; color: #949ba4; font-weight: 600;
}
.admin-bulk-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-left: auto;
}
.admin-bulk-actions.is-hidden { display: none !important; }
.admin-bulk-actions select {
  min-width: 120px; background: #313338; color: #dbdee1;
  border: none; border-radius: 6px; padding: 6px 8px;
}
.admin-user-check {
  display: grid; place-items: center; flex-shrink: 0; cursor: pointer;
}
.admin-user-check input { accent-color: #5865f2; width: 16px; height: 16px; }
.admin-row.is-selected {
  box-shadow: inset 0 0 0 1px rgba(88, 101, 242, 0.55);
  background: rgba(88, 101, 242, 0.12);
}
.allow-row, .admin-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg-low); border-radius: 8px;
}
.allow-row label { flex: 1; }
.admin-row .nick { flex: 1; font-weight: 600; }
html[data-theme="light"] .admin-users-toolbar { background: #e3e5e8; }
html[data-theme="light"] .admin-select-all { color: #2e3338; }
html[data-theme="light"] .admin-row.is-selected {
  background: rgba(88, 101, 242, 0.1);
}
.admin-row select, .row input {
  background: var(--bg-lowest); border: none; border-radius: 6px; padding: 8px;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 120px; }
.row button, .primary, #btn-create-channel {
  background: var(--accent); color: #fff; padding: 8px 14px;
  border-radius: 6px; font-weight: 600;
}
.primary:hover, #btn-create-channel:hover { background: var(--accent-hover); }
.modal-card footer { margin-top: 20px; display: flex; justify-content: flex-end; }

/* Mobile shell helpers (hidden on desktop) */
.mobile-only { display: none !important; }
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-backdrop[hidden] { display: none !important; }
body.mobile-nav-open .mobile-backdrop,
body.mobile-members-open .mobile-backdrop {
  display: block;
}
.members-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -8px 0 12px;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--bg-highest);
}
.members-mobile-title {
  margin: 0 !important;
  font-size: 0.85rem !important;
  letter-spacing: 0.02em;
  color: var(--header) !important;
  text-transform: uppercase;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 56px 220px minmax(0, 1fr);
    height: 100dvh;
  }
  .app.members-hidden:not(.view-dms) {
    grid-template-columns: 56px 220px minmax(0, 1fr);
  }
  #btn-members-toggle {
    display: none !important;
  }
  .app.view-dms {
    grid-template-columns: 56px 220px minmax(0, 1fr);
  }
  .guild-rail {
    display: flex;
    padding: 8px 0;
    gap: 6px;
  }
  .guild-btn {
    width: 40px;
    height: 40px;
  }
  .guild-sep { width: 24px; }
  .members {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 50;
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.4);
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    overflow: hidden;
  }
  .members.mobile-open {
    display: flex;
    flex-direction: column;
  }
  .members.mobile-open .members-mobile-header { display: flex !important; }
  .members.mobile-open .members-mobile-header.mobile-only { display: flex !important; }
  .members.mobile-open .members-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .chat-actions #btn-mobile-members.mobile-only {
    display: inline-grid !important;
  }
  .chat-header {
    gap: 8px;
    padding: 0 10px 0 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .chat-title .divider,
  #target-topic { display: none; }
  .conn-status { display: none; }
  .composer-wrap {
    margin: 0 10px max(12px, env(safe-area-inset-bottom));
  }
  .message-wrap { min-height: 0; flex: 1; position: relative; }
  .message-list {
    padding: 12px 8px 0;
    -webkit-overflow-scrolling: touch;
  }
  .message {
    grid-template-columns: 36px 1fr;
    gap: 10px;
    padding: 8px 8px;
  }
  .msg-actions {
    display: flex;
    opacity: 0.95;
    position: static;
    margin-top: 6px;
    width: fit-content;
  }
  .message:hover .msg-actions { display: flex; }
  .attachments img {
    max-width: 100%;
    max-height: 240px;
  }
  .file-chip { max-width: 100%; }
  .media-drawer {
    width: min(100vw, 420px);
    max-width: 100%;
  }
  .toast-stack {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
  }
  .admin-row { flex-wrap: wrap; }
  .admin-row .admin-user-meta { flex: 1 1 140px; min-width: 0; }
  .admin-row .admin-nick-input,
  .admin-row .admin-display-input,
  .admin-row select {
    flex: 1 1 120px;
    min-width: 0;
  }
  .admin-modal {
    width: 100% !important;
    max-width: none !important;
    margin: 0;
    padding: 6px;
  }
  .profile-modal .modal-card,
  .modal-card {
    max-height: calc(100dvh - 24px);
  }
  .profile-card {
    width: min(420px, calc(100vw - 16px));
    max-height: calc(100dvh - 24px);
  }
  button, .icon-btn, .attach-btn, .send-btn, .member-item, .nav-list button {
    touch-action: manipulation;
  }
}

@media (max-width: 640px) {
  .app {
    grid-template-columns: 56px minmax(0, 1fr);
    height: 100dvh;
    height: 100svh;
  }
  .app.view-dms {
    grid-template-columns: 56px minmax(0, 1fr);
  }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 56px;
    width: min(320px, calc(88vw - 56px));
    z-index: 50;
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.45);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.mobile-open {
    display: flex;
    flex-direction: column;
  }
  .sidebar.mobile-open #btn-mobile-nav-close.mobile-only {
    display: inline-grid !important;
  }
  .sidebar.mobile-open .irc-badge { display: none; }
  #btn-mobile-nav.mobile-only {
    display: inline-grid !important;
  }
  .chat-actions .icon-btn#btn-keybinds { display: none; }
  .auth-view {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .auth-card { padding: 24px 18px; }
  .channel-search-bar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
  }
  .channel-search-bar input { flex: 1 1 100%; min-width: 0; }
  .emoji-picker {
    left: 8px !important;
    right: 8px;
    width: auto !important;
    max-width: none;
  }
  .qs-card {
    width: calc(100% - 16px);
    margin: 8px;
  }
  .composer .attach-btn { width: 40px; height: 40px; }
  #msg-input { font-size: 16px; } /* avoid iOS zoom on focus */
}

html[data-theme="light"] .mobile-backdrop {
  background: rgba(0, 0, 0, 0.35);
}

/* Notifications / reply / reactions / emoji / calls */
.notif-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700;
  display: inline-grid; place-items: center;
}
.chat-actions { display: flex; align-items: center; gap: 4px; }
.reply-quote {
  margin-bottom: 4px; padding: 6px 8px; border-left: 3px solid var(--accent);
  background: rgba(88,101,242,0.12); border-radius: 0 6px 6px 0;
  font-size: 0.8rem; color: var(--text-muted); cursor: pointer;
}
.msg-actions {
  display: none; gap: 4px; position: absolute; top: 4px; right: 8px;
  background: var(--bg-low); border: 1px solid var(--bg-highest); border-radius: 6px; padding: 2px;
}
.message:hover .msg-actions { display: flex; }
.msg-actions button { width: 28px; height: 28px; border-radius: 4px; font-size: 0.9rem; color: var(--text-muted); }
.msg-actions button:hover { background: var(--bg-modifier); color: var(--text-strong); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; background: var(--bg-low);
  border: 1px solid var(--bg-highest); font-size: 0.8rem; color: var(--text);
}
.reaction-chip.mine { border-color: var(--accent); background: rgba(88,101,242,0.2); }
.reaction-chip:hover { background: var(--bg-high); }
.toast-stack {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  display: grid; gap: 0; width: min(340px, calc(100% - 32px));
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  background: var(--bg-low); border: 1px solid var(--bg-highest); border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 10px 28px rgba(0,0,0,0.4); cursor: pointer;
  animation: toast-in 0.16s ease-out;
}
.toast-item strong { display: block; color: var(--header); margin-bottom: 4px; font-size: 0.92rem; }
.toast-item span {
  display: block; color: var(--text-muted); font-size: 0.85rem;
  line-height: 1.35; word-break: break-word;
}
.toast-bundle.is-stacked {
  padding-top: 10px;
}
.toast-bundle-head {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}
.toast-bundle-prev {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--bg-highest);
  display: grid; gap: 6px;
}
.toast-bundle-line {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast-bundle-line b { color: var(--text); font-weight: 650; }
.toast-bundle-more {
  margin-top: 6px; font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
html[data-theme="light"] .toast-item {
  background: #fff; border-color: #e3e5e8;
  box-shadow: 0 10px 28px rgba(0,0,0,0.14);
}
/* Incoming call — compact Discord-style popup */
.call-incoming {
  position: fixed; right: 20px; bottom: 20px; z-index: 95;
  pointer-events: none;
}
.call-incoming.is-hidden { display: none !important; }
.call-incoming-card {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  min-width: 280px; max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1e1f22;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  color: #fff;
  animation: call-incoming-in .2s ease-out;
}
html[data-theme="light"] .call-incoming-card {
  background: #fff; color: #060607;
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
}
@keyframes call-incoming-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.call-incoming-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; color: #fff;
  background: #5865f2; overflow: hidden;
  animation: call-pulse 1.8s ease-in-out infinite;
}
.call-incoming-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-incoming-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.call-incoming-meta strong {
  font-size: 0.95rem; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.call-incoming-meta span { font-size: 0.78rem; color: var(--text-muted, #b5bac1); }
.call-incoming-actions { display: flex; gap: 8px; flex-shrink: 0; }
.call-incoming-actions .call-ctrl { width: 40px; height: 40px; }

/* DM call stage — Discord-style in-chat voice panel (not fullscreen) */
.dm-call-stage {
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, #1a2e28 0%, #111916 100%);
}
.dm-call-stage.is-hidden { display: none !important; }
.dm-call-stage.is-video { min-height: 220px; }
.dm-call-stage-inner {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 160px;
  max-height: min(42vh, 360px);
  padding: 16px 16px 12px;
}
.dm-call-videos {
  position: absolute; inset: 0; z-index: 1;
  opacity: 0; pointer-events: none;
}
.dm-call-stage.is-video .dm-call-videos { opacity: 1; pointer-events: auto; }
.dm-call-stage.is-video .dm-call-people { opacity: 0; pointer-events: none; }
#remote-video {
  width: 100%; height: 100%; object-fit: cover; background: #0b1411;
}
#local-video {
  position: absolute; right: 14px; bottom: 70px; width: min(160px, 28vw);
  border-radius: 10px; border: 2px solid rgba(255,255,255,0.12);
  aspect-ratio: 16/10; object-fit: cover; background: #111; z-index: 3;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#local-video.is-hidden { display: none; }
.dm-call-people {
  position: relative; z-index: 2;
  display: flex; align-items: flex-end; justify-content: center; gap: 28px;
  flex-wrap: wrap; min-height: 120px; color: #fff; padding: 8px 8px 0;
}
.dm-call-tile {
  display: grid; justify-items: center; gap: 8px;
  min-width: 100px;
}
.dm-call-avatar-wrap {
  position: relative;
  width: 88px; height: 88px;
}
.dm-call-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 800; color: #fff;
  background: #5865f2; overflow: hidden;
  box-shadow: 0 0 0 3px transparent, 0 12px 28px rgba(0,0,0,0.35);
  transition: box-shadow 0.12s ease;
}
.dm-call-tile.is-speaking .dm-call-avatar,
.dm-call-avatar.is-speaking {
  box-shadow: 0 0 0 3px #23a559, 0 12px 28px rgba(0,0,0,0.35);
}
.dm-call-stage.is-active .dm-call-tile:not(.is-speaking) .dm-call-avatar {
  animation: none;
}
.dm-call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dm-call-avatar-wrap .status-badge,
.dm-call-avatar-wrap .member-status-dot {
  position: absolute; right: 0; bottom: 0;
  width: 22px; height: 22px;
  border: 3px solid #111916;
  z-index: 2;
}
.dm-call-tile-meta {
  display: flex; align-items: center; gap: 6px; max-width: 140px;
}
.dm-call-tile-name {
  font-size: 0.9rem; font-weight: 600; color: #f2f3f5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-call-tile.is-self .dm-call-tile-name { color: #b5bac1; }
.dm-call-tile-flags { display: flex; gap: 4px; color: #ed4245; }
.dm-call-meta {
  position: relative; z-index: 2;
  text-align: center; color: #fff; padding: 4px 8px 0;
}
.dm-call-meta h3 {
  margin: 0; font-size: 1.05rem; font-weight: 700; color: #fff;
}
.dm-call-meta p {
  margin: 4px 0 0; color: rgba(255,255,255,0.7); font-size: 0.85rem;
}
.dm-call-actions {
  position: relative; z-index: 4;
  display: flex; gap: 12px; justify-content: center; align-items: center;
  padding-top: 8px;
}
.call-ctrl {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: #2b2d31; color: #fff; border: none; cursor: pointer;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.call-ctrl:hover { background: #3f4147; transform: scale(1.05); }
.call-ctrl.is-off { background: #fff; color: #1e1f22; }
.call-ctrl.accept { background: #23a559; }
.call-ctrl.accept:hover { background: #1a7f43; }
.call-ctrl.decline { background: #ed4245; }
.call-ctrl.decline:hover { background: #c03537; }
@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(35, 165, 89, 0.18), 0 12px 28px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 0 0 14px rgba(35, 165, 89, 0.08), 0 12px 28px rgba(0,0,0,0.35); }
}
#remote-audio { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

/* Voice connection bar + stage */
.user-panel-wrap {
  margin-top: auto;
  display: grid;
  background: #232428;
}
.voice-panel {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px;
  background: #232428;
  border-bottom: 1px solid rgba(0,0,0,0.4);
}
.voice-panel.is-hidden { display: none !important; }
.voice-panel-status {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  flex: 1; cursor: pointer; border-radius: 4px; padding: 2px 4px;
}
.voice-panel-status:hover { background: rgba(255,255,255,0.04); }
.voice-panel-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #23a559;
  box-shadow: 0 0 0 4px rgba(35,165,89,0.18); flex-shrink: 0;
  animation: voice-pulse 2s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(35,165,89,0.18); }
  50% { box-shadow: 0 0 0 6px rgba(35,165,89,0.08); }
}
.voice-panel-meta { min-width: 0; display: grid; line-height: 1.15; }
.voice-panel-meta strong {
  color: #23a559; font-size: 0.78rem; font-weight: 700;
}
.voice-panel-meta span {
  color: #b5bac1; font-size: 0.72rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.voice-panel-actions { display: flex; gap: 2px; flex-shrink: 0; }
.voice-ctrl {
  width: 32px; height: 32px; border-radius: 4px;
  display: grid; place-items: center;
  background: transparent; color: #b5bac1; border: none; cursor: pointer;
}
.voice-ctrl:hover { background: var(--bg-modifier); color: #fff; }
.voice-ctrl.is-off { color: #ed4245; background: rgba(237,66,69,0.1); }
.voice-ctrl.danger { color: #b5bac1; }
.voice-ctrl.danger:hover { color: #ed4245; background: rgba(237,66,69,0.15); }
.voice-ctrl .icon-mic-off,
.voice-ctrl .icon-head-off { display: none; }
.voice-ctrl.is-off .icon-mic,
.voice-ctrl.is-off .icon-head { display: none; }
.voice-ctrl.is-off .icon-mic-off,
.voice-ctrl.is-off .icon-head-off { display: block; }

.nav-item .hash.voice-hash {
  display: inline-grid; place-items: center; width: 1.1em;
  opacity: 0.85;
}
.channel-row.is-voice.is-connected > .nav-item {
  color: #23a559;
}
.voice-user-list {
  list-style: none; margin: 0; padding: 2px 0 6px 8px;
  display: grid; gap: 2px;
  overflow: visible;
}
.voice-user-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 18px; border-radius: 4px;
  color: #949ba4; font-size: 0.8rem; font-weight: 500;
  cursor: pointer;
  overflow: visible;
}
.voice-user-item:hover { background: var(--bg-modifier); color: #dbdee1; }
.voice-user-avatar {
  position: relative;
  display: grid; place-items: center; border-radius: 50%;
  width: 28px; height: 28px;
  flex-shrink: 0;
  overflow: visible;
}
.voice-user-avatar .avatar {
  width: 24px; height: 24px; font-size: 0.6rem; border-radius: 50%;
  /* overflow:hidden on .avatar clips box-shadow — ring must stay on the wrapper */
}
/* Discord-like green ring while talking (wrapper, not .avatar) */
.voice-user-avatar.is-speaking,
.voice-user-item.is-speaking .voice-user-avatar {
  box-shadow: 0 0 0 2px #23a559, 0 0 10px rgba(35, 165, 89, 0.5);
}
.voice-user-avatar .status-badge,
.voice-user-avatar .member-status-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-width: 2px;
  border-style: solid; border-color: var(--bg-dark, #1e1f22);
  z-index: 2; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-dark, #1e1f22);
}
.voice-user-avatar .status-badge svg {
  width: 8px; height: 8px;
}
.voice-user-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.voice-user-item.is-self .voice-user-name { color: #f2f3f5; }
.voice-user-item.is-speaking .voice-user-name { color: #f2f3f5; }
.voice-user-flags {
  display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0;
}
.voice-user-mute,
.voice-user-deaf {
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
  background: #1e1f22; color: #ed4245;
}
.voice-user-item.is-muted::after,
.voice-user-item.is-deafened::after { content: none; }

.voice-stage {
  flex: 1 1 auto; min-height: 180px; min-width: 0;
  display: flex; flex-direction: column;
  background: #2b2d31; border-radius: 0; margin: 0;
  overflow: hidden;
}
.voice-stage.is-hidden { display: none !important; }
/* Discord-style: large voice stage on top, compact ephemeral text chat below */
.chat.is-voice-view .voice-stage { display: flex; }
.chat.is-voice-view .message-wrap {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
.chat.is-voice-view:not(.is-voice-connected) .voice-stage {
  flex: 1 1 auto; max-height: none;
}
.chat.is-voice-connected .voice-stage {
  flex: 1 1 58%; max-height: none; min-height: 220px;
}
.chat.is-voice-view .voice-chat-bar { display: flex; }
.chat.is-voice-view .message-list {
  display: flex; flex-direction: column; flex: 1 1 42%;
  min-height: 140px; max-height: min(38vh, 360px);
  background: #313338; border-top: 1px solid rgba(0,0,0,0.25);
}
.chat.is-voice-view .composer-wrap,
.chat.is-voice-view #typing { display: block; }
.chat.is-voice-view #btn-jump-present { display: none !important; }
.voice-chat-bar {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px 4px; background: #313338;
  border-top: 1px solid rgba(0,0,0,0.2); flex-shrink: 0;
}
.voice-chat-bar.is-hidden { display: none !important; }
.voice-chat-bar-title {
  display: inline-flex; align-items: center; gap: 6px;
  color: #f2f3f5; font-size: 0.8rem; letter-spacing: 0.02em;
}
.voice-chat-bar-title svg { color: #b5bac1; }
.voice-chat-bar-title strong { font-weight: 700; text-transform: uppercase; font-size: 0.72rem; }
.voice-chat-bar-hint {
  color: #949ba4; font-size: 0.72rem;
}
.voice-chat-empty {
  margin: auto; text-align: center; padding: 28px 20px;
  display: grid; gap: 6px; color: #949ba4; max-width: 360px;
}
.voice-chat-empty strong { color: #dbdee1; font-size: 0.95rem; }
.voice-chat-empty span { font-size: 0.8rem; line-height: 1.35; }
.composer-wrap.is-voice-locked {
  opacity: 0.72;
}
.composer-wrap.is-voice-locked #msg-input {
  cursor: not-allowed;
}
.voice-stage-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: #1e1f22;
  border-bottom: 1px solid rgba(0,0,0,0.35);
  flex-shrink: 0;
}
.voice-stage-header-icon { color: #b5bac1; flex-shrink: 0; }
.voice-stage-header-text { min-width: 0; flex: 1; }
.voice-stage-header h3 { margin: 0; color: #f2f3f5; font-size: 1rem; font-weight: 700; }
.voice-stage-header p { margin: 2px 0 0; color: #949ba4; font-size: 0.78rem; }
.voice-stage-header .primary,
.voice-stage-header .voice-disconnect-btn { margin-left: auto; flex-shrink: 0; }
.voice-disconnect-btn {
  background: #da373c; color: #fff; border: none; border-radius: 3px;
  padding: 8px 16px; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.voice-disconnect-btn:hover { background: #a12828; }
.voice-stage-grid {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; padding: 16px; align-content: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(35,165,89,0.07), transparent 50%),
    #2b2d31;
}
.voice-stage-empty {
  grid-column: 1 / -1;
  display: grid; place-items: center; gap: 8px;
  text-align: center; padding: 48px 24px; color: #949ba4;
}
.voice-stage-empty-icon { color: #4e5058; margin-bottom: 4px; }
.voice-stage-empty strong { color: #dbdee1; font-size: 1rem; }
.voice-stage-empty span { font-size: 0.85rem; max-width: 320px; }
.voice-tile {
  aspect-ratio: 16 / 10; min-height: 110px; border-radius: 8px;
  background: #1e1f22; display: grid; place-items: center; gap: 10px;
  position: relative; color: #fff; padding: 14px 12px 12px;
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.voice-tile.is-speaking {
  box-shadow: inset 0 0 0 3px #23a559;
}
.voice-tile-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 1.7rem;
  overflow: hidden;
  box-shadow: 0 0 0 0 transparent;
  transition: box-shadow 0.12s ease;
}
.voice-tile-avatar.is-speaking,
.voice-tile.is-speaking .voice-tile-avatar {
  box-shadow: 0 0 0 4px #23a559, 0 0 18px rgba(35,165,89,0.35);
}
.voice-tile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.voice-tile-name {
  font-weight: 650; font-size: 0.92rem; text-align: center;
  color: #f2f3f5; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.voice-you {
  color: #949ba4; font-weight: 500; font-size: 0.8rem;
}
.voice-tile-flags {
  position: absolute; right: 10px; bottom: 10px;
  display: flex; gap: 4px;
}
.voice-badge {
  width: 28px; height: 28px; border-radius: 50%;
  background: #ed4245; color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.voice-badge-deaf { background: #ed4245; }

#target-hash.is-voice {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; color: var(--text-muted);
}
#target-hash.is-voice svg { width: 18px; height: 18px; }
html[data-theme="light"] .voice-panel { background: #e3e5e8; border-bottom-color: #d4d7dc; }
html[data-theme="light"] .user-panel-wrap,
html[data-theme="light"] .user-panel { background: #ebedef; --status-platform: #ebedef; }
html[data-theme="light"] .voice-panel-meta span { color: #4e5058; }
html[data-theme="light"] .voice-stage { background: #e3e5e8; }
html[data-theme="light"] .voice-stage-header { background: #f2f3f5; }
html[data-theme="light"] .voice-stage-grid { background: #e3e5e8; }
html[data-theme="light"] .voice-chat-bar,
html[data-theme="light"] .chat.is-voice-view .message-list { background: #fff; }
html[data-theme="light"] .voice-chat-bar-title { color: #2e3338; }
html[data-theme="light"] .voice-tile { background: #fff; color: #2e3338; }
html[data-theme="light"] .voice-tile-name { color: #2e3338; }
.channel-type-card { margin: 0; }
.admin-dash .channel-type-card {
  background: #1e1f22; border-radius: 10px; padding: 12px 14px;
}
.danger { background: var(--red); color: #fff; }
.perm-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 8px 0; font-size: 0.85rem; color: var(--text-muted);
}
.perm-row span { font-weight: 700; color: var(--text); min-width: 40px; }
.perm-row label { display: inline-flex; gap: 4px; align-items: center; }
.channel-perm-card {
  display: grid; gap: 8px; padding: 10px; background: var(--bg-low); border-radius: 8px; margin-top: 8px;
}
.channel-perm-card .title { font-weight: 700; color: var(--text-strong); }
.channel-perm-card .title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.channel-name-input {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-lowest); border-radius: 8px; padding: 0 10px;
}
.channel-name-input .hash {
  color: var(--text-muted); font-weight: 700; font-size: 1.1rem;
}
.channel-name-input input {
  flex: 1; border: none !important; background: transparent !important;
  padding: 10px 0 !important; outline: none;
}
.channel-edit-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; flex-wrap: wrap;
}
.channel-edit-actions { display: flex; gap: 8px; margin-left: auto; }
.file-btn.ghost {
  background: transparent; color: var(--text-muted); padding: 8px 12px; border-radius: 6px;
}
.file-btn.ghost:hover { background: var(--bg-modifier); color: var(--text); }
.lock-tag {
  font-size: 0.65rem; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-highest); color: var(--text-muted); margin-left: 6px;
}

/* Status */
.avatar-wrap { position: relative; flex-shrink: 0; }
.status-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #232428;
}
.status-dot.online { background: var(--green); }
.status-dot.away { background: var(--yellow); }
.status-dot.busy { background: var(--red); }
.status-dot.invisible { background: #747f8d; }
.member-status {
  display: none;
}

/* Unread badges */
.unread-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 0.7rem; font-weight: 700; display: inline-grid; place-items: center;
}
.nav-item.has-unread { color: var(--text-strong); font-weight: 600; }

/* Jump to present */
.message-wrap {
  position: relative; flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  overflow-x: hidden;
}
.message-wrap .message-list { flex: 1; min-width: 0; }

.drop-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.72);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  margin: 8px;
  pointer-events: none;
}
.drop-overlay.is-hidden { display: none !important; }
.drop-overlay-card {
  display: grid; gap: 8px; justify-items: center; text-align: center;
  color: #fff; padding: 24px; max-width: 360px;
}
.drop-overlay-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(88, 101, 242, 0.25);
  color: var(--accent);
  display: grid; place-items: center; margin-bottom: 4px;
}
.drop-overlay-card strong { font-size: 1.25rem; color: #fff; }
.drop-overlay-card span { font-size: 0.9rem; color: rgba(255,255,255,0.75); }
.chat.is-dragging .composer-wrap {
  box-shadow: inset 0 0 0 2px var(--accent);
}
html[data-theme="light"] .drop-overlay {
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--accent);
}
html[data-theme="light"] .drop-overlay-card strong { color: var(--text-strong); }
html[data-theme="light"] .drop-overlay-card span { color: var(--text-muted); }
.jump-present {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 20px;
  font-size: 0.85rem; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,0.35); z-index: 5;
}
.jump-present:hover { background: var(--accent-hover); }

/* Markdown */
.content .md-p { margin: 0 0 0.25em; }
.content .md-p:last-child { margin-bottom: 0; }
.content .md-br { height: 0.5em; }
.content .md-code, .content .md-codeblock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}
.content .md-code {
  background: var(--bg-lowest); padding: 0.1em 0.35em; border-radius: 4px;
}
.content .md-pre {
  background: var(--bg-lowest); border-radius: 6px; padding: 10px 12px;
  overflow-x: auto; margin: 6px 0; border: 1px solid var(--bg-highest);
  max-width: 100%;
  min-width: 0;
}
.content .md-codeblock {
  white-space: pre;
  display: block;
  max-width: 100%;
}
.content .md-quote {
  margin: 4px 0; padding: 4px 10px; border-left: 3px solid var(--accent);
  background: rgba(88,101,242,0.1); color: var(--text-muted);
}
.content .md-list { margin: 4px 0; padding-left: 1.25em; }
.content .md-link { color: #00a8fc; text-decoration: none; }
.content .md-link:hover { text-decoration: underline; }
.content .md-spoiler {
  background: #202225; color: transparent; border-radius: 3px; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.content .md-spoiler.revealed, .content .md-spoiler:hover {
  color: var(--text); background: rgba(255,255,255,0.08);
}
.content strong { font-weight: 700; }
.content em { font-style: italic; }
.content del { opacity: 0.75; }
.content u { text-decoration: underline; }

/* Sidebar search */
.sidebar-search { padding: 8px 10px 0; }
.sidebar-search input {
  width: 100%; background: var(--bg-lowest); border: none; border-radius: 4px;
  padding: 8px 10px; color: var(--text); font-size: 0.85rem;
}

/* Channel search bar */
.channel-search-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px;
  background: var(--bg-low); border-bottom: 1px solid var(--bg-highest);
}
.channel-search-bar input {
  flex: 1; background: var(--bg-lowest); border: none; border-radius: 4px;
  padding: 8px 10px; color: var(--text);
}
.search-count { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.message.search-hit { outline: 2px solid var(--accent); background: rgba(88,101,242,0.15); }

/* Quick Switcher */
.quick-switcher {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,0.65);
  display: grid; place-items: start center; padding-top: 12vh;
}
.qs-card {
  width: min(560px, calc(100% - 32px)); background: var(--bg-mid); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5); overflow: hidden;
}
.qs-card input {
  width: 100%; border: none; background: transparent; padding: 16px 18px;
  font-size: 1.1rem; color: var(--text-strong); outline: none;
  border-bottom: 1px solid var(--bg-highest);
}
.qs-results { max-height: 360px; overflow: auto; padding: 8px; }
.qs-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 6px; text-align: left; color: var(--text);
}
.qs-item:hover, .qs-item.active { background: var(--accent); color: #fff; }
.qs-item .qs-type { font-size: 0.7rem; opacity: 0.8; text-transform: uppercase; min-width: 56px; }
.qs-hint {
  padding: 8px 14px; font-size: 0.75rem; color: var(--text-muted);
  border-top: 1px solid var(--bg-highest);
}
kbd {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: var(--bg-lowest); border: 1px solid var(--bg-highest);
  font-size: 0.75rem; font-family: inherit; color: var(--text-strong);
}

/* Media drawer */
.media-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: var(--bg-low); z-index: 40; box-shadow: -8px 0 24px rgba(0,0,0,0.35);
  display: flex; flex-direction: column;
}
.media-drawer header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.media-drawer h3 { margin: 0; font-size: 1rem; }
.media-grid {
  flex: 1; overflow: auto; padding: 12px; display: grid;
  grid-template-columns: repeat(2, 1fr); gap: 8px; align-content: start;
}
.media-grid a, .media-grid video, .media-grid audio {
  display: block; width: 100%; border-radius: 8px; background: var(--bg-lowest);
}
.media-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; display: block; }
.media-empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 24px; }

.keybind-list { display: grid; gap: 10px; }
.keybind-list div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-muted); }
.keybind-list span { margin-left: auto; color: var(--text); }

.field-label { display: grid; gap: 6px; margin-bottom: 12px; font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.field-label input {
  background: var(--bg-lowest); border: none; border-radius: 6px; padding: 10px; color: var(--text); text-transform: none; font-weight: 500;
}
.server-admin { margin-bottom: 16px; }

/* Discord-like autocomplete */
.mention-menu {
  width: min(360px, 100%);
  padding: 0;
}
.ac-header {
  padding: 8px 12px 4px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.02em;
}
.ac-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; text-align: left; color: var(--text); border-radius: 0;
}
.ac-item .avatar { flex-shrink: 0; }
.ac-nick { font-weight: 600; color: var(--text-strong); }
.ac-nick-wrap { min-width: 0; flex: 1; display: grid; gap: 1px; }
.ac-handle { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.ac-role {
  margin-left: auto; font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); background: var(--bg-highest); padding: 2px 6px; border-radius: 3px;
}
.ac-emoji { font-size: 1.25rem; width: 28px; text-align: center; }
.ac-name { color: var(--text-muted); font-size: 0.9rem; }
.ac-status {
  position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px;
  border-radius: 50%; border: 2px solid var(--bg-low); background: #747f8d;
}
.ac-status.online { background: var(--green); }
.ac-status.idle { background: var(--yellow); }
.ac-status.dnd { background: var(--red); }
.ac-status.offline { background: #747f8d; }

/* Discord-like reply attached to composer */
.composer-wrap {
  margin: 0 16px 24px;
  border-radius: 8px;
  background: var(--bg-high);
  /* clip alone does not force the other axis to auto — popups can escape upward */
  overflow-x: clip;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 40;
  min-width: 0;
  max-width: 100%;
}
.composer-wrap .composer {
  margin: 0;
  background: transparent;
  border-radius: 0;
  overflow: visible;
}
.composer-wrap.is-replying {
  box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.35);
}
.composer-wrap.is-replying.is-forward,
.composer-wrap.is-replying:has(.reply-bar.is-forward) {
  box-shadow: 0 0 0 1px rgba(59, 165, 93, 0.4);
}

.reply-bar {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  display: block;
  border-radius: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
.reply-bar-inner {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 44px;
}
.reply-bar-accent {
  width: 4px;
  background: var(--accent);
  flex-shrink: 0;
}
.reply-bar.is-forward .reply-bar-accent { background: #3ba55d; }
.reply-bar-icon {
  display: grid;
  place-items: center;
  padding: 0 4px 0 10px;
  color: var(--accent);
}
.reply-bar.is-forward .reply-bar-icon { color: #3ba55d; }
.reply-bar-body {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  justify-content: center;
}
.reply-bar-label { font-size: 0.75rem; color: var(--text-muted); line-height: 1.2; }
.reply-bar-label strong { color: var(--accent); font-weight: 700; }
.reply-bar.is-forward .reply-bar-label strong { color: #3ba55d; }
.reply-bar-preview {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}
.reply-bar .reply-cancel {
  align-self: center;
  margin-right: 6px;
  background: transparent;
  border-radius: 4px;
}
.reply-bar .icon-btn { background: transparent; border-radius: 4px; }

html[data-theme="light"] .composer-wrap { background: #ebedef; }
html[data-theme="light"] .reply-bar { border-bottom-color: rgba(0,0,0,0.08); }
html[data-theme="light"] .composer-wrap.is-replying {
  box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.45);
}

.reply-quote {
  display: flex; gap: 0; margin-bottom: 4px; padding: 0; background: transparent;
  border: none; cursor: pointer; max-width: 100%;
}
.reply-quote-bar {
  width: 2px; background: var(--accent); border-radius: 1px; margin-right: 8px; flex-shrink: 0;
}
.reply-quote-body {
  min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline;
  font-size: 0.8rem; line-height: 1.25;
}
.reply-quote-nick { color: var(--accent); font-weight: 600; }
.reply-quote-text {
  color: var(--text-muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
}
.reply-quote:hover .reply-quote-text { color: var(--text); }

.forward-badge {
  font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  cursor: pointer; max-width: 100%;
}
.forward-badge:hover { color: var(--text); }
.forward-badge strong { color: #3ba55d; }
.forward-icon { color: #3ba55d; font-weight: 700; }
.forward-preview {
  width: 100%; padding: 6px 8px; margin-top: 2px;
  border-left: 2px solid #3ba55d; background: rgba(59,165,93,0.1);
  border-radius: 0 4px 4px 0; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.msg-actions {
  display: none; gap: 0; position: absolute; top: -16px; right: 12px;
  background: var(--bg-mid); border: 1px solid var(--bg-highest); border-radius: 4px;
  padding: 0 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.28);
  z-index: 5; align-items: center;
}
.message:hover .msg-actions { display: flex; }
.msg-actions-reacts { display: flex; gap: 0; border-right: 1px solid var(--bg-highest); margin-right: 2px; padding-right: 2px; }
.msg-act, .msg-act-react {
  width: 32px; height: 32px; border-radius: 4px; font-size: 1rem;
  color: #b5bac1; display: grid; place-items: center;
  background: transparent; border: none; cursor: pointer;
}
.msg-act .ui-icon, .msg-act-react .ui-icon {
  display: block; width: 18px; height: 18px; flex-shrink: 0;
}
.msg-act:hover, .msg-act-react:hover { background: var(--bg-modifier); color: #dbdee1; }
.msg-act.msg-act-danger:hover { background: rgba(242, 63, 67, 0.15); color: #f23f43; }
.attach-btn .ui-icon, .send-btn .ui-icon, .icon-btn .ui-icon {
  display: block;
}

.emoji-picker {
  position: absolute; left: 0; bottom: calc(100% + 8px);
  width: min(340px, calc(100vw - 48px)); max-height: 320px;
  background: var(--bg-low); border: 1px solid var(--bg-highest); border-radius: 10px;
  padding: 0; display: flex; flex-direction: column; z-index: 120;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45); overflow: hidden;
}
.emoji-picker-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px; border-bottom: 1px solid var(--bg-highest);
}
.emoji-picker-head input {
  flex: 1; border: none; border-radius: 6px; padding: 8px 10px;
  background: var(--bg-lowest); color: var(--text); font-size: 0.9rem; outline: none;
}
.emoji-picker-scroll {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  max-height: 240px; overflow: auto; padding: 8px;
}
.emoji-picker .emoji-btn {
  font-size: 1.35rem; padding: 6px; border-radius: 6px; line-height: 1;
  display: grid; place-items: center;
}
.emoji-picker .emoji-btn:hover { background: var(--bg-modifier); }
.emoji-empty {
  grid-column: 1 / -1; text-align: center; color: var(--text-muted);
  padding: 24px 12px; font-size: 0.85rem;
}
html[data-theme="light"] .emoji-picker {
  background: #fff; box-shadow: 0 10px 28px rgba(0,0,0,0.15);
}

/* Close PM button on DM rows */
.nav-item-wrap { display: flex; align-items: center; gap: 2px; }
.nav-item-wrap .nav-item { flex: 1; min-width: 0; }
.dm-close {
  width: 22px; height: 22px; border-radius: 4px; flex-shrink: 0;
  color: var(--text-muted); font-size: 0.85rem; opacity: 0;
}
.nav-item-wrap:hover .dm-close, .nav-item-wrap:focus-within .dm-close { opacity: 1; }
.dm-close:hover { background: var(--bg-modifier); color: var(--text-strong); }

/* Context menu (Discord-like) */
.ctx-menu {
  position: fixed; z-index: 200; min-width: 200px; max-width: 280px;
  background: var(--bg-floating, #111214); background: #111214;
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  padding: 6px 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  color: var(--text);
}
.ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 4px; text-align: left;
  color: #dbdee1; font-size: 0.9rem;
}
.ctx-item:hover, .ctx-item:focus { background: var(--accent); color: #fff; outline: none; }
.ctx-item.danger { color: #f23f43; }
.ctx-item.danger:hover { background: #f23f43; color: #fff; }
.ctx-item.is-checked { color: #23a559; }
.ctx-item.has-submenu {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 8px 10px; border-radius: 4px; text-align: left;
  color: #dbdee1; font-size: 0.9rem; cursor: default;
}
.ctx-item.has-submenu:hover, .ctx-item.has-submenu:focus-within {
  background: var(--accent); color: #fff;
}
.ctx-caret { opacity: 0.8; font-size: 1rem; line-height: 1; }
.ctx-submenu {
  display: none; position: absolute; left: calc(100% - 4px); top: -6px;
  min-width: 180px; max-width: 240px; max-height: min(320px, 70vh); overflow: auto;
  background: #111214; border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  padding: 6px 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.45); z-index: 5;
}
.ctx-submenu.flip-left { left: auto; right: calc(100% - 4px); }
.ctx-item.has-submenu:hover > .ctx-submenu,
.ctx-item.has-submenu:focus-within > .ctx-submenu { display: grid; gap: 2px; }
.ctx-sep { height: 1px; margin: 4px 6px; background: rgba(255,255,255,0.08); }
.ctx-label {
  padding: 6px 10px 4px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; color: #949ba4; letter-spacing: 0.02em;
}

/* In-app confirm / prompt / alert (replaces browser dialogs) */
.ui-dialog {
  padding: 0; border: none; background: transparent;
  max-width: none; width: auto; margin: auto;
  overflow: visible;
}
.ui-dialog[open] {
  display: grid;
  place-items: center;
}
.ui-dialog:not([open]) { display: none !important; }
.ui-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.ui-dialog-card {
  width: min(440px, calc(100vw - 32px));
  background: #313338;
  color: #dbdee1;
  border-radius: 12px;
  padding: 20px 22px 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: grid;
  gap: 14px;
}
.ui-dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.ui-dialog-head h2 {
  margin: 0; font-size: 1.15rem; font-weight: 700; color: #f2f3f5;
}
.ui-dialog-message {
  margin: 0; color: #b5bac1; font-size: 0.92rem; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.ui-dialog-label {
  display: block; margin: 0 0 6px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: #b5bac1;
}
.ui-dialog-input-wrap.is-hidden,
.ui-dialog-result-wrap.is-hidden,
#ui-dialog-generate.is-hidden,
#ui-dialog-hint.is-hidden,
#ui-dialog-cancel.is-hidden { display: none !important; }
.ui-dialog-input-row {
  display: flex; gap: 8px; align-items: stretch;
}
.ui-dialog-input-row input,
.ui-dialog-result {
  flex: 1; min-width: 0;
  background: #1e1f22; color: #dbdee1;
  border: none; border-radius: 6px;
  padding: 10px 12px; font: inherit;
  outline: none;
}
.ui-dialog-input-row input:focus,
.ui-dialog-result:focus {
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.45);
}
.ui-dialog-result {
  resize: vertical; min-height: 88px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem; line-height: 1.4;
}
.ui-dialog-hint {
  margin: 8px 0 0; font-size: 0.78rem; color: #949ba4;
}
.ui-dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px;
}
.ui-dialog-actions .primary { min-width: 96px; }
.ui-dialog-card.is-danger #ui-dialog-ok {
  background: #da373c !important;
}
.ui-dialog-card.is-danger #ui-dialog-ok:hover {
  background: #a12828 !important;
}
html[data-theme="light"] .ui-dialog-card { background: #fff; color: #2e3338; }
html[data-theme="light"] .ui-dialog-head h2 { color: #060607; }
html[data-theme="light"] .ui-dialog-message { color: #4e5058; }
html[data-theme="light"] .ui-dialog-input-row input,
html[data-theme="light"] .ui-dialog-result { background: #e3e5e8; color: #2e3338; }

/* Admin dashboard */
.admin-modal {
  padding: 0; border: none; background: transparent;
  max-width: none !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  margin: 0;
  overflow: hidden;
}
.admin-modal[open] {
  display: grid;
  place-items: center;
}
.admin-modal:not([open]) {
  display: none !important;
}
.admin-modal::backdrop { background: rgba(0,0,0,0.72); }
.admin-dash {
  display: grid; grid-template-columns: 240px minmax(0, 1fr);
  width: min(1480px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: 0;
  background: #1e1f22; border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55); color: #dbdee1;
}
.admin-nav {
  background: #2b2d31; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 0; overflow: auto;
}
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; flex-shrink: 0; }
.admin-brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #5865f2, #57f287); color: #fff; font-weight: 800;
}
.admin-brand strong { display: block; color: #fff; font-size: 0.95rem; }
.admin-brand span { font-size: 0.75rem; color: #949ba4; }
.admin-tabs { display: grid; gap: 4px; flex: 1; align-content: start; min-height: 0; overflow: auto; }
.admin-tab {
  text-align: left; padding: 10px 12px; border-radius: 8px; color: #b5bac1; font-weight: 600;
}
.admin-tab:hover { background: rgba(255,255,255,0.04); color: #fff; }
.admin-tab.active { background: #404249; color: #fff; }
.admin-nav-foot { display: grid; gap: 8px; padding-top: 8px; flex-shrink: 0; }
.admin-save { width: 100%; }
.admin-close-btn {
  width: 100%; padding: 10px; border-radius: 8px; background: transparent;
  color: #949ba4; border: 1px solid #3f4147;
}
.admin-close-btn:hover { color: #fff; background: #35373c; }

.admin-main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;
  background: #313338;
}
.admin-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 24px 12px; border-bottom: 1px solid rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.admin-top h2 { margin: 0; color: #fff; font-size: 1.35rem; }
.admin-sub { margin: 4px 0 0; color: #949ba4; font-size: 0.9rem; }
.admin-search-wrap { min-width: min(280px, 40%); }
.admin-search-wrap input, .admin-inline-search {
  width: 100%; background: #1e1f22; border: none; border-radius: 8px;
  padding: 10px 12px; color: #dbdee1; font-size: 0.9rem;
}
.admin-panels {
  flex: 1 1 auto; min-height: 0;
  overflow-x: hidden; overflow-y: auto;
  padding: 16px 28px 32px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.admin-panel { display: none; animation: adminIn 0.2s ease; }
.admin-panel.active {
  display: grid; gap: 16px;
  min-width: 0;
  align-content: start;
}
.admin-panel .form-card,
.admin-panel .dash-card {
  min-width: 0;
}
.admin-users,
.admin-media-list,
#channel-perm-list,
#category-admin-list,
#role-admin-list {
  min-width: 0;
}
@keyframes adminIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
.stat-card {
  background: #2b2d31; border-radius: 12px; padding: 16px;
  display: grid; gap: 8px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: #949ba4; }
.stat-card strong { font-size: 1.6rem; color: #fff; }

.dash-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dash-cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-card, .form-card {
  background: #2b2d31; border-radius: 12px; padding: 16px 18px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.dash-card h3, .form-card h3 { margin: 0 0 8px; color: #fff; font-size: 1rem; }
.friendly-list { margin: 0; padding-left: 18px; color: #b5bac1; display: grid; gap: 8px; }
.friendly-list strong { color: #fff; }
.linkish {
  margin-top: 10px; color: #00a8fc; font-weight: 600; padding: 0; background: none;
}
.linkish:hover { text-decoration: underline; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.card-head .admin-inline-search { max-width: 220px; }

.toggle-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px;
  background: #1e1f22; border-radius: 10px; cursor: pointer;
}
.toggle-row input { margin-top: 4px; accent-color: #5865f2; width: 18px; height: 18px; }
.toggle-row strong { display: block; color: #fff; }
.toggle-row small { color: #949ba4; }

.choice-cards { display: grid; gap: 8px; }
.choice-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  background: #1e1f22; border-radius: 10px; cursor: pointer;
  box-shadow: inset 0 0 0 1px transparent;
}
.choice-card:has(input:checked) { box-shadow: inset 0 0 0 2px #5865f2; background: rgba(88,101,242,0.12); }
.choice-card strong { display: block; color: #fff; }
.choice-card small { color: #949ba4; }
.choice-card input { margin-top: 3px; accent-color: #5865f2; }

.admin-dash .field-label { color: #b5bac1; }
.admin-dash .field-label input {
  background: #1e1f22; color: #dbdee1; border-radius: 8px;
}
.admin-dash .row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.admin-dash .row input { flex: 1; min-width: 140px; background: #1e1f22; border: none; border-radius: 8px; padding: 10px; color: #dbdee1; }
.admin-dash .perm-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; color: #b5bac1; }
.admin-dash .admin-row, .admin-dash .allow-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #1e1f22; border-radius: 8px;
}
.admin-dash .admin-row .nick { flex: 1; color: #fff; font-weight: 600; }
.xmpp-stat-grid { margin: 12px 0; }
.xmpp-list { max-height: 280px; overflow: auto; display: grid; gap: 4px; }
.xmpp-row-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.xmpp-tag {
  display: inline-block; margin-left: 8px; padding: 1px 6px; border-radius: 4px;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  background: var(--bg-highest); color: var(--text-muted); vertical-align: middle;
}
.xmpp-tag.warn { background: rgba(240,178,50,0.2); color: var(--yellow); }
.xmpp-detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.xmpp-detail-head h3 { margin: 0; }
.xmpp-detail-body { display: grid; gap: 6px; }
.admin-dash select {
  background: #1e1f22; border: none; border-radius: 8px; padding: 10px; color: #dbdee1;
}
.linkish.danger { color: var(--red); }
.admin-dash button:not(.admin-tab):not(.linkish):not(.admin-close-btn):not(.danger-btn):not(.role-manager-item):not(.role-manager-tab) {
  background: #404249; color: #fff; border-radius: 6px; padding: 6px 10px;
}
.admin-dash .field-label select {
  background: #1e1f22 !important;
  color: #dbdee1 !important;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
.admin-dash button.primary { background: #5865f2; color: #fff; }
.admin-dash button.primary:hover { background: #4752c4; }
.admin-dash .modal-help { color: #949ba4; }

@media (max-width: 860px) {
  .admin-modal {
    place-items: stretch;
    padding: 8px;
  }
  .admin-dash {
    grid-template-columns: 1fr;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 12px;
  }
  .admin-nav {
    flex-direction: row; flex-wrap: wrap; align-items: center;
    max-height: min(42vh, 280px); overflow: auto; flex-shrink: 0;
  }
  .admin-tabs { display: flex; flex-wrap: wrap; width: 100%; overflow: visible; }
  .admin-nav-foot { width: 100%; grid-template-columns: 1fr 1fr; }
  .stat-grid, .dash-cards, .dash-cards.two { grid-template-columns: 1fr 1fr; }
  .admin-top { flex-direction: column; }
  .admin-search-wrap { width: 100%; min-width: 0; }
  .admin-main { min-height: 0; overflow: hidden; }
}
@media (max-width: 520px) {
  .stat-grid, .dash-cards, .dash-cards.two { grid-template-columns: 1fr; }
}

.admin-dash .danger-btn,
.modal .danger-btn,
.channel-edit-foot .danger-btn,
.category-edit-foot .danger-btn,
.row .danger-btn,
.channel-perm-card .danger-btn,
.role-card .danger-btn,
.admin-media-row .danger-btn,
button.danger-btn,
.danger-btn {
  background: #da373c !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  border: none;
}
.admin-dash .danger-btn:hover,
.modal .danger-btn:hover,
.channel-edit-foot .danger-btn:hover,
.category-edit-foot .danger-btn:hover,
.row .danger-btn:hover,
.channel-perm-card .danger-btn:hover,
.role-card .danger-btn:hover,
.admin-media-row .danger-btn:hover,
button.danger-btn:hover,
.danger-btn:hover {
  background: #a12828 !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}
.modal .field-label {
  display: grid; gap: 6px; margin-bottom: 12px;
  font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
}
.modal .field-label input,
.modal .field-label select {
  text-transform: none; letter-spacing: normal; font-weight: 500;
  font-size: 0.9rem;
  background: var(--bg-lowest); color: var(--text);
  border: 1px solid var(--bg-highest); border-radius: 8px; padding: 10px 12px;
}

.channel-meta-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 2px 0 4px;
}
.channel-meta-label {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase; color: #949ba4;
}
.channel-meta-value {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  background: #1e1f22; color: #dbdee1;
  font-size: 0.78rem; font-weight: 600;
}
html[data-theme="light"] .channel-meta-value {
  background: #fff; color: #4e5058;
}
.admin-dash .channel-perm-card {
  background: #1e1f22; border-radius: 10px; padding: 12px 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
html[data-theme="light"] .admin-dash .channel-perm-card { background: #e3e5e8; }
.admin-dash .channel-perm-card .title { color: #fff; }
html[data-theme="light"] .admin-dash .channel-perm-card .title { color: #060607; }
.admin-dash .field-label {
  display: grid; gap: 6px;
  font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: #949ba4;
}
.admin-dash .field-label select,
.admin-dash .field-label input {
  text-transform: none; letter-spacing: normal; font-weight: 500;
  font-size: 0.9rem;
}
.category-admin-card .title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.category-admin-card .category-count {
  font-size: 0.72rem; font-weight: 700; color: #949ba4;
  text-transform: uppercase; letter-spacing: 0.03em;
}

/* Light theme */
html[data-theme="light"] {
  --bg-lowest: #f2f3f5;
  --bg-low: #e3e5e8;
  --bg-mid: #ffffff;
  --bg-high: #ebedef;
  --bg-highest: #d4d7dc;
  --bg-modifier: rgba(0, 0, 0, 0.06);
  --text: #2e3338;
  --text-muted: #5c6370;
  --text-strong: #060607;
  --header: #060607;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #248046;
  --red: #da373c;
  --yellow: #c28914;
  --mention-bg: rgba(88, 101, 242, 0.18);
  --mention-me: rgba(240, 178, 50, 0.22);
  --scrollbar-thumb: rgba(116, 127, 141, 0.45);
  --scrollbar-thumb-hover: rgba(79, 84, 92, 0.7);
  --scrollbar-track: transparent;
}

html[data-theme="light"] body { background: var(--bg-lowest); }
html[data-theme="light"] .auth-view {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(88, 101, 242, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(87, 242, 135, 0.12), transparent 50%),
    linear-gradient(160deg, #eef0f5 0%, #e3e7ef 100%);
}
html[data-theme="light"] .auth-card,
html[data-theme="light"] .qs-card,
html[data-theme="light"] .ctx-menu {
  background: #fff;
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  color: var(--text);
}
html[data-theme="light"] .auth-security-foot {
  border-top-color: rgba(0, 0, 0, 0.08);
}
html[data-theme="light"] .auth-security li {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
html[data-theme="light"] .auth-sec-icon {
  background: rgba(36, 128, 70, 0.08);
  color: #248046;
  box-shadow: inset 0 0 0 1px rgba(36, 128, 70, 0.22);
}
html[data-theme="light"] .ctx-menu { background: #fff; border-color: #e3e5e8; }
html[data-theme="light"] .ctx-item { color: #2e3338; }
html[data-theme="light"] .ctx-item:hover { background: var(--accent); color: #fff; }
html[data-theme="light"] .admin-dash { background: #f8f9fb; color: #2e3338; }
html[data-theme="light"] .admin-nav { background: #ebedef; }
html[data-theme="light"] .admin-main { background: #f2f3f5; }
html[data-theme="light"] .admin-tab { color: #4e5058; }
html[data-theme="light"] .admin-tab.active { background: #fff; color: #060607; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
html[data-theme="light"] .admin-brand strong,
html[data-theme="light"] .admin-top h2,
html[data-theme="light"] .dash-card h3,
html[data-theme="light"] .form-card h3,
html[data-theme="light"] .stat-card strong { color: #060607; }
html[data-theme="light"] .stat-card,
html[data-theme="light"] .dash-card,
html[data-theme="light"] .form-card { background: #fff; }
html[data-theme="light"] .admin-search-wrap input,
html[data-theme="light"] .admin-inline-search,
html[data-theme="light"] .choice-card,
html[data-theme="light"] .toggle-row,
html[data-theme="light"] .admin-dash .admin-row,
html[data-theme="light"] .admin-dash .allow-row,
html[data-theme="light"] .admin-dash .row input,
html[data-theme="light"] .admin-dash .field-label input {
  background: #e3e5e8; color: #2e3338;
}
html[data-theme="light"] .message:hover { background: rgba(0,0,0,0.04); }
html[data-theme="light"] .msg-actions { background: #fff; border-color: #d4d7dc; }
html[data-theme="light"] .guild-rail { background: #e3e5e8; }
html[data-theme="light"] .chat { background: #fff; }
html[data-theme="light"] .members { background: #f2f3f5; --status-platform: #f2f3f5; }
html[data-theme="light"] .composer { background: #ebedef; }
html[data-theme="light"] .user-panel { background: #ebedef; --status-platform: #ebedef; }
html[data-theme="light"] .sidebar { background: #f2f3f5; --status-platform: #f2f3f5; }
html[data-theme="light"] .user-menu {
  background: #fff; border-color: #e3e5e8;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
}
html[data-theme="light"] .user-menu-sep { background: #e3e5e8; }
html[data-theme="light"] .user-menu-item.active { background: rgba(88,101,242,0.12); }
html[data-theme="light"] .user-menu-scale-btn { background: #e3e5e8; color: #2e3338; }
html[data-theme="light"] .msg-day-divider-line { background: #e3e5e8; }
html[data-theme="light"] .profile-card-inner { background: #f2f3f5; }
html[data-theme="light"] .attach-preview .chip { background: #fff; border-color: #d4d7dc; }
html[data-theme="light"] .file-chip {
  background: #f2f3f5; border-color: #d4d7dc;
}

/* Roles editor / Role Manager (Discord-style) */
.roles-editor { display: grid; gap: 12px; }
.role-manager-card { min-height: 0; }
.role-manager {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  min-height: min(560px, 58vh);
  max-height: min(640px, 62vh);
  background: #1e1f22;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.role-manager-nav {
  background: #2b2d31;
  border-right: 1px solid rgba(0,0,0,0.28);
  min-height: 0;
  overflow: auto;
  padding: 8px;
}
.role-manager-list { display: grid; gap: 2px; align-content: start; }
.role-manager-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 6px;
  color: #dbdee1; background: transparent;
  font-weight: 600; font-size: 0.9rem;
}
.role-manager-item:hover { background: rgba(255,255,255,0.04); }
.role-manager-item.active { background: #404249; color: #fff; }
.role-manager-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.role-manager-item-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.role-manager-item-count {
  font-size: 0.72rem; font-weight: 700; color: #949ba4;
  background: rgba(0,0,0,0.25); border-radius: 999px;
  padding: 2px 7px; flex-shrink: 0;
}
.role-manager-main {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: #313338;
}
.role-manager-empty {
  margin: auto; color: #949ba4; font-weight: 600; padding: 32px;
}
.role-manager-detail {
  display: flex; flex-direction: column;
  min-height: 0; height: 100%;
}
.role-manager-detail.is-hidden { display: none !important; }
.role-manager-detail-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 10px; flex-shrink: 0;
}
.role-manager-detail-titles { min-width: 0; }
.role-manager-detail-titles h3 {
  margin: 0; font-size: 1.15rem; font-weight: 700; color: #fff;
}
.role-manager-tabs {
  display: flex; gap: 4px; padding: 0 18px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.25); flex-shrink: 0;
}
.role-manager-tab {
  padding: 8px 12px; border-radius: 6px;
  color: #b5bac1; font-weight: 600; font-size: 0.85rem;
}
.role-manager-tab:hover { background: rgba(255,255,255,0.04); color: #fff; }
.role-manager-tab.active { background: #404249; color: #fff; }
.role-manager-panels {
  flex: 1; min-height: 0; overflow: auto;
  padding: 16px 18px 20px;
}
.role-manager-panel { display: none; gap: 14px; }
.role-manager-panel.active { display: grid; align-content: start; }
.role-manager-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.role-members-add {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.role-members-nick {
  flex: 1; min-width: 160px;
  background: #1e1f22; border-radius: 8px;
}
.role-members-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 4px;
}
.role-members-head strong { color: #fff; font-size: 0.85rem; }
.role-members-head .admin-inline-search { max-width: 200px; }
.role-members-list {
  display: grid; gap: 4px;
  max-height: min(340px, 40vh); overflow: auto;
}
.role-member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: #1e1f22;
}
.role-member-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.role-member-meta .nick { font-weight: 700; }
html[data-theme="light"] .role-manager { background: #e3e5e8; }
html[data-theme="light"] .role-manager-nav { background: #f2f3f5; }
html[data-theme="light"] .role-manager-main { background: #fff; }
html[data-theme="light"] .role-manager-item.active { background: #e3e5e8; color: #060607; }
html[data-theme="light"] .role-manager-detail-titles h3,
html[data-theme="light"] .role-members-head strong { color: #060607; }
html[data-theme="light"] .role-member-row,
html[data-theme="light"] .role-members-nick { background: #f2f3f5; }
@media (max-width: 900px) {
  .role-manager {
    grid-template-columns: 1fr;
    max-height: none;
    min-height: 0;
  }
  .role-manager-nav {
    border-right: none;
    border-bottom: 1px solid rgba(0,0,0,0.2);
    max-height: 180px;
  }
}

.role-card {
  background: #1e1f22; border-radius: 12px; padding: 14px 16px; display: grid; gap: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
html[data-theme="light"] .role-card { background: #e3e5e8; }
.role-card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.role-card-swatch, .role-swatch-lg {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12), 0 0 0 1px rgba(0,0,0,0.35);
}
.role-card-titles { display: grid; gap: 2px; min-width: 0; flex: 1; }
.role-card-head strong, .role-preview-name {
  color: #fff; font-size: 1rem; font-weight: 700;
}
html[data-theme="light"] .role-card-head strong,
html[data-theme="light"] .role-preview-name { color: #060607; }
.role-card-tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.role-name-input {
  max-width: 180px; min-width: 120px; flex: 1;
  background: #2b2d31 !important; border: none; border-radius: 8px;
  padding: 10px 12px; color: #dbdee1;
}
html[data-theme="light"] .role-name-input {
  background: #fff !important; color: #060607;
}

.role-create-row { align-items: center; }
.role-live-preview {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
  padding: 10px 12px; border-radius: 10px; background: #1e1f22;
}
html[data-theme="light"] .role-live-preview { background: #fff; }
.role-live-preview .role-preview-name { font-weight: 800; font-size: 1rem; }

.role-color-pair {
  display: inline-flex; align-items: center; gap: 8px;
}
.role-color-pick {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%;
  overflow: hidden; cursor: pointer; flex-shrink: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18), 0 0 0 1px rgba(0,0,0,0.4);
  transition: transform .15s ease, box-shadow .15s ease;
}
.role-color-pick:hover { transform: scale(1.06); }
.role-color-pick.is-secondary.is-empty {
  background:
    linear-gradient(135deg, transparent 46%, rgba(255,255,255,0.35) 46%, rgba(255,255,255,0.35) 54%, transparent 54%),
    repeating-conic-gradient(#3f4147 0% 25%, #2b2d31 0% 50%) 50% / 10px 10px !important;
  opacity: 0.7;
}
.role-color-pick input[type="color"] {
  position: absolute; inset: -10px;
  width: calc(100% + 20px); height: calc(100% + 20px);
  border: none; padding: 0; margin: 0; cursor: pointer;
  opacity: 0; background: transparent;
}
.role-color-pick input[type="color"]:disabled { pointer-events: none; }
.role-color-chip {
  min-width: 28px; height: 28px; padding: 0 8px !important;
  border-radius: 999px !important; font-size: 0.75rem; font-weight: 700;
  background: #404249 !important; color: #dbdee1 !important;
  line-height: 1;
}
.role-color-chip.is-hidden { display: none !important; }
.role-live-swatch { width: 22px; height: 22px; }

.role-perms { display: grid; gap: 14px; }
.perm-group-title, .perm-legend-group h4 {
  margin: 0 0 8px; font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase; color: #949ba4;
}
.role-card .perm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px;
}
.perm-toggle {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: #2b2d31;
  box-shadow: inset 0 0 0 1px transparent;
  transition: background .15s ease, box-shadow .15s ease;
}
.perm-toggle.is-locked { opacity: 0.55; cursor: not-allowed; }
.perm-toggle.is-locked:hover { background: #2b2d31; }
.perm-toggle:has(input:checked) {
  background: rgba(88,101,242,0.14);
  box-shadow: inset 0 0 0 2px #5865f2;
}
.perm-toggle input {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.perm-switch {
  width: 36px; height: 20px; border-radius: 999px; flex-shrink: 0; margin-top: 1px;
  background: #4e5058; position: relative; transition: background .15s ease;
}
.perm-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.perm-toggle input:checked + .perm-switch { background: #5865f2; }
.perm-toggle input:checked + .perm-switch::after { transform: translateX(16px); }
.perm-toggle-copy { min-width: 0; display: grid; gap: 2px; }
.perm-toggle-copy strong {
  color: #f2f3f5; font-size: 0.84rem; font-weight: 650; line-height: 1.25;
}
.perm-toggle-copy small {
  color: #949ba4; font-size: 0.72rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
html[data-theme="light"] .perm-toggle { background: #fff; }
html[data-theme="light"] .perm-toggle:hover { background: #f2f3f5; }
html[data-theme="light"] .perm-toggle:has(input:checked) { background: rgba(88,101,242,0.1); }
html[data-theme="light"] .perm-toggle-copy strong { color: #060607; }

.perm-legend { display: grid; gap: 14px; }
.perm-legend-group { display: grid; gap: 6px; }
.perm-legend-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 12px; background: #1e1f22; border-radius: 10px; font-size: 0.85rem;
}
html[data-theme="light"] .perm-legend-row { background: #e3e5e8; }
.perm-legend code { color: var(--accent); font-size: 0.75rem; }
.role-tag-custom {
  background: var(--role-fill, var(--role-color, var(--accent))) !important;
  color: #fff !important;
}
.nick-role.has-gradient,
.member-name.has-gradient,
.role-preview-name.has-gradient,
.admin-user-meta .nick.has-gradient,
#profile-nick.has-gradient,
#profile-role.has-gradient,
#me-nick.has-gradient {
  background-image: var(--role-fill);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
}

.logo-mark {
  background: linear-gradient(135deg, #5865f2, #57f287);
}

/* Attachments + lightbox */
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; align-items: flex-start; max-width: 100%; min-width: 0; }
.attach-image {
  padding: 0; border: none; background: transparent; border-radius: 8px; overflow: hidden;
  cursor: zoom-in; max-width: min(400px, 100%);
}
.attach-image img {
  max-width: min(400px, 100%); max-height: 300px; border-radius: 8px;
  display: block; object-fit: cover;
}
.attach-image:hover img { filter: brightness(1.05); }
.attach-media {
  display: grid; gap: 6px; max-width: min(400px, 100%); min-width: 0;
}
.attach-media video { width: 100%; max-width: 100%; border-radius: 8px; background: #000; }
.attach-media.audio { min-width: 0; width: min(100%, 360px); }
.attach-media audio { width: 100%; max-width: 100%; }

/* Discord-style inline video embed (landscape vs phone/portrait) */
.attach-video {
  width: min(520px, 100%);
  max-width: 100%;
  background: #2b2d31;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
  overflow-anchor: none;
}
.attach-video.is-pending-orient { opacity: 0.92; }
.attach-video-player {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: min(360px, 50vh);
}
.attach-video.is-landscape {
  width: min(520px, 100%);
}
.attach-video.is-landscape .attach-video-player {
  aspect-ratio: 16 / 9;
  max-height: min(360px, 50vh);
}
/* Vertical / phone-style clip */
.attach-video.is-portrait {
  width: min(260px, 72vw);
  border-radius: 14px;
  background: #111214;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 10px 28px rgba(0,0,0,0.35);
}
.attach-video.is-portrait .attach-video-player {
  aspect-ratio: 9 / 16;
  max-height: min(480px, 62vh);
  border-radius: 14px 14px 0 0;
}
.attach-video.is-portrait .attach-video-bar {
  background: #1a1b1e;
  padding: 10px 12px;
}
.attach-video-player video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.attach-video.is-portrait .attach-video-player video {
  object-fit: cover;
}
.attach-video-player { cursor: pointer; }
.attach-video.is-playing .attach-video-player { cursor: default; }

/* Discord-style center play button */
.attach-video-play {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: #fff;
}
.attach-video-play-disc {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.92),
    0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.attach-video-play-disc svg {
  margin-left: 3px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.attach-video-play:hover .attach-video-play-disc,
.attach-video-player:hover .attach-video-play-disc {
  transform: scale(1.08);
  background: rgba(88, 101, 242, 0.88);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.95),
    0 10px 28px rgba(88, 101, 242, 0.35);
}
.attach-video-play:active .attach-video-play-disc {
  transform: scale(0.96);
}
.attach-video.is-playing .attach-video-play {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.attach-video.is-paused .attach-video-play {
  opacity: 1;
  pointer-events: auto;
}
.attach-video.is-paused .attach-video-player::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0,0,0,0.18), rgba(0,0,0,0.08) 40%, rgba(0,0,0,0.28));
  pointer-events: none;
}
.attach-video.is-portrait .attach-video-play-disc {
  width: 58px;
  height: 58px;
}
.attach-video.is-portrait .attach-video-play-disc svg {
  width: 28px;
  height: 28px;
}
.attach-video-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: #232428;
}
.attach-video-meta { min-width: 0; display: grid; gap: 2px; }
.attach-video-name {
  font-size: 0.85rem; font-weight: 700; color: #f2f3f5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-video .file-size { font-size: 0.72rem; color: #949ba4; }
.attach-video.is-broken .attach-video-player::after {
  content: 'Preview unavailable — use Download';
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #b5bac1; font-size: 0.85rem; font-weight: 600;
  background: rgba(0,0,0,0.72); padding: 12px; text-align: center;
}
.attach-video.is-broken video { opacity: 0; }
.video-chip-preview {
  display: flex; align-items: center; gap: 8px;
  max-width: 220px;
}
.video-chip-preview video {
  width: 56px; height: 40px; object-fit: cover; border-radius: 6px; background: #000;
}
html[data-theme="light"] .attach-video { background: #e3e5e8; }
html[data-theme="light"] .attach-video.is-portrait { background: #eceef0; }
html[data-theme="light"] .attach-video-bar,
html[data-theme="light"] .attach-video.is-portrait .attach-video-bar { background: #f2f3f5; }
html[data-theme="light"] .attach-video-name { color: #060607; }

@media (max-width: 640px) {
  .attach-video.is-portrait { width: min(220px, 68vw); }
  .attach-video.is-portrait .attach-video-player { max-height: min(420px, 58vh); }
}
.file-download-link, .file-download-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; font-weight: 600; color: var(--accent); text-decoration: none;
  flex-shrink: 0;
}
.file-download-link:hover, .file-download-btn:hover { text-decoration: underline; color: var(--accent-hover); }
.file-download-locked {
  font-size: 0.75rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-low); border-radius: 8px;
  border: 1px solid var(--bg-highest); color: var(--text);
  max-width: min(360px, 100%);
}
.file-chip-meta { min-width: 0; flex: 1; display: grid; gap: 2px; }
.file-chip-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text-strong);
}
.file-size { font-size: 0.75rem; color: var(--text-muted); }
.file-download-btn {
  flex-shrink: 0; padding: 6px 10px; border-radius: 6px;
  background: var(--bg-modifier); color: var(--text-strong); text-decoration: none;
}
.file-download-btn:hover { background: var(--accent); color: #fff; text-decoration: none; }

.lightbox {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0,0,0,0.88);
  display: grid; grid-template-rows: 1fr auto;
  place-items: center; padding: 56px 16px 16px;
  gap: 12px;
}
.lightbox.is-hidden { display: none !important; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
  color: #fff; background: rgba(255,255,255,0.1); border-radius: 8px; z-index: 2;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); color: #fff; }
.lightbox-stage {
  min-width: 0; min-height: 0;
  width: 100%; height: 100%;
  display: grid; place-items: center;
}
.lightbox img,
.lightbox-stage img {
  max-width: min(96vw, 1200px); max-height: calc(100dvh - 140px);
  object-fit: contain; border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.lightbox-stage video,
#lightbox-video {
  display: block;
  background: #000;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  object-fit: contain;
}
/* Maximized landscape: wide embed, never forced edge-to-edge */
.lightbox.is-video.is-landscape .lightbox-stage video,
.lightbox-stage.is-landscape video {
  width: min(92vw, 1100px);
  height: auto;
  max-width: min(92vw, 1100px);
  max-height: calc(100dvh - 140px);
  aspect-ratio: 16 / 9;
}
/* Maximized portrait: phone-style frame, not full width */
.lightbox.is-video.is-portrait .lightbox-stage video,
.lightbox-stage.is-portrait video {
  width: auto;
  height: min(84dvh, 820px);
  max-width: min(420px, 78vw);
  max-height: calc(100dvh - 140px);
  aspect-ratio: 9 / 16;
  border-radius: 16px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    0 18px 48px rgba(0,0,0,0.55);
}
.lightbox-bar {
  display: flex; align-items: center; gap: 16px; justify-content: center;
  width: min(96vw, 800px); padding: 12px 16px; color: #fff;
  background: rgba(0,0,0,0.35); border-radius: 10px;
}
.lightbox.is-portrait .lightbox-bar { width: min(420px, 78vw); }
.lightbox-bar span {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem;
}
.lightbox-download {
  color: #fff; font-weight: 700; text-decoration: none;
  padding: 8px 12px; border-radius: 6px; background: var(--accent);
}
.lightbox-download:hover { background: var(--accent-hover); }
.lightbox-download.is-hidden { display: none !important; }

.attach-video-maximize {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.18);
  opacity: 0; transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.attach-video-player:hover .attach-video-maximize,
.attach-video.is-paused .attach-video-maximize,
.attach-video.is-playing .attach-video-maximize:focus-visible {
  opacity: 1;
}
.attach-video-maximize:hover {
  background: rgba(88, 101, 242, 0.9);
  transform: scale(1.05);
}
.attach-video-actions {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.attach-video-actions .file-download-link {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
}
/* Keep browser fullscreen from stretching portrait clips */
.attach-video-player video:fullscreen,
#lightbox-video:fullscreen {
  object-fit: contain;
  background: #000;
}

/* User profile — Discord-like popout + Profiles dashboard */
.profile-modal {
  padding: 0; border: none; background: transparent;
  width: auto; max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  overflow: visible;
}
.profile-modal::backdrop { background: rgba(0,0,0,0.78); }
.profile-modal.is-dashboard {
  width: min(980px, calc(100vw - 32px));
  max-height: min(90vh, calc(100dvh - 24px));
}
.profile-modal.is-dashboard .profile-card { display: none !important; }
.profile-modal:not(.is-dashboard) .profile-dashboard { display: none !important; }
.profile-card {
  width: min(380px, 92vw);
  max-height: min(85vh, calc(100dvh - 24px));
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-mid); border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  -webkit-overflow-scrolling: touch;
}
.profile-banner {
  height: 120px; background: linear-gradient(135deg, var(--accent), #3ba55d);
  position: relative; margin: 0; border: none; box-shadow: none;
  flex-shrink: 0;
}
.profile-close {
  position: absolute; top: 8px; right: 8px; color: #fff;
  background: rgba(0,0,0,0.35); border-radius: 50%;
  z-index: 2;
}
.profile-close:hover { background: rgba(0,0,0,0.55); color: #fff; }
.profile-body {
  padding: 0 16px 16px; margin-top: -50px; display: grid; gap: 0;
}
.profile-avatar-wrap {
  position: relative; width: 92px; height: 92px; margin-bottom: 8px;
}
.profile-avatar-lg {
  width: 80px; height: 80px; border-radius: 50%;
  border: 6px solid var(--bg-mid); font-size: 1.45rem;
  display: grid; place-items: center; color: #fff; font-weight: 800;
  overflow: hidden; background: var(--accent);
  box-sizing: content-box;
}
.profile-avatar-wrap .status-dot,
.profile-avatar-wrap .status-badge {
  position: absolute; right: 2px; bottom: 2px;
  width: 22px; height: 22px;
  border: none;
  background: var(--bg-mid);
}
.profile-avatar-wrap .status-badge svg {
  width: 14px;
  height: 14px;
}
.profile-avatar-lg.has-img { padding: 0; }
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.profile-card-inner {
  background: var(--bg-lowest); border-radius: 8px;
  padding: 12px; display: grid; gap: 10px;
  min-width: 0;
}
.profile-body h2 {
  margin: 0; font-size: 1.25rem; color: var(--text-strong); line-height: 1.2;
}
.profile-handle {
  margin: 2px 0 0; font-size: 0.85rem; color: var(--text-muted);
}
.profile-section {
  padding-top: 10px; border-top: 1px solid var(--bg-highest);
}
.profile-section-title {
  margin: 0 0 6px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.profile-role {
  margin: 0; font-size: 0.85rem; font-weight: 600;
  color: var(--role-color, var(--text));
}
.profile-desc {
  margin: 0; color: var(--text); font-size: 0.875rem;
  line-height: 1.4; white-space: pre-wrap; word-break: break-word;
}
.profile-desc:empty::before {
  content: 'No bio yet.';
  color: var(--text-muted); font-style: italic;
}
.profile-rewards-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.profile-rewards-head .profile-section-title,
.profile-rewards-head h3 { margin: 0; }
.profile-rewards-month-pick select {
  appearance: none; -webkit-appearance: none;
  background: rgba(0,0,0,0.22); color: var(--text);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 6px;
  padding: 4px 28px 4px 10px; font-size: 0.75rem; font-weight: 600;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  max-width: 160px;
}
.profile-reward-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
  margin: 0 0 10px;
}
.profile-reward-stats.is-compact { gap: 4px; margin-bottom: 8px; }
.profile-reward-stat {
  display: grid; gap: 2px; padding: 8px 8px; border-radius: 6px;
  background: rgba(0,0,0,0.18); min-width: 0;
}
.profile-reward-stat.is-win { background: rgba(88, 101, 242, 0.14); }
.profile-reward-stat-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--text-muted);
}
.profile-reward-stat strong {
  font-size: 0.9rem; font-variant-numeric: tabular-nums;
  color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-reward-stat strong.pos { color: #23a559; }
.profile-reward-stat strong.neg { color: #ed4245; }
.profile-reward-stat.is-win strong.pos { color: #23a559; }
.profile-reward-stat.is-win strong.neg { color: #ed4245; }
.profile-rewards-month {
  margin: 0 0 8px; font-size: 0.8rem; color: var(--text-muted);
}
.profile-rewards-list {
  display: grid; gap: 6px; max-height: 180px; overflow: auto;
}
.stat-card strong.pos { color: #23a559; }
.stat-card strong.neg { color: #ed4245; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.profile-reward-item {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px;
  padding: 8px 10px; border-radius: 6px;
  background: rgba(0,0,0,0.18);
  font-size: 0.8rem;
}
.profile-reward-item.is-deduction { background: rgba(237, 66, 69, 0.12); }
.profile-reward-item.is-bonus { background: rgba(35, 165, 89, 0.12); }
.profile-reward-amt {
  font-weight: 700; font-variant-numeric: tabular-nums;
  grid-row: 1 / span 2; align-self: center;
}
.profile-reward-amt.pos { color: #23a559; }
.profile-reward-amt.neg { color: #ed4245; }
.profile-reward-msg {
  color: var(--text); line-height: 1.35; word-break: break-word;
}
.profile-reward-meta {
  color: var(--text-muted); font-size: 0.72rem;
}
.profile-rewards-empty {
  margin: 0; color: var(--text-muted); font-size: 0.8rem; font-style: italic;
}

.reward-form-grid {
  display: grid; grid-template-columns: 1.4fr 0.8fr 0.8fr; gap: 10px;
}
.reward-month-label { margin: 0; min-width: 140px; }
.reward-month-label input { margin-top: 4px; }
.reward-stat-grid { margin: 12px 0 16px; }
.reward-subhead {
  margin: 0 0 8px; font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.reward-summary-list, .reward-history-list {
  display: grid; gap: 6px; max-height: 280px; overflow: auto;
}
.reward-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px 12px;
  align-items: center; padding: 10px 12px; border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.reward-row-main { min-width: 0; }
.reward-row-name { font-weight: 600; color: var(--text-strong); }
.reward-row-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.reward-row-amt {
  font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.reward-row-amt.pos { color: #23a559; }
.reward-row-amt.neg { color: #ed4245; }
.reward-row-actions { display: flex; gap: 6px; }
.reward-history-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px;
  align-items: start; padding: 10px 12px; border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.reward-history-item .reward-row-amt { padding-top: 2px; }
.api-scope-grid {
  display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 12px 0;
}
.api-scope-grid label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--text); cursor: pointer;
}
.api-keys-list { display: grid; gap: 8px; margin-top: 12px; max-height: 320px; overflow: auto; }
.api-key-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px;
  padding: 10px 12px; border-radius: 6px; background: rgba(255,255,255,0.03);
}
.api-key-row-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.api-docs-sample {
  margin: 0; padding: 12px 14px; border-radius: 8px;
  background: rgba(0,0,0,0.28); color: var(--text);
  font-size: 0.75rem; line-height: 1.45; overflow: auto; white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bots-list { display: grid; gap: 10px; margin-top: 14px; max-height: 420px; overflow: auto; }
.bot-row {
  display: grid; gap: 8px;
  padding: 12px 14px; background: rgba(255,255,255,0.03); border-radius: 8px;
}
.bot-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bot-row-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bot-row-title strong { color: var(--text-strong); }
.bot-row-avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: #f7931a;
}
.bot-badge {
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  background: #5865f2; color: #fff; padding: 2px 6px; border-radius: 4px;
}
.bot-row-meta { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.bot-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bot-token-banner {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: rgba(88, 101, 242, 0.15); border: 1px solid rgba(88, 101, 242, 0.35);
  color: var(--text-strong); word-break: break-all;
}
.bot-token-banner code { color: #c9cdfb; }
.meta .bot-tag {
  font-size: 0.62rem; font-weight: 800; text-transform: uppercase;
  background: #5865f2; color: #fff; padding: 1px 5px; border-radius: 3px; margin-left: 4px;
}
@media (max-width: 720px) {
  .reward-form-grid { grid-template-columns: 1fr; }
  .reward-row { grid-template-columns: 1fr auto; }
  .reward-history-item { grid-template-columns: auto 1fr; }
}
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 3px; font-size: 0.8rem; font-weight: 600;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
}
.file-btn:hover { background: var(--accent-hover); }
.file-btn.ghost {
  background: transparent; color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--bg-highest);
}
.file-btn.ghost:hover { color: var(--text); background: var(--bg-modifier); }
.file-chosen-name {
  display: block; margin-top: 4px; font-size: 0.75rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-actions {
  margin-top: 4px; display: flex; gap: 8px;
}
.profile-actions .primary { flex: 1; }

/* Profiles dashboard (Discord User Settings → Profiles) */
.profile-dashboard {
  width: min(980px, calc(100vw - 32px));
  max-height: min(90vh, calc(100dvh - 24px));
  display: flex; flex-direction: column;
  background: #313338;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
}
.profile-dashboard.is-hidden { display: none !important; }
.profile-dash-section.is-hidden { display: none !important; }
.nitro-badge.is-hidden { display: none !important; }
.profile-dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 20px 24px 12px; flex-shrink: 0;
  background: #2b2d31; border-bottom: 1px solid rgba(0,0,0,0.25);
}
.profile-dash-title h2 {
  margin: 0; font-size: 1.25rem; font-weight: 700; color: #f2f3f5;
}
.profile-dash-title p {
  margin: 4px 0 0; font-size: 0.85rem; color: #949ba4;
}
.profile-dash-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 28px;
  padding: 20px 24px;
  overflow: auto;
}
.profile-dash-form {
  display: grid; gap: 22px; align-content: start; min-width: 0;
}
.profile-dash-section h3 {
  margin: 0 0 4px; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: #b5bac1;
}
.profile-dash-help {
  margin: 0 0 10px; font-size: 0.8rem; color: #949ba4; line-height: 1.35;
}
.profile-dash-form input[type="text"],
.profile-dash-form input:not([type]),
.profile-dash-form #profile-display-input,
.profile-dash-form #profile-nick-input,
.profile-dash-form textarea {
  width: 100%; max-width: 100%;
  background: #1e1f22; color: #dbdee1;
  border: none; border-radius: 4px;
  padding: 10px 12px; font: inherit;
  outline: none;
}
.profile-dash-form textarea { min-height: 96px; resize: vertical; }
.profile-dash-form input:focus,
.profile-dash-form textarea:focus {
  box-shadow: 0 0 0 2px rgba(88,101,242,0.45);
}
.profile-dash-nick { background: #1e1f22; border-radius: 4px; }
.profile-dash-nick .hash { color: #949ba4; }
.profile-dash-nick input { background: transparent !important; box-shadow: none !important; }
.profile-media-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.profile-media-thumb {
  flex-shrink: 0; border-radius: 8px; overflow: hidden;
  background: #1e1f22; border: 1px solid rgba(255,255,255,0.06);
}
.profile-media-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 1.4rem;
}
.profile-media-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-media-banner {
  width: min(260px, 100%); height: 92px;
  background: linear-gradient(135deg, var(--accent), #3ba55d);
  background-size: cover; background-position: center;
}
.profile-media-actions { display: grid; gap: 8px; justify-items: start; }
.profile-accent-row {
  margin-top: 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.06);
}
.profile-accent-row input[type="color"] {
  width: 56px; height: 40px; padding: 0; border: none;
  background: transparent; cursor: pointer; border-radius: 4px;
}
.profile-char-count {
  display: block; margin-top: 6px; text-align: right;
  font-size: 0.72rem; color: #949ba4;
}
.profile-dash-preview-col {
  position: sticky; top: 0; align-self: start;
  display: grid; gap: 10px;
}
.profile-dash-preview-label {
  margin: 0; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: #b5bac1;
}
.profile-preview-card {
  width: 100%; max-width: 340px;
  background: #232428; border-radius: 8px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.profile-preview-card .profile-banner { height: 100px; margin: 0; }
.profile-preview-card .profile-body { padding: 0 12px 12px; margin-top: -44px; }
.profile-preview-card .profile-avatar-lg {
  width: 72px; height: 72px; border-width: 6px; border-color: #232428; font-size: 1.25rem;
}
.profile-preview-card .profile-card-inner {
  background: #111214; border-radius: 8px; padding: 12px; gap: 8px;
}
.profile-preview-card .profile-body h2 { font-size: 1.1rem; }
.profile-dash-footer {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 16px 16px; padding: 12px 16px;
  background: #111214; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  animation: toast-in 0.16s ease-out;
}
.profile-dash-footer.is-hidden { display: none !important; }
.profile-dash-footer-msg {
  font-size: 0.9rem; font-weight: 600; color: #f2f3f5;
}
.profile-dash-footer-actions { display: flex; gap: 8px; margin-left: auto; }
.profile-dash-footer .primary:disabled {
  opacity: 0.45; cursor: default;
}
@media (max-width: 820px) {
  .profile-modal.is-dashboard {
    width: min(100vw - 16px, 980px);
    max-height: calc(100dvh - 12px);
  }
  .profile-dashboard {
    width: 100%;
    max-height: calc(100dvh - 12px);
  }
  .profile-dash-body {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 16px;
  }
  .profile-dash-preview-col { position: static; }
  .profile-preview-card { max-width: none; }
  .profile-dash-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 0;
    border-radius: 0;
    border-top: 1px solid rgba(0,0,0,0.25);
  }
}
.user-panel .avatar { cursor: pointer; }
.message .avatar { cursor: pointer; }
.member-item { cursor: pointer; }

/* Boost / Nitro-style premium */
.nitro-badge {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, #ff73fa, #5865f2 55%, #00d4ff);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 115, 250, 0.45);
  vertical-align: middle;
}
.nitro-badge svg { display: block; }
.nick-premium, .name-premium, .member-name.name-premium, #profile-nick.nick-premium {
  background: linear-gradient(90deg, var(--premium-accent, #ff73fa), #5865f2, #00d4ff, var(--premium-accent, #ff73fa));
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  font-weight: 800;
  animation: premium-shine 5s linear infinite;
}
@keyframes premium-shine {
  to { background-position: 220% center; }
}
.avatar.premium, .profile-avatar-lg.premium {
  position: relative;
  box-shadow:
    0 0 0 2px var(--bg-mid, #313338),
    0 0 0 4px var(--premium-accent, #ff73fa),
    0 0 14px color-mix(in srgb, var(--premium-accent, #ff73fa) 55%, transparent);
}
.profile-avatar-lg.premium {
  box-shadow:
    0 0 0 4px var(--bg-mid, #313338),
    0 0 0 7px var(--premium-accent, #ff73fa),
    0 0 18px color-mix(in srgb, var(--premium-accent, #ff73fa) 50%, transparent);
}
.profile-card.is-premium,
.profile-preview-card.is-premium {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--premium-accent, #ff73fa) 40%, transparent),
    0 12px 40px rgba(0,0,0,0.35);
}
.profile-banner.has-image {
  background-size: cover !important;
  background-position: center !important;
}
.profile-name-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 0;
}
.profile-name-row h2 { margin: 0; }
#profile-boost-edit.is-hidden { display: none !important; }
html[data-theme="light"] .profile-dashboard { background: #fff; }
html[data-theme="light"] .profile-dash-header { background: #f2f3f5; border-bottom-color: #e3e5e8; }
html[data-theme="light"] .profile-dash-title h2 { color: #060607; }
html[data-theme="light"] .profile-dash-form input,
html[data-theme="light"] .profile-dash-form textarea,
html[data-theme="light"] .profile-dash-nick { background: #e3e5e8; color: #2e3338; }
html[data-theme="light"] .profile-preview-card { background: #f2f3f5; }
html[data-theme="light"] .profile-preview-card .profile-card-inner { background: #fff; }
html[data-theme="light"] .profile-preview-card .profile-avatar-lg { border-color: #f2f3f5; }
html[data-theme="light"] .profile-dash-footer { background: #ebedef; }
html[data-theme="light"] .profile-dash-footer-msg { color: #060607; }
.admin-row .boost-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 700; color: #ff73fa;
  text-transform: uppercase; letter-spacing: 0.03em;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.admin-row .boost-toggle input { accent-color: #ff73fa; cursor: pointer; }
.meta .nick { display: inline-flex; align-items: center; gap: 4px; }
.meta .nick .nick-handle {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85em;
}
.meta .nick .nitro-badge { flex-shrink: 0; }

/* Message edit (Discord-style) */
.msg-edited {
  display: inline; margin-left: 4px; font-size: 0.7rem; font-weight: 500;
  color: var(--text-muted); opacity: 0.9; white-space: nowrap;
  vertical-align: baseline;
}
.content .msg-edited { cursor: help; }
.message.is-editing {
  background: rgba(88, 101, 242, 0.08);
  border-radius: 4px;
}
.msg-edit-box { margin-top: 4px; display: grid; gap: 6px; }
.msg-edit-input {
  width: 100%; min-height: 44px; max-height: 200px; resize: vertical;
  background: var(--bg-lowest); color: var(--text);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px 12px; font: inherit; line-height: 1.375;
}
.msg-edit-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(88,101,242,0.25); }
.msg-edit-actions { display: flex; align-items: center; gap: 8px; }
.msg-edit-hint {
  font-size: 0.75rem; color: var(--text-muted);
}
.msg-edit-hint .linkish {
  background: none; border: none; padding: 0; color: var(--accent);
  font: inherit; font-weight: 600; cursor: pointer;
}
.msg-edit-hint .linkish:hover { text-decoration: underline; }

/* Display names + role color styling */
.nick-role, .name-role, #profile-nick.nick-role {
  color: var(--role-color, var(--text-strong));
  font-weight: 700;
}
.nick-handle, .member-handle, .profile-handle, .admin-user-handle {
  display: inline; margin-left: 6px;
  font-size: 0.75rem; font-weight: 500; color: var(--text-muted);
}
.profile-handle { margin: 0; display: block; }
.member-item .role-tag { display: none; }
.meta .role-tag {
  font-size: 0.7rem; padding: 1px 6px; border-radius: 4px;
  color: #fff; font-weight: 700;
}
.admin-create-user { flex-wrap: wrap; align-items: center; }
.admin-create-user input, .admin-create-user select {
  min-width: 120px; flex: 1;
}
.admin-role-swatch {
  width: 10px; height: 32px; border-radius: 4px; flex-shrink: 0;
  background: var(--role-fill, var(--role-color, #949ba4));
}
.admin-user-meta { flex: 1; min-width: 80px; display: grid; gap: 1px; }
.admin-user-meta .nick { font-weight: 700; }
.admin-nick-input,
.admin-display-input {
  max-width: 140px; font-size: 0.85rem;
  background: var(--bg-lowest, #1e1f22); color: var(--text);
  border: 1px solid var(--bg-highest, #3f4147); border-radius: 4px; padding: 6px 8px;
}
.admin-nick-input { max-width: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.admin-dash .admin-nick-input,
.admin-dash .admin-display-input { background: #1e1f22; color: #dbdee1; border-color: #3f4147; }
.profile-role {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 800 !important;
}

/* Upload progress */
.upload-progress {
  display: grid; gap: 6px; margin: 0 0 8px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-lowest); border: 1px solid var(--bg-highest);
}
.upload-progress-track {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--bg-modifier);
}
.upload-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #57f287);
  transition: width 0.12s ease-out;
}
#upload-progress-label {
  font-size: 0.75rem; color: var(--text-muted); font-weight: 600;
}
#btn-attach:disabled { opacity: 0.45; cursor: wait; }

/* Admin media library */
.media-kind-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px;
}
.media-kind-tab {
  background: #2b2d31; color: var(--text-muted); border: 0;
  padding: 6px 10px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.media-kind-tab:hover { color: var(--text-strong, #fff); background: #35373c; }
.media-kind-tab.active {
  background: var(--accent, #5865f2); color: #fff;
}
html[data-theme="light"] .media-kind-tab { background: #e3e5e8; color: #4e5058; }
html[data-theme="light"] .media-kind-tab:hover { background: #d4d7dc; color: #060607; }
html[data-theme="light"] .media-kind-tab.active { background: var(--accent, #5865f2); color: #fff; }
.media-toolbar { margin: 8px 0; gap: 8px; flex-wrap: wrap; }
.media-channel-tools {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 8px 0;
}
.media-channel-tools.is-hidden,
#btn-media-purge-kind.is-hidden,
#btn-media-delete-selected.is-hidden {
  display: none !important;
}
.media-channel-tools .field-label { flex: 1; min-width: 180px; margin: 0; }
.media-channel-tools select { width: 100%; }
.admin-media-list { display: grid; gap: 8px; max-height: 55vh; overflow: auto; margin-top: 10px; }
.admin-media-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: #1e1f22;
}
html[data-theme="light"] .admin-media-row { background: #e3e5e8; }
.media-check { display: grid; place-items: center; }
.media-preview { flex-shrink: 0; }
.media-thumb {
  width: 48px; height: 48px; border-radius: 6px; object-fit: cover; display: block;
  background: #111;
}
.media-thumb-file {
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  color: #fff; background: #3f4147;
}
.media-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.media-name {
  color: var(--text-strong, #fff); font-weight: 600; font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none;
}
.media-name:hover { text-decoration: underline; }
.media-sub { font-size: 0.75rem; color: var(--text-muted); }

/* Force readable labels on red destructive buttons (beats inherit / theme overrides) */
button.danger-btn,
.danger-btn,
.row button.danger-btn,
.admin-dash button.danger-btn,
.modal button.danger-btn,
html[data-theme="light"] button.danger-btn,
html[data-theme="light"] .danger-btn {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background-color: #da373c !important;
}
button.danger-btn:hover,
.danger-btn:hover,
.row button.danger-btn:hover,
.admin-dash button.danger-btn:hover,
.modal button.danger-btn:hover,
html[data-theme="light"] button.danger-btn:hover,
html[data-theme="light"] .danger-btn:hover {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background-color: #a12828 !important;
}
button.danger,
.user-menu-item.danger {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
