@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Discord "dark" palette */
  --bg: #313338;           /* main chat area */
  --bg-2: #2b2d31;         /* channel/DM sidebar */
  --bg-3: #383a40;         /* hover + elevated surfaces, chips, inputs-in-context */
  --bg-4: #404249;         /* active channel / stronger surface */
  --bg-input: #1e1f22;     /* text inputs, search */
  --bg-rail: #1e1f22;      /* server rail */
  --bg-floating: #111214;  /* deep popovers / tooltips */
  --border: #232428;
  --border-strong: #3f4147;
  --text: #dbdee1;
  --text-bright: #f2f3f5;
  --muted: #949ba4;
  --muted-2: #80848e;
  --accent: #5865f2;       /* blurple */
  --accent-hover: #4752c4;
  --accent-press: #3c45a5;
  --accent-soft: rgba(88, 101, 242, 0.15);
  --accent-2: #00a8fc;     /* link blue */
  --danger: #f23f43;
  --ok: #23a55a;           /* online green */
  --warn: #f0b232;         /* idle yellow */
  --rail-w: 72px;
  --side-w: 240px;
  --right-w: 300px;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 8px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 0 rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(4,4,5,0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Inter", "gg sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.app-page { height: 100vh; height: 100dvh; overflow: hidden; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select {
  font: inherit; color: inherit;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}
button {
  cursor: pointer; background: var(--accent); border-color: var(--accent);
  color: white; font-weight: 500; letter-spacing: 0;
  box-shadow: none;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active { background: var(--accent-press); transform: translateY(0.5px); }
button:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent; color: var(--text); border-color: var(--border);
  font-weight: 500; box-shadow: none;
}
button.ghost:hover { background: var(--bg-3); border-color: var(--border-strong); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); box-shadow: none; }
button.danger:hover { background: rgba(255, 92, 124, 0.12); }
button.icon-btn { padding: 7px 10px; }
input, textarea, select { background: var(--bg-input); border-color: var(--border); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover:not(:focus), textarea:hover:not(:focus), select:hover:not(:focus) { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238a90a3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); background-clip: padding-box; }

/* Landing (kept) */
.landing { max-width: 920px; margin: 0 auto; padding: 60px 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.hero { padding: 60px 0 40px; }
.hero h1 { font-size: 56px; line-height: 1.05; margin: 0 0 16px; letter-spacing: -1px; }
.hero h1 span { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 20px; color: var(--muted); max-width: 640px; }
.cta { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.cta a { display: inline-block; padding: 12px 18px; border-radius: 8px; font-weight: 600; }
.cta .primary { background: var(--accent); color: white; }
.cta .secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.cta a:hover { text-decoration: none; filter: brightness(1.1); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 60px; }
.feature { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.feature h3 { margin: 0 0 6px; font-size: 17px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }
.footer { color: var(--muted); padding: 40px 0 20px; font-size: 13px; }

/* Auth pages (kept) */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, #181c28 0%, var(--bg-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-card h2 { margin: 0 0 6px; letter-spacing: -0.3px; }
.auth-card .muted { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.auth-card label { display: block; font-size: 13px; color: var(--text); font-weight: 500; margin: 14px 0 6px; }
.auth-card input { width: 100%; }
.auth-card button { width: 100%; margin-top: 22px; padding: 11px; }
.auth-card .alt { margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* Banner */
.announce-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white; padding: 10px 18px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: center;
  text-align: center;
}
.announce-banner .close { background: rgba(255,255,255,0.18); border: none; color: white; padding: 2px 10px; border-radius: 999px; font-size: 12px; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) 1fr;
  height: 100vh;
  height: 100dvh;
}
.app.with-right { grid-template-columns: var(--rail-w) var(--side-w) 1fr var(--right-w); }
.app.no-sidebar { grid-template-columns: var(--rail-w) 1fr; }
.app.no-sidebar.with-right { grid-template-columns: var(--rail-w) 1fr var(--right-w); }
.app.no-sidebar .sidebar { display: none; }
.app.has-banner { height: calc(100vh - 40px); margin-top: 40px; }
.toggle-btn {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 7px 10px; font-size: 16px; line-height: 1; flex-shrink: 0;
  border-radius: var(--radius-sm); box-shadow: none;
}
.toggle-btn:hover { background: var(--bg-3); color: var(--text); border-color: var(--border); }
.hd-actions .ghost.icon-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--muted); padding: 6px 9px; box-shadow: none;
  border-radius: var(--radius-sm);
}
.hd-actions .ghost.icon-btn:hover { background: var(--bg-3); color: var(--text); border-color: var(--border); }

/* Server rail */
.server-rail {
  background: var(--bg-rail); border-right: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0;
  overflow-y: auto;
}
.server-rail::-webkit-scrollbar { width: 0; }
.rail-icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: none; color: var(--text); cursor: pointer;
  font-size: 14px; font-weight: 600;
  transition: border-radius 0.18s cubic-bezier(0.22,1,0.36,1), background 0.15s, color 0.15s;
  position: relative; padding: 0;
  box-shadow: none;
}
.rail-icon:hover, .rail-icon.active {
  border-radius: 16px; background: var(--accent); color: white;
}
.rail-icon.dragging { opacity: 0.35; cursor: grabbing; }
.rail-icon[draggable="true"]:active { cursor: grabbing; }
/* white pill indicator on the rail's left edge */
.rail-icon::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%) scaleY(0);
  width: 4px; height: 40px; background: var(--text-bright); border-radius: 0 4px 4px 0;
  transition: transform 0.18s cubic-bezier(0.22,1,0.36,1);
}
.rail-icon:hover::before { transform: translateY(-50%) scaleY(0.5); }
.rail-icon.active::before { transform: translateY(-50%) scaleY(0.9); }
.rail-icon.plus::before, .rail-icon.plus:hover::before { transform: translateY(-50%) scaleY(0); }
.rail-icon.plus {
  color: var(--ok); background: var(--bg-2);
  border: 1px dashed rgba(92,214,160,0.4);
}
.rail-icon.plus:hover { background: rgba(92,214,160,0.12); border-color: var(--ok); border-style: solid; }
.rail-icon.discover::before, .rail-icon.discover:hover::before { transform: translateY(-50%) scaleY(0); }
.rail-icon.discover {
  color: #00a8fc; background: var(--bg-2);
  border: 1px dashed rgba(0,168,252,0.4);
}
.rail-icon.discover:hover { background: rgba(0,168,252,0.12); border-color: #00a8fc; border-style: solid; }
.rail-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
/* Unread red dot on a server icon / the home (DM) button */
.rail-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--danger); border: 2.5px solid var(--bg-rail);
  pointer-events: none; z-index: 3;
}
.rail-divider { width: 32px; height: 2px; background: var(--border); margin: 2px 0; border-radius: 2px; }

/* Sidebar */
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.sidebar header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.me { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; }
.me-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-row > div:last-child { line-height: 1.2; min-width: 0; flex: 1; overflow: hidden; }
.me-row > div:last-child > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .muted { color: var(--muted); font-weight: 400; font-size: 11px; }
.hd-actions { display: flex; gap: 4px; flex-shrink: 0; }
#sidebarContent { flex: 1; overflow-y: auto; padding: 6px 6px; min-height: 0; }

.sidebar-section { padding: 8px 4px 2px; }
.sidebar-section .title {
  padding: 6px 10px 6px; font-size: 11px; text-transform: uppercase; color: var(--muted);
  letter-spacing: 0.6px; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-weight: 600;
}
.sidebar-section .title .st-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-section .title .st-actions { display: flex; align-items: center; flex-shrink: 0; }
.sidebar-section .title button {
  padding: 2px 8px; font-size: 14px; line-height: 1;
  background: transparent; color: var(--muted);
  border: none; border-radius: var(--radius-sm); box-shadow: none;
}
.sidebar-section .title button:hover { background: var(--bg-3); color: var(--text); }
.list-item {
  padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; min-width: 0; color: var(--muted);
  margin: 1px 0;
  transition: background 0.1s ease, color 0.1s ease;
}
.list-item:hover { background: var(--bg-3); color: var(--text); }
.list-item.active { background: var(--bg-4); color: var(--text-bright); }
.list-item.active .channel-icon { color: var(--text-bright); }
.list-item .badge { margin-left: auto; font-size: 10px; background: var(--accent); color: white; padding: 1px 7px; border-radius: 999px; line-height: 1.4; }
.list-item .small { color: var(--muted); font-size: 12px; }
.list-item > .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .channel-icon { color: var(--muted); width: 14px; display: inline-block; text-align: center; flex-shrink: 0; }
.list-item.muted-text { color: var(--muted); }

.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.online-dot.online { background: var(--ok); }

.member-avatar-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.member-avatar-wrap .status-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--bg-2); }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.status-online { background: #23a55a; }
.status-dot.status-idle { background: #f0b232; }
.status-dot.status-dnd { background: #f23f43; }
.status-dot.status-offline { background: #80848e; }
.member-label-stack { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.member-label-stack .member-status { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-status { display: flex; align-items: center; margin-top: 6px; color: var(--muted); font-size: 13px; }

.sidebar-footer { padding: 0 12px; border-top: none; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.sidebar-footer a { display: block; padding: 6px 0; }

/* DM search bar — Discord "Find or start a conversation" */
.sidebar-search { padding: 10px 10px 8px; flex-shrink: 0; }
.sidebar-search-btn {
  width: 100%; text-align: left;
  background: var(--bg-input); color: var(--muted);
  border: none; border-radius: var(--radius-sm);
  padding: 7px 8px; font-size: 13px; font-weight: 500;
  box-shadow: none; cursor: pointer;
}
.sidebar-search-btn:hover { background: var(--bg-input); color: var(--text); }

/* Bottom user panel — the iconic Discord account bar */
.user-panel {
  flex-shrink: 0; display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; background: #232428;
}
.user-panel .up-me {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  padding: 3px 4px; border-radius: var(--radius-sm); cursor: pointer;
}
.user-panel .up-me:hover { background: rgba(255,255,255,0.06); }
.user-panel .up-info { min-width: 0; line-height: 1.15; }
.user-panel .up-info > div:first-child { font-size: 13px; font-weight: 600; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-panel .up-info .muted { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-panel .up-status { border: 2px solid #232428; width: 10px; height: 10px; }
.user-panel .up-actions { display: flex; gap: 0; flex-shrink: 0; }
.user-panel .up-actions .icon-btn { width: 30px; height: 32px; padding: 0; font-size: 15px; color: var(--text); }
.user-panel .up-actions .icon-btn:hover { background: rgba(255,255,255,0.06); border-color: transparent; }
.user-panel .up-actions .icon-btn.muted { color: var(--danger); }
.user-panel .up-actions .icon-btn.muted:hover { background: rgba(242,63,67,0.12); }
.user-panel .up-actions .icon-btn.no-mic { color: var(--muted); cursor: default; opacity: 0.55; }
.user-panel .up-actions .icon-btn.no-mic:hover { background: transparent; }
/* Log out lives in Settings now; keep the button in the DOM (hidden) so the
   Settings "Log Out" item can still trigger it. */
.user-panel #logoutBtn { display: none; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; }

/* Jump-to-present button (floats above the composer when scrolled up) */
.jump-bottom {
  position: absolute; right: 18px; bottom: 76px; z-index: 5;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px 7px 11px; border-radius: 999px; cursor: pointer;
  background: var(--bg-floating); color: var(--text); border: 1px solid var(--border-strong);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md);
}
.jump-bottom:hover { background: var(--bg-4); }
.jump-bottom svg { width: 16px; height: 16px; }

/* Fullscreen image viewer */
.lightbox {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(0,0,0,0.85); padding: 32px; cursor: zoom-out;
  animation: modal-fade 0.15s ease-out;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 8px; box-shadow: var(--shadow-lg); cursor: default; }
.lightbox-close {
  position: fixed; top: 18px; right: 22px; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.1); color: #fff; border: none; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* Drag-and-drop upload overlay */
.drop-overlay { position: absolute; inset: 10px; z-index: 40; display: none; place-items: center;
  background: rgba(88,101,242,0.12); border: 2px dashed var(--accent); border-radius: 12px; pointer-events: none; }
.main.dragging .drop-overlay { display: grid; }
.drop-overlay .drop-inner { background: var(--bg-floating); color: var(--text-bright); font-weight: 600;
  padding: 16px 28px; border-radius: 12px; box-shadow: var(--shadow-lg); }

/* Collapsible channel categories */
.cat-head { display: flex; align-items: center; gap: 5px; padding: 14px 8px 4px; cursor: pointer; user-select: none;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.cat-head:hover { color: var(--text); }
.cat-caret { display: inline-block; font-size: 9px; transition: transform .12s ease; }
.cat-wrap.collapsed .cat-caret { transform: rotate(-90deg); }
.cat-wrap.collapsed .cat-list { display: none; }

/* Users currently connected to a voice channel, nested under the channel item. */
.voice-members { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 5px 30px; }
.vmem { display: flex; align-items: center; gap: 7px; padding: 2px 6px; border-radius: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.vmem .vmem-av { width: 20px; height: 20px; font-size: 9px; }
.vmem-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmem-ic { margin-left: auto; display: inline-flex; align-items: center; color: var(--danger); flex: 0 0 auto; }
.vmem.muted, .vmem.deafened { color: var(--muted-2); }
.vmem.me .vmem-name { color: var(--text); font-weight: 600; }

/* Searchable emoji picker */
.emoji-picker-v2 { padding: 0; width: 440px; max-width: 94vw; overflow: hidden; }
.emoji-pop { display: flex; flex-direction: column; max-height: 480px; }
.emoji-search { margin: 10px 10px 6px; padding: 9px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; outline: none; }
.emoji-search:focus { border-color: var(--accent); }
.emoji-body { overflow-y: auto; padding: 2px 8px 10px; }
.emoji-cat-h { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px 4px 4px; position: sticky; top: 0; background: var(--bg-floating); }
/* Custom-emoji section headers name the server they came from, so a picker full
   of emoji from several servers you're in never leaves you guessing the source. */
.emoji-cat-h-server { display: flex; align-items: center; gap: 6px; text-transform: none; font-size: 12px; letter-spacing: 0; }
.emoji-cat-h-icon { width: 18px; height: 18px; border-radius: 6px; object-fit: cover; flex: none; display: block; }
.emoji-cat-h-icon-ph { display: grid; place-items: center; background: var(--bg-3); font-size: 9px; font-weight: 700; }
.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.emoji-grid .emoji { display: grid; place-items: center; font-size: 28px; line-height: 1; padding: 7px 0; border-radius: 8px; background: none; border: none; cursor: pointer; }
.emoji-grid .emoji:hover { background: var(--bg-3); }
.emoji-grid .emoji.custom { padding: 4px; }
.emoji-grid .emoji.custom img { width: 34px; height: 34px; display: block; object-fit: contain; }
.emoji-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }

/* Jumbo emoji for emoji-only messages */
.msg .text.jumbo-emoji { font-size: 2.7em; line-height: 1.25; }
.msg .text.jumbo-emoji .custom-emoji { width: 48px; height: 48px; }

/* Party tricks: Konami emoji party + /party /snow /fireworks /disco /barrelroll /matrix */
.egg-confetti { position: fixed; top: -44px; z-index: 9999; pointer-events: none; user-select: none; animation: egg-fall linear forwards; }
@keyframes egg-fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0.8; } }
.egg-toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 10000; pointer-events: none;
  background: var(--bg-floating); color: var(--text-bright); border: 1px solid var(--border-strong);
  padding: 12px 22px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow-lg); animation: egg-pop .3s ease-out; }
@keyframes egg-pop { from { opacity: 0; transform: translateX(-50%) translateY(12px); } }
.egg-spark { position: fixed; width: 7px; height: 7px; border-radius: 50%; z-index: 9999; pointer-events: none;
  box-shadow: 0 0 10px 2px currentColor; animation: egg-spark 1.2s ease-out forwards; }
@keyframes egg-spark { from { transform: none; opacity: 1; } to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
body.egg-disco .app { animation: egg-disco 1.1s linear infinite; }
@keyframes egg-disco { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }
body.egg-roll .app { animation: egg-roll 1.5s cubic-bezier(0.45, 0, 0.3, 1); }
@keyframes egg-roll { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.egg-matrix { position: fixed; inset: 0; z-index: 9998; pointer-events: none; opacity: 0.92; transition: opacity 0.6s; }
.egg-matrix.fade { opacity: 0; }
.main header {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.012) 0%, transparent 100%);
}
.main header .title { font-weight: 600; font-size: 15px; letter-spacing: -0.1px; }
.main header .muted { color: var(--muted); font-size: 13px; }
.main header .lhs { display: flex; align-items: center; gap: 10px; min-width: 0; }
.main header .lhs > div { min-width: 0; }
.main header .title, .main header .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0 24px; display: flex; flex-direction: column; gap: 0; }
.messages > :first-child { margin-top: auto; }
.msg {
  display: flex; gap: 16px; padding: 2px 48px 3px 16px;
  border-radius: 0;
  transition: background 0.06s ease;
}
.msg:hover { background: rgba(2,2,2,0.18); }
/* Optimistic send: bubble is dimmed while the server hasn't confirmed it yet,
   then fades back to full opacity once reconciled into a real message. */
.msg.pending { opacity: 0.45; }
.msg.pending .time::after { content: ' · sending…'; color: var(--muted); font-size: 11px; }
.msg.send-failed { opacity: 0.9; }
.msg.send-failed .text { color: #f23f43; }
.send-failed-note { color: #f23f43; font-size: 12px; margin-left: 4px; }
.send-failed-note .retry-send { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; }
.send-failed-note .retry-send:hover { color: var(--text-bright); }
body.density-compact .messages { gap: 1px; padding: 8px 16px; }
body.density-compact .msg { padding: 2px 6px; gap: 8px; }
body.density-compact .msg .avatar { width: 28px; height: 28px; font-size: 12px; }
body.density-compact .msg .head { gap: 6px; }
.msg .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; color: white; font-size: 15px; overflow: hidden; }
.msg .avatar.small { width: 24px; height: 24px; font-size: 10px; }
.msg .avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg .body { min-width: 0; flex: 1; }
.msg .head { display: flex; gap: 8px; align-items: baseline; }
.msg .head .name { font-weight: 600; font-size: 16px; color: var(--text-bright); }
.msg .head .time { color: var(--muted-2); font-size: 12px; }
.msg .text { font-size: 16px; line-height: 1.375; }
.msg .head .edited { color: var(--muted); font-size: 11px; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg .text .chat-link {
  color: var(--accent-2); text-decoration: none; word-break: break-all;
}
.msg .text .chat-link:hover { text-decoration: underline; }
.msg .text code { background: var(--bg-3); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 13px; }
.msg .text strong { font-weight: 700; }
.msg .text em { font-style: italic; }
.msg .text .spoiler { background: var(--bg-4); color: var(--bg-4); cursor: pointer; border-radius: 3px; padding: 0 3px; }
.msg .text .spoiler.revealed { color: var(--text); background: var(--bg-3); cursor: text; }
.msg .text .mention { color: #c9cdfb; background: rgba(88,101,242,0.3); padding: 1px 4px; border-radius: 4px; font-weight: 500; cursor: pointer; }
.msg .text .mention:hover { background: var(--accent); color: #fff; }
.msg .text .mention.me-mention { color: var(--warn); background: rgba(240,178,50,0.15); }
.msg.has-mention, .msg:has(.me-mention) { border-left: 2px solid var(--warn); padding-left: 4px; }
/* Role mentions: pill in the role's colour (defaults to accent when uncoloured). */
.msg .text .role-mention {
  color: var(--accent); background: var(--accent-soft); border-radius: 4px;
  padding: 0 3px; font-weight: 500; cursor: default;
}
.msg:has(.role-mention-me) { border-left: 2px solid var(--warn); padding-left: 4px; }

.reply-context {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  color: var(--muted); font-size: 12px; margin-bottom: 2px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-context:hover { color: var(--text); }
.reply-context .reply-arrow { color: var(--accent-2); }
.reply-context .reply-name { color: var(--accent-2); }
.reply-context .reply-name.pings { font-weight: 600; }
/* A reply that pinged you gets the same warm highlight as an @mention. */
.reply-context.reply-pinged-me .reply-name { color: var(--warn); }
.msg:has(.reply-pinged-me) { border-left: 2px solid var(--warn); padding-left: 4px; }
.reply-chip { background: var(--bg-3) !important; border: 1px solid var(--accent-2) !important; }
/* @ ON/OFF ping toggle inside the reply chip. Scoped under .attach-preview .reply-chip
   so it outweighs the generic muted ".attach-preview .chip button" styling. */
.attach-preview .reply-chip .reply-ping-toggle {
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent);
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; line-height: 1;
  padding: 3px 7px; border-radius: 999px; cursor: pointer; box-shadow: none;
}
.attach-preview .reply-chip .reply-ping-toggle:hover { background: var(--accent); color: #fff; }
.attach-preview .reply-chip .reply-ping-toggle:not(.on) { background: transparent; border-color: var(--border-strong); color: var(--muted); }
.attach-preview .reply-chip .reply-ping-toggle:not(.on):hover { color: var(--text); border-color: var(--text); background: transparent; }

.reactions-bar { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.reaction-chip {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 9px; font-size: 12px; display: inline-flex; align-items: center; gap: 5px;
  color: var(--text); cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease;
  box-shadow: none;
}
.reaction-chip:hover { background: var(--bg-4); border-color: var(--border-strong); }
.reaction-chip.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction-chip .count { color: var(--muted); font-size: 11px; }
.reaction-emoji-img { width: 14px; height: 14px; object-fit: contain; display: block; }

.thread-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 5px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; color: var(--accent-2); cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.thread-pill:hover { background: var(--bg-4); border-color: var(--accent-2); }
.thread-pill-count { font-weight: 600; }
.thread-pill-time { color: var(--muted); font-weight: 400; }

.thread-panel-bg { z-index: 6000; }
.thread-panel { display: flex; flex-direction: column; max-height: 82vh; }
.thread-messages {
  flex: 1; overflow-y: auto; min-height: 200px; max-height: 56vh;
  margin: 10px -20px; padding: 10px 20px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.thread-composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.thread-input {
  flex: 1; resize: none; max-height: 120px; min-height: 38px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; color: var(--text); font: inherit; line-height: 1.4;
}
.thread-input:focus { outline: none; border-color: var(--accent); }
.thread-composer button {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.thread-locked-note { display: flex; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; }

.forum-hidden { display: none !important; }
.forum-view { padding: 20px 20px 24px; max-width: 760px; margin: 0 auto; }
.forum-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.forum-toolbar button { display: inline-flex; align-items: center; gap: 6px; }
.forum-count { font-size: 13px; }
.forum-post-list { display: flex; flex-direction: column; gap: 8px; }
.forum-post-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.forum-post-row:hover { background: var(--bg-4); border-color: var(--border-strong); }
.forum-post-row:active { transform: translateY(0.5px); }
.forum-post-body { flex: 1; min-width: 0; }
.forum-post-title {
  font-weight: 600; color: var(--text-bright); display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.forum-post-preview { color: var(--muted); font-size: 13px; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forum-post-meta { color: var(--muted-2); font-size: 12px; }
.forum-post-replies {
  flex-shrink: 0; align-self: center; display: flex; align-items: center; gap: 5px;
  background: var(--bg-4); color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 8px;
}
.forum-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 56px 20px; color: var(--muted); text-align: center;
  border: 1px dashed var(--border); border-radius: 10px;
}
.forum-empty svg { opacity: 0.45; margin-bottom: 6px; }
.forum-empty p { font-weight: 600; color: var(--text); margin: 0; font-size: 15px; }
.forum-empty span { font-size: 13px; }
@media (max-width: 760px) {
  .thread-panel { max-height: 92vh; }
  .thread-messages { max-height: 62vh; }
}

.emoji-picker { flex-direction: row; flex-wrap: wrap; max-width: 280px; padding: 6px; }
.emoji-picker .emoji {
  font-size: 20px; padding: 4px 8px; background: transparent; border: none; cursor: pointer;
  border-radius: 6px;
}
.emoji-picker .emoji:hover { background: var(--bg-3); }

.pin-icon { font-size: 11px; }
.msg.pinned { background: rgba(255,178,76,0.06); }
.msg.system { color: var(--muted); font-style: italic; font-size: 13px; }
.msg.system.sys-event {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-style: normal; padding: 6px 16px; text-align: center;
}
.msg.system.sys-event svg { opacity: .7; flex-shrink: 0; }
.msg.system.sys-event .sys-text { color: var(--text-muted, var(--muted)); }
.msg.system.sys-event .sys-time { opacity: .55; font-size: 11px; }
.msg .msg-quick-reply {
  opacity: 0; flex-shrink: 0; margin-left: auto;
  padding: 1px 6px; font-size: 13px; line-height: 1.7;
  background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: opacity 0.12s, background 0.12s;
}
.msg:hover .msg-quick-reply, .msg .msg-quick-reply:focus { opacity: 1; }
.msg .msg-quick-reply:hover { background: var(--bg-3); color: var(--text); }
.msg .msg-menu-btn {
  opacity: 0; flex-shrink: 0;
  padding: 0 6px; font-size: 14px; line-height: 1;
  background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 6px;
}
.msg:hover .msg-menu-btn, .msg .msg-menu-btn:focus { opacity: 1; }
.msg .msg-menu-btn:hover { background: var(--bg-3); color: var(--text); }
.char-count {
  display: block; text-align: right; font-size: 11px; font-weight: 600;
  color: var(--muted); padding: 2px 10px 4px; line-height: 1;
}
.char-count.warn { color: #f5a623; }
.char-count.danger { color: #f04747; animation: char-pulse 1s ease-in-out infinite; }
@keyframes char-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.msg.deleted .text { color: var(--muted); font-style: italic; }
.floating-menu {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; box-shadow: var(--shadow-md);
  min-width: 160px; z-index: 400; display: flex; flex-direction: column;
  animation: fm-pop 0.13s cubic-bezier(0.2, 0, 0.13, 1.4);
}
@keyframes fm-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.floating-menu button {
  background: transparent; border: none; color: var(--text); text-align: left;
  padding: 8px 12px; font-size: 13px; border-radius: var(--radius-sm);
  font-weight: 500; box-shadow: none;
}
.floating-menu button:hover { background: var(--bg-3); }
.floating-menu button:focus-visible { background: var(--bg-3); outline: none; box-shadow: inset 0 0 0 1px var(--accent, #8aa0ff); }
.floating-menu button.danger { color: var(--danger); }
.floating-menu button.danger:hover, .floating-menu button.danger:focus-visible { background: rgba(255,92,124,0.1); box-shadow: inset 0 0 0 1px rgba(255,92,124,0.4); }
/* Shared icon-row menus built by showFloatingMenu() (message / chat-row / server-rail) */
.floating-menu.fm-icons { min-width: 196px; }
.floating-menu.fm-icons button { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.floating-menu.fm-icons button svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.floating-menu.fm-icons button:hover svg, .floating-menu.fm-icons button:focus-visible svg { color: inherit; }
.floating-menu.fm-icons button.danger svg { color: var(--danger); }
.fm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-sep { height: 1px; background: var(--border); margin: 5px 8px; flex: none; }
/* Per-user volume row inside the voice-participant right-click menu */
.fm-custom { flex: none; }
.fm-volume { width: 216px; max-width: 100%; padding: 6px 10px 8px; box-sizing: border-box; }
.fm-vol-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fm-vol-label { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-vol-val { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); flex: none; }
.fm-vol-val.hot { color: var(--accent); font-weight: 600; }
.fm-volume input[type=range] { width: 100%; display: block; accent-color: var(--accent); margin: 0; }
/* Booster toggle — beat the generic .floating-menu button rules */
.floating-menu .fm-boost {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 22px; padding: 0; flex: none;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--muted);
}
.floating-menu .fm-boost:hover { background: var(--bg-3); color: var(--text); }
.floating-menu .fm-boost.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.floating-menu .fm-boost.on:hover { background: var(--accent-hover, var(--accent)); color: #fff; }
/* Local (only-for-you) volume state shown on call tiles */
.tile-icon.local-muted { color: var(--danger); }
.tile-icon.local-vol { font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.tile-icon.local-vol.hot { color: var(--accent); font-weight: 600; }
/* Composer "+" mobile menu: icon + label rows */
.floating-menu.composer-more button { display: flex; align-items: center; gap: 11px; padding: 11px 14px; font-size: 15px; }
.floating-menu.composer-more button svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.floating-menu.composer-more { min-width: 190px; }
/* Notification-level menu (chat header bell) */
.floating-menu.notif-menu { min-width: 210px; }
.notif-menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 4px 12px 7px; font-weight: 700; }
.floating-menu.notif-menu button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.floating-menu.notif-menu button svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.floating-menu.notif-menu button.active { color: var(--text-bright); }
.floating-menu.notif-menu button.active svg { color: var(--accent, #8aa0ff); }
.floating-menu.notif-menu button span { flex: 1; }
.icon-btn.notif-dimmed svg { color: var(--muted); opacity: 0.85; }

/* Screen-share menu (anchored to the share-screen button) */
.floating-menu.ss-menu { min-width: 220px; }
.ss-menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 4px 12px 7px; font-weight: 700; }
.floating-menu.ss-menu button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.floating-menu.ss-menu button svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.floating-menu.ss-menu button span { flex: 1; }
.floating-menu.ss-menu button.ss-stop { color: var(--danger); }
.floating-menu.ss-menu button.ss-stop:hover { background: rgba(255,92,124,0.1); }
.floating-menu.ss-menu button.ss-toggle.on svg { color: var(--accent, #8aa0ff); }
.ss-menu .ss-check svg { color: var(--accent, #8aa0ff); }
.ss-menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }

/* Clickable user names / avatars on call tiles + sidebar voice members */
.tile-uname.clickable, .tile-avatar.clickable { cursor: pointer; }
.tile-uname.clickable:hover { text-decoration: underline; }
.tile-avatar.clickable:hover { filter: brightness(1.08); }
.vmem.clickable { cursor: pointer; }
.vmem.clickable:hover { background: var(--bg-3); }

.attachments { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; align-items: flex-start; }
.attachments .attach-image {
  display: inline-block; max-width: min(360px, 100%); border-radius: 8px;
  overflow: hidden; background: var(--bg-3); border: 1px solid var(--border);
}
.attachments .attach-image img {
  display: block; max-width: 100%; max-height: 280px; height: auto; width: auto;
}
.attachment {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px;
  max-width: 360px; text-decoration: none; color: var(--text);
}
.attachment .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment .size { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.attachment.warn { border-color: var(--warn); color: var(--warn); }
.attachment.warn:hover { background: rgba(255, 178, 76, 0.08); }
.attachment-wrap { display: flex; flex-direction: column; gap: 4px; }
.attachment-warn { color: var(--warn); font-size: 12px; max-width: 360px; }
.attachment-note { color: var(--muted); font-size: 11px; max-width: 360px; }
.attachments video, .attachments audio {
  display: block; max-width: min(420px, 100%); max-height: 320px;
  border-radius: 8px; background: #000;
}
.attachments audio { background: transparent; height: 40px; }

.typing { padding: 2px 20px 0; color: var(--muted); font-size: 12px; min-height: 18px; font-style: italic; }

.attach-preview { padding: 6px 18px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.attach-preview .chip { background: var(--bg-3); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.attach-preview .chip button { background: transparent; border: none; color: var(--muted); padding: 0; }

.composer {
  margin: 0 16px 24px; padding: 2px 6px 2px 8px;
  display: flex; gap: 2px; align-items: center;
  flex-shrink: 0;
  background: var(--bg-3);
  border: 1px solid transparent; border-radius: var(--radius);
  transition: border-color 0.12s ease;
}
.composer:focus-within { border-color: transparent; }
.composer > * { flex-shrink: 0; }
.composer input {
  flex: 1; min-width: 0;
  background: transparent;
  border: none; border-radius: 0;
  padding: 12px 8px; font-size: 15px;
}
.composer input:focus { background: transparent; border: none; box-shadow: none; }
.composer .ghost.icon-btn {
  background: transparent; border: none; color: var(--muted);
  padding: 0; font-size: 18px; line-height: 1; box-shadow: none;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
.composer .ghost.icon-btn:hover { background: transparent; color: var(--text); border: none; }
.composer button[type=submit] {
  padding: 8px 14px; border-radius: var(--radius-sm);
  margin-left: 2px; background: transparent; color: var(--accent);
  font-weight: 600; box-shadow: none;
}
.composer button[type=submit]:hover { background: var(--accent); color: #fff; }

label.check-row {
  display: flex; align-items: center; gap: 14px;
  margin: 10px 0 4px; cursor: pointer;
  font-size: 14px; color: var(--text);
  padding: 12px 14px; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: background 0.12s ease, border-color 0.12s ease;
}
label.check-row:hover { background: var(--bg-4); border-color: var(--border-strong); }
label.check-row span { line-height: 1.35; order: 1; flex: 1 1 auto; }

/* On/off checkboxes render as a sliding switch (label left, switch right). */
label.check-row input[type=checkbox] {
  order: 2; flex: none; -webkit-appearance: none; appearance: none;
  position: relative; width: 42px; height: 24px; margin: 0; padding: 0;
  border-radius: 999px; background: var(--bg-input);
  border: 1px solid var(--border-strong); cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
label.check-row input[type=checkbox]::before {
  content: ''; position: absolute; top: 50%; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transform: translateY(-50%);
  transition: transform 0.18s cubic-bezier(.3,.7,.4,1.2);
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
label.check-row input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
label.check-row input[type=checkbox]:checked::before { transform: translate(18px, -50%); }
label.check-row input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-preview { width: 56px; height: 56px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; }
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }
.icon-preview span { font-weight: 700; }
.discover-banner-preview {
  width: 100%; max-width: 420px; height: 110px; border-radius: 10px; margin: 6px 0 10px;
  background: var(--bg-3); border: 1px solid var(--border); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.discover-banner-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.update-banner {
  position: fixed; top: 16px; right: 16px; z-index: 300;
  background: var(--accent); color: white; padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4); display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.update-banner button { background: white; color: var(--accent); border: none; padding: 5px 12px; border-radius: 6px; font-weight: 700; }

.in-call-chip {
  background: var(--bg-3); border: 1px solid var(--ok); color: var(--ok);
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
}

.voice-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-2); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.voice-bar .voice-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.voice-bar .vlabel { font-size: 12px; color: var(--muted); }

.voice-status {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-3);
}
.voice-status.connecting, .voice-status.reconnecting { color: var(--warn); border-color: var(--warn); }
.voice-status.connecting::before { content: '● '; animation: voice-pulse 1.4s infinite; }
.voice-status.ok { color: var(--ok); border-color: var(--ok); }
.voice-status.failed { color: var(--danger); border-color: var(--danger); }
.voice-status.alone { color: var(--muted); }
@keyframes voice-pulse { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }

.ping-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.ping-bars .bar { width: 3px; background: var(--bg-4); border-radius: 1px; }
.ping-bars .bar:nth-child(1) { height: 5px; }
.ping-bars .bar:nth-child(2) { height: 9px; }
.ping-bars .bar:nth-child(3) { height: 13px; }
.ping-bars .bar.lit { background: var(--ok); }
.ping-bars .bar.lit:nth-child(1) { background: var(--danger); }
.ping-bars .bar.lit:nth-child(2) { background: var(--warn); }

.call-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.call-tile {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  aspect-ratio: 4 / 3; justify-content: center;
  position: relative;
  transition: border-color 0.25s ease;
}
/* The speaking ring lives on an overlay so turning it off FADES (opacity
   transition) instead of the box-shadow snapping off mid-pulse when the
   .speaking class drops. The 0%/100% keyframe matches the resting shadow, so
   the pulse also starts/stops seamlessly. Drawn INSET (inside the tile bounds):
   the voice bar's tiles are overflow:hidden and its grid is overflow:auto, so
   anything drawn outside the tile gets sliced off at container edges. */
.call-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--ok), inset 0 0 10px rgba(35,165,90,0.35);
  opacity: 0; transition: opacity 0.3s ease;
}
.call-tile.speaking { border-color: var(--ok); }
.call-tile.speaking::after { opacity: 1; animation: speaking-ring 1.6s ease-in-out infinite; }
@keyframes speaking-ring {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--ok), inset 0 0 10px rgba(35,165,90,0.35); }
  50%      { box-shadow: inset 0 0 0 3px var(--ok), inset 0 0 20px rgba(35,165,90,0.6); }
}
.call-tile.camera-on { border-color: var(--accent-2); }
.call-tile.camera-on.speaking { border-color: var(--ok); }
.call-tile video {
  width: 100%; height: 100%; object-fit: cover; border-radius: 6px; background: #000;
}
.call-tile .tile-avatar { display: grid; place-items: center; }
.call-tile .tile-avatar .avatar.large {
  width: 56px; height: 56px; font-size: 22px;
  box-shadow: 0 0 0 3px transparent;
  transition: box-shadow 0.3s ease;
}
.call-tile.speaking .tile-avatar .avatar.large {
  box-shadow: 0 0 0 3px var(--ok);
}
/* Ringing card — a member who's been rung but hasn't joined yet. */
.call-tile.ringing { border-color: var(--accent); border-style: dashed; }
.call-tile.ringing .tile-avatar { position: relative; }
.call-tile.ringing .tile-avatar .avatar.large { animation: ring-pulse 1.3s ease-in-out infinite; }
.call-tile.ringing .ring-wave {
  position: absolute; top: 50%; left: 50%; width: 56px; height: 56px;
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  animation: ring-wave 1.3s ease-out infinite;
}
.ring-label { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; margin-left: 6px; color: var(--accent-2, #8aa0ff); opacity: .95; }
.ring-label svg { width: 12px; height: 12px; }
@keyframes ring-pulse { 0%,100% { box-shadow: 0 0 0 2px rgba(88,101,242,0.5); } 50% { box-shadow: 0 0 0 4px rgba(88,101,242,0.95); } }
@keyframes ring-wave { 0% { box-shadow: 0 0 0 0 rgba(88,101,242,0.45); } 70% { box-shadow: 0 0 0 16px rgba(88,101,242,0); } 100% { box-shadow: 0 0 0 0 rgba(88,101,242,0); } }
.call-tile .tile-name {
  font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 4px;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.call-tile .tile-icon { font-size: 11px; }
/* Call control bar — one design shared by the voice bar and the stage:
   a rounded-rect tray of square icon buttons (no capsules). */
.call-controls {
  display: flex; gap: 7px; justify-content: center; align-items: center; flex-wrap: wrap;
  align-self: center;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px; box-shadow: var(--shadow-md);
}
.call-controls button {
  width: 46px; height: 46px; border-radius: 11px; padding: 0;
  font-size: 14px; box-shadow: none;
  background: var(--bg-4); border: none; color: var(--text);
  transition: background 0.13s ease, color 0.13s ease, transform 0.08s ease;
}
.call-controls button:hover { background: var(--border-strong); }
.call-controls button:active { transform: scale(0.93); }
.call-controls button svg { width: 20px; height: 20px; }
.call-controls button.accent { background: var(--accent); color: #fff; }
.call-controls button.accent:hover { background: var(--accent-hover); }
.call-controls button.danger { background: var(--danger); color: #fff; }
.call-controls button.danger:hover { filter: brightness(1.12); background: var(--danger); }
.call-controls button.leave { width: 62px; }
.call-controls .cc-sep { width: 1px; height: 26px; background: var(--border-strong); margin: 0 3px; flex: none; }

/* Overlays opened while the full-view call stage (z-index 6000) is up must
   layer above it. Scoped to body.stage-open so the normal stacking order
   (modal 100 < lightbox 200 < banner 300 < menu 400) is untouched elsewhere. */
body.stage-open .modal-bg { z-index: 6040; }
body.stage-open .lightbox { z-index: 6050; }
body.stage-open .update-banner { z-index: 6060; }
body.stage-open .event-modal-root { z-index: 6070; }
body.stage-open .floating-menu { z-index: 6300; }

/* A tile taken fullscreen by double-click (the tile, not the bare <video>,
   so the name bar and speaking ring stay visible) */
.call-tile:fullscreen { border-radius: 0; border: none; aspect-ratio: auto; background: #000; padding: 0; }
.call-tile:fullscreen video { border-radius: 0; object-fit: contain; }
.call-tile:fullscreen .tile-name {
  position: absolute; left: 16px; bottom: 16px; font-size: 15px; max-width: 60vw;
  background: rgba(0,0,0,0.55); padding: 6px 12px; border-radius: 8px;
}

/* Sidebar voice-member rows light up while that person is speaking */
.vmem .vmem-av { box-shadow: 0 0 0 2px transparent; transition: box-shadow 0.3s ease; }
.vmem.speaking .vmem-av { box-shadow: 0 0 0 2px var(--ok); }
.vmem.speaking .vmem-name { color: var(--text); }

/* Stage header participant count + click-to-focus affordance on stage tiles */
.stage-count { display: inline-flex; align-items: center; gap: 5px; margin-left: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stage-count svg { width: 13px; height: 13px; }
.stage-grid .call-tile { cursor: pointer; }
.stage-grid .call-tile:hover { border-color: var(--accent-2); }
.stage-grid .call-tile.speaking:hover { border-color: var(--ok); }

.right { display: none; background: var(--bg-2); border-left: 1px solid var(--border); padding: 14px 14px; overflow-y: auto; position: relative; }
.app.with-right .right { display: block; }
.right .right-close {
  display: none; position: absolute; top: 6px; right: 8px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
  font-size: 22px; line-height: 1; padding: 4px 12px; border-radius: 8px;
  z-index: 2;
}
.right .right-close:active { background: var(--accent); color: white; }
.right h4 { margin: 10px 0 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.right .member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 13px; }
.right .member:hover { background: var(--bg-3); cursor: pointer; }
.right .member .avatar.small { width: 26px; height: 26px; font-size: 11px; }
.right .member .role { color: var(--muted); font-size: 11px; margin-left: auto; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; color: white; font-size: 14px; overflow: hidden; }
.avatar.small { width: 28px; height: 28px; font-size: 11px; }
.avatar.large { width: 72px; height: 72px; font-size: 28px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg .head .name.clickable { cursor: pointer; }
.msg .head .name.clickable:hover { text-decoration: underline; }
.bot-badge { display: inline-block; margin-left: 5px; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--accent); color: #fff; vertical-align: middle; letter-spacing: .03em; }
.sidebar .bot-badge { font-size: 9px; padding: 1px 4px; margin-left: 4px; }
.text.bot-streaming::after { content: '▋'; display: inline-block; margin-left: 1px; animation: bot-cursor 0.6s step-end infinite; }
@keyframes bot-cursor { 0%,100%{opacity:1} 50%{opacity:0} }
.ai-settings-modal { width: 420px; }
.ai-settings-modal .modal-header h3 { display: flex; align-items: center; gap: 7px; }
.ai-persona-input { width: 100%; height: 130px; resize: vertical; background: var(--input-bg, #1e1f22); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 13px; line-height: 1.5; font-family: inherit; box-sizing: border-box; }
.ai-persona-input:focus { outline: none; border-color: var(--accent); }
.ai-persona-footer { display: flex; justify-content: flex-end; margin-top: 4px; }
.ai-persona-count { font-size: 11px; color: var(--text-muted); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.78);
  display: grid; place-items: center; z-index: 100; padding: 16px;
  animation: modal-fade 0.18s ease-out;
}
.modal {
  background: var(--bg);
  border: none;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  min-width: 320px; max-width: 480px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-pop 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { margin: 0 0 14px; font-size: 18px; letter-spacing: -0.2px; }

/* Privacy-policy consent gate — must sit above the #appLoading splash (z 9999). */
.modal-bg.consent-gate { z-index: 10001; }
.consent-card .consent-body { margin: 0 0 4px; }
.consent-card .consent-body p { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.consent-card .consent-body p:first-child { color: var(--text); }
.consent-card .consent-link a { color: var(--accent-2); font-weight: 600; }
.consent-card .consent-err { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* Rebrand name poll prompt */
.rebrand-card .rebrand-lead { margin: 0 0 16px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.rebrand-card .rebrand-input { width: 100%; margin: 0 0 4px; font-size: 15px; padding: 11px 12px; }
.panel-modal { padding: 0; display: flex; flex-direction: column; }
.panel-modal .panel-head {
  padding: 18px 24px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-modal .panel-head h3 { font-size: 19px; font-weight: 700; }
.panel-modal .panel-head .ghost {
  padding: 4px 10px; line-height: 1;
  border-radius: var(--radius-sm);
  font-size: 18px; color: var(--muted);
  border-color: transparent;
}
.panel-modal .panel-head .ghost:hover { background: var(--bg-3); color: var(--text); border-color: var(--border); }
.panel-modal > div:last-child { padding: 20px 24px 22px; overflow-y: auto; }
.manage-list { display: flex; flex-direction: column; gap: 8px; }
.manage-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.manage-row:last-child { border-bottom: none; }
.manage-row input[readonly] { background: var(--bg-3); }
.manage-row button { padding: 5px 10px; font-size: 12px; }
.emoji-manage-preview { width: 28px; height: 28px; object-fit: contain; flex: none; border-radius: 4px; background: var(--bg-3); }
.profile-head { display: flex; gap: 14px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.profile-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.profile-section:last-child { border-bottom: none; }
.profile-section h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.profile-section p { margin: 0; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 0; }
.mutuals { display: flex; flex-direction: column; gap: 4px; }
.mutual-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.mutual-row:hover { background: var(--bg-3); }
.modal .row { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.modal .row button { padding: 9px 18px; }
.modal label {
  display: block; font-size: 13px;
  color: var(--text); font-weight: 500;
  margin: 14px 0 6px;
}
.modal label:first-child, .modal > label:first-of-type { margin-top: 0; }
.modal input, .modal textarea, .modal select { width: 100%; }
.modal textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.chip:hover { background: var(--bg-4); border-color: var(--border-strong); }
.chip button { background: transparent; border: none; color: var(--muted); padding: 0; cursor: pointer; box-shadow: none; }
.chip button:hover { color: var(--danger); background: transparent; }

.kbd { background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-family: monospace; }

/* Admin */
.scroll-table { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.scroll-table table { border-collapse: separate; }
.scroll-table thead th { position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--border); }
.tag.danger { color: var(--danger); border-color: var(--danger); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.warn { color: var(--warn); border-color: var(--warn); }

.warn-btn { background: var(--warn); color: #1a1206; border: 0; font-weight: 600; }
.warn-btn:hover { filter: brightness(1.05); }

.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.admin-tabs .tab-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.admin-tabs .tab-btn:hover { color: var(--text); }
.admin-tabs .tab-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

.settings-grid { display: flex; flex-direction: column; gap: 10px; max-width: 600px; }
.settings-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.settings-row input[type=checkbox] { width: auto; margin-top: 2px; }

.sidebar-scrim {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 49;
}
.app.show-sidebar .sidebar-scrim { display: block; }
.right-scrim {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 49;
}
.app.with-right.show-right .right-scrim { display: block; }
@media (min-width: 761px) {
  .right-scrim { display: none !important; }
}

@media (max-width: 760px) {
  :root { --rail-w: 56px; --right-w: 0px; }
  /* Mobile chrome: the chat owns the full width. Server rail + channel list
     live together in one slide-in drawer (Discord-mobile style) — toggled by
     ☰, an edge swipe, or the scrim. */
  .app, .app.with-right, .app.no-sidebar, .app.no-sidebar.with-right {
    grid-template-columns: 1fr;
  }
  .server-rail {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--rail-w);
    z-index: 51;
    transform: translateX(-110%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .sidebar, .app.no-sidebar .sidebar {
    display: flex;
    position: fixed; top: 0; left: var(--rail-w); bottom: 0;
    z-index: 50; width: min(78vw, 320px); max-width: calc(100vw - var(--rail-w) - 24px);
    background: var(--bg-2); border-right: 1px solid var(--border);
    transform: translateX(calc(-100% - var(--rail-w)));
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .app.show-sidebar .server-rail { transform: translateX(0); }
  .app.show-sidebar .sidebar,
  .app.show-sidebar.no-sidebar .sidebar { transform: translateX(0); }
  .app.has-banner .sidebar, .app.has-banner .server-rail { top: 40px; }
  .right {
    display: none;
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 50; width: 280px; max-width: calc(100vw - 40px);
    background: var(--bg-2); border-left: 1px solid var(--border);
    padding-top: 40px;
  }
  .app.with-right .right { display: none; }
  .app.with-right.show-right .right { display: block; }
  .right .right-close { display: block; }
  .app.has-banner .right { top: 40px; }
  .toggle-btn { padding: 8px 12px; font-size: 18px; }
  .main { height: 100%; min-height: 0; }
  .messages { padding: 10px; }
  .composer { padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); gap: 4px; flex-wrap: nowrap; }
  /* Hide non-essential composer buttons on mobile so the input has room to breathe */
  .composer #gifBtn, .composer #voiceNoteBtn { display: none; }
  .composer .ghost.icon-btn {
    width: 36px; height: 36px; min-width: 36px;
    padding: 6px; font-size: 16px;
  }
  .composer input {
    flex: 1 1 0; min-width: 0;
    padding: 10px 14px; font-size: 16px;
  }
  .composer button[type=submit] {
    padding: 8px 16px; font-size: 14px;
    margin-left: 2px;
  }
  .main header { padding: 8px 10px; gap: 8px; }
  .main header .muted { display: none; }
  .main header .title { font-size: 15px; }
  /* Header action buttons must never overflow onto the ☰/title side.
     The rhs shrinks (min-width:0) and the action row side-scrolls instead. */
  .main header .lhs { flex: 1 1 auto; }
  .main header .lhs .toggle-btn { flex-shrink: 0; }
  .main header .rhs { min-width: 0; gap: 4px; flex-shrink: 1; }
  .main header .rhs #inboxBtn { flex-shrink: 0; }
  .hd-actions {
    min-width: 0; flex-shrink: 1; overflow-x: auto; gap: 2px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .hd-actions::-webkit-scrollbar { display: none; }
  .hd-actions .ghost.icon-btn { padding: 6px 7px; flex-shrink: 0; }
  .friends-page { padding: 12px; }
  /* Avatar at top of sidebar gets compressed otherwise */
  .me-row > div:last-child { font-size: 13px; }
  /* Modals: 320px min-width overflowed narrow phones — let them shrink to fit. */
  .modal-bg { padding: 10px; }
  .modal { min-width: 0; padding: 18px 16px; max-width: 100%; }
  .panel-modal { max-width: 100% !important; }
  .modal input, .modal textarea, .modal select { font-size: 16px; } /* avoid iOS zoom-on-focus */
  /* Settings rows with several actions: let them wrap instead of overflowing. */
  .manage-row { flex-wrap: wrap; }
  .role-mgmt-row { flex-wrap: wrap; }
  .chan-perm-row { gap: 8px; }
  .tab-row { overflow-x: auto; }
}
@media (min-width: 761px) {
  .sidebar-scrim { display: none !important; }
}
.friends-page { padding: 22px 24px; overflow-y: auto; flex: 1; min-height: 0; }
.friends-page h3 { margin: 0 0 14px; font-size: 17px; letter-spacing: -0.2px; }
.friends-page section { margin-bottom: 28px; }
.friends-page .add-form { display: flex; gap: 10px; max-width: 480px; }
.friends-page .add-form input { flex: 1; }
.friend-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.1s ease;
}
.friend-row:hover { background: var(--bg-2); }
.friend-row .label { flex: 1; min-width: 0; }
.friend-row .actions { display: flex; gap: 6px; }
.friend-row .actions button { padding: 5px 12px; font-size: 12px; }
.tab-row {
  display: flex; gap: 8px; padding: 10px 14px; align-items: center;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 5px 10px; background: transparent; border: none;
  color: var(--muted); border-radius: var(--radius-sm); font-weight: 500;
  box-shadow: none;
  transition: color 0.12s ease, background 0.12s ease;
}
.tab:hover { color: var(--text-bright); background: var(--bg-3); }
.tab.active { color: var(--text-bright); background: var(--bg-4); font-weight: 500; }

/* ─── Lightbox ────────────────────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 200; display: grid; place-items: center; padding: 24px; }
.lightbox-img { max-width: 95vw; max-height: 85vh; border-radius: 6px; box-shadow: 0 4px 30px rgba(0,0,0,0.6); user-select: none; }
.lightbox-img.zoomable { cursor: zoom-in; touch-action: none; will-change: transform; }
.lightbox-zoom { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.lightbox-zoom button { background: rgba(255,255,255,0.1); border: none; color: #fff; width: 40px; height: 34px; border-radius: 8px; font-size: 18px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.lightbox-zoom button:hover { background: rgba(255,255,255,0.2); }
.lightbox-caption { position: absolute; bottom: 50px; left: 0; right: 0; text-align: center; color: #ccc; font-size: 13px; }
.lightbox-close, .lightbox-prev, .lightbox-next { position: absolute; background: rgba(255,255,255,0.08); border: none; color: white; font-size: 28px; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0; }
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.18); }
.lightbox-close { top: 20px; right: 20px; }
.lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-open { position: absolute; bottom: 18px; right: 24px; color: #aaa; font-size: 12px; text-decoration: underline; }

/* ─── Code blocks ─────────────────────────────────────────────────────────── */
.code-block { background: #0e1015; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 6px 0; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.code-block code { background: transparent; padding: 0; font-family: 'SF Mono', 'Cascadia Mono', Menlo, monospace; }

/* ─── Custom emoji inline ─────────────────────────────────────────────────── */
.custom-emoji { width: 22px; height: 22px; vertical-align: -6px; margin: 0 1px; cursor: pointer; border-radius: 4px; transition: transform 0.1s ease; }
.custom-emoji:hover { transform: scale(1.15); }
.msg .text:has(.custom-emoji:only-child) .custom-emoji { width: 40px; height: 40px; vertical-align: -10px; }

/* ─── Custom emoji info modal (click a custom emoji in a message) ──────────── */
.emoji-info-modal { max-width: 340px; padding: 0; overflow: hidden; }
.emoji-info-modal .ei-banner { width: 100%; height: 90px; object-fit: cover; display: block; }
.emoji-info-modal .ei-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 4px; }
.emoji-info-modal .ei-emoji { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: var(--bg-3); flex: none; }
.emoji-info-modal .ei-name { font-weight: 700; font-size: 16px; }
.emoji-info-modal .ei-server { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.emoji-info-modal .ei-server-icon { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; flex: none; }
.emoji-info-modal .ei-server-icon-ph { display: grid; place-items: center; background: var(--bg-3); font-weight: 700; }
.emoji-info-modal .ei-server-name { font-weight: 600; }
.emoji-info-modal .ei-desc { margin: 10px 16px 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.emoji-info-modal .row { padding: 0 16px 16px; margin-top: 14px; }

/* ─── Discover Servers ───────────────────────────────────────────────────────
   Full-screen page (same fixed-inset treatment as the settings modal, just
   without its sidebar) — a card grid deserves the room, not a small popup. */
.discover-fullscreen {
  position: fixed; inset: 0;
  background: var(--bg); padding: 0;
  display: block; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.discover-shell { width: 100vw; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.discover-shell-head {
  display: flex; align-items: center; gap: 20px;
  padding: 40px 48px 20px; border-bottom: 1px solid var(--border);
}
.discover-shell-head h2 { margin: 0; font-size: 24px; font-weight: 700; color: var(--text-bright); }
.discover-shell-title { flex: 1; min-width: 0; }
.discover-shell-head .settings-close { position: static; flex: none; }
.discover-search {
  width: 280px; max-width: 40vw; padding: 10px 14px; flex: none;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; outline: none;
}
.discover-search:focus { border-color: var(--accent); }
.discover-shell-body { flex: 1; overflow-y: auto; padding: 28px 48px 60px; }
/* Grid of public-server cards: banner, icon overlapping the banner (Discord-
   style), name, member count, description, Join/Open button. */
.discover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; max-width: 1200px; margin: 0 auto; }
.discover-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.discover-card-banner { width: 100%; height: 84px; background: var(--bg-3); }
.discover-card-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.discover-card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.discover-card-head { display: flex; align-items: center; gap: 10px; }
.discover-card-icon { width: 44px; height: 44px; border-radius: 14px; object-fit: cover; flex: none; }
.discover-card-icon-ph { display: grid; place-items: center; background: var(--bg-3); font-weight: 700; }
.discover-card-title-wrap { min-width: 0; }
.discover-card-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.discover-card-members { font-size: 12px; color: var(--muted); }
.discover-card-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.discover-card-body button { align-self: flex-start; }

/* ─── Link preview ────────────────────────────────────────────────────────── */
.link-preview { display: flex; gap: 10px; max-width: 480px; margin-top: 6px; padding: 10px; background: var(--bg-3); border-left: 3px solid var(--accent); border-radius: 4px; color: inherit; text-decoration: none; }
.link-preview:hover { background: var(--bg-2); }
.link-preview .lp-image { flex-shrink: 0; width: 80px; height: 80px; border-radius: 4px; overflow: hidden; background: var(--bg-2); }
.link-preview .lp-image img { width: 100%; height: 100%; object-fit: cover; }
.link-preview .lp-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.link-preview .lp-site { font-size: 11px; color: var(--muted); }
.link-preview .lp-title { font-weight: 600; color: var(--accent); font-size: 13px; }
.link-preview .lp-desc { font-size: 12px; color: var(--muted); max-height: 3.6em; overflow: hidden; }

/* ─── Bot embed (message.kind === 'embed') ───────────────────────────────── */
.bot-embed { max-width: 420px; margin-top: 6px; background: var(--bg-3); border-left: 3px solid var(--accent); border-radius: 6px; overflow: hidden; }
.bot-embed .be-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.bot-embed .be-title { font-weight: 600; font-size: 14px; }
.bot-embed .be-desc { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.bot-embed .be-image { width: 100%; max-height: 260px; overflow: hidden; background: var(--bg-2); }
.bot-embed .be-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ─── Forwarded ───────────────────────────────────────────────────────────── */
.forwarded-context { font-size: 11px; color: var(--muted); margin-bottom: 2px; font-style: italic; }
.forwarded-preview {
  padding: 12px 14px; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 6px;
}
.forwarded-preview > div:first-child { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.forwarded-preview .fp-text {
  color: var(--text); font-size: 13px; line-height: 1.45;
  word-break: break-all;
  max-height: 60px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}

/* ─── Spoiler images ──────────────────────────────────────────────────────── */
.spoiler-attach { position: relative; }
.spoiler-attach img { filter: blur(40px); }
.spoiler-attach .spoiler-cover { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; letter-spacing: 2px; color: white; pointer-events: none; }
.spoiler-attach.revealed img { filter: none; }
.spoiler-attach.revealed .spoiler-cover { display: none; }

/* ─── Voice notes ─────────────────────────────────────────────────────────── */
.voice-note { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-3); border-radius: 8px; }
.voice-note .vn-icon { font-size: 16px; }
.voice-note audio { height: 32px; }
.voice-note-indicator { padding: 8px 12px; background: var(--bg-3); border-left: 3px solid var(--danger); color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.voice-note-indicator .vn-dot { color: var(--danger); animation: vnpulse 1s infinite; }
.voice-note-indicator .vn-timer { flex: 1; font-variant-numeric: tabular-nums; }
.voice-note-indicator .send-vn { background: var(--accent); color: white; padding: 6px 16px; border-radius: 6px; font-weight: 600; }
.voice-note-indicator .cancel-vn { background: var(--danger); color: white; padding: 6px 16px; border-radius: 6px; font-weight: 600; border: 0; cursor: pointer; }
.voice-note-indicator .cancel-vn:hover { filter: brightness(1.1); }
@keyframes vnpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
#voiceNoteBtn.recording { background: var(--danger); color: white; }

/* ─── Inline GIF/image ────────────────────────────────────────────────────── */
.inline-gif { display: inline-block; max-width: 320px; }
.inline-gif img { display: block; max-width: 100%; max-height: 280px; border-radius: 8px; }

/* YouTube click-to-play embed */
.yt-embed { position: relative; display: block; width: 100%; max-width: 460px; aspect-ratio: 16 / 9; margin-top: 8px; border-radius: 10px; overflow: hidden; background: #000; cursor: pointer; }
.yt-embed .yt-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-embed .yt-play { position: absolute; inset: 0; margin: auto; width: 64px; height: 44px; border-radius: 10px; background: rgba(0,0,0,0.65); transition: background 0.12s ease; }
.yt-embed .yt-play::after { content: ''; position: absolute; top: 50%; left: 52%; transform: translate(-50%,-50%); border-style: solid; border-width: 9px 0 9px 16px; border-color: transparent transparent transparent #fff; }
.yt-embed:hover .yt-play { background: #f00; }
.yt-embed.playing { cursor: default; }
.yt-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* disdroc server-invite join card */
.invite-embed { margin-top: 8px; max-width: 440px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; gap: 14px; }
.invite-embed .ie-load, .invite-embed .ie-bad { color: var(--muted); font-size: 13px; }
.invite-embed .ie-bad { color: var(--danger); }
.invite-embed .ie-icon { width: 50px; height: 50px; border-radius: 16px; flex: none; object-fit: cover; }
.invite-embed .ie-initials { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; }
.invite-embed .ie-info { min-width: 0; flex: 1; }
.invite-embed .ie-label { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.invite-embed .ie-name { font-size: 16px; font-weight: 700; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.invite-embed .ie-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.invite-embed .ie-join { flex: none; background: var(--ok); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; font-weight: 600; font-size: 14px; cursor: pointer; }
.invite-embed .ie-join:hover { filter: brightness(1.08); }
.invite-embed .ie-join.joined { background: var(--bg-4); color: var(--muted); cursor: default; }
.invite-embed .ie-join:disabled { opacity: .8; cursor: default; }

/* ─── Pinned messages bar ─────────────────────────────────────────────────── */
.pinned-bar { background: var(--bg-2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pinned-bar .pin-bar-header { display: flex; align-items: center; gap: 8px; padding: 4px 12px; }
.pinned-bar .pin-bar-title { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; flex: 1; }
.pinned-bar .pin-bar-toggle { font-size: 11px; padding: 2px 8px; }
.pinned-bar .pin-bar-list { max-height: 180px; overflow-y: auto; padding: 0 12px 6px; display: flex; flex-direction: column; gap: 2px; }
.pinned-bar .pin-bar-item { display: flex; gap: 8px; align-items: baseline; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1.3; }
.pinned-bar .pin-bar-item:hover { background: var(--bg-3); }
.pinned-bar .pin-bar-item.deleted { opacity: 0.5; font-style: italic; }
.pinned-bar .pin-bar-author { color: var(--accent); font-weight: 600; flex-shrink: 0; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinned-bar .pin-bar-text { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.msg.flash { background: rgba(124, 92, 255, 0.18); transition: background 1.2s; }

/* ─── Slowmode ────────────────────────────────────────────────────────────── */
.slowmode-banner { padding: 6px 12px; background: var(--bg-3); border-left: 3px solid var(--warn); color: var(--warn); font-size: 13px; }

/* ─── GIF picker ──────────────────────────────────────────────────────────── */
.gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-top: 12px; max-height: 360px; overflow-y: auto; }
.gif-item { padding: 0; background: transparent; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; cursor: pointer; }
.gif-item img { width: 100%; height: 100px; object-fit: cover; display: block; }
.gif-item:hover { border-color: var(--accent); }

/* ─── Emoji picker wide ───────────────────────────────────────────────────── */
.floating-menu.emoji-picker.wide { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; max-width: 320px; }
.floating-menu.emoji-picker.wide .emoji { font-size: 20px; padding: 4px; }
.floating-menu.emoji-picker.wide .emoji.custom { padding: 2px; }
.floating-menu.emoji-picker.wide .emoji.custom img { width: 24px; height: 24px; display: block; }

/* ─── Quick switcher ──────────────────────────────────────────────────────── */
.qs-bg { display: grid; place-items: start center; padding-top: 80px; }
.qs-panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; width: 100%; max-width: 480px; overflow: hidden; box-shadow: 0 8px 40px rgba(0,0,0,0.4); }
.qs-input { width: 100%; padding: 14px 18px; background: transparent; border: none; outline: none; font-size: 15px; border-bottom: 1px solid var(--border); }
.qs-list { max-height: 360px; overflow-y: auto; }
.qs-item { padding: 10px 16px; display: flex; justify-content: space-between; cursor: pointer; }
.qs-item.active, .qs-item:hover { background: var(--bg-3); }
.qs-sub { color: var(--muted); font-size: 12px; }

/* ─── Settings panel ──────────────────────────────────────────────────────── */
.settings-panel { padding: 0 24px 22px; display: flex; flex-direction: column; gap: 4px; }
.settings-panel .tab-row { margin: 0 -24px 18px; padding: 0 18px; }
.settings-panel > label:not(.check-row) {
  display: block; font-size: 13px; color: var(--text);
  font-weight: 500; margin: 14px 0 6px;
}
.settings-panel > label:not(.check-row):first-of-type { margin-top: 4px; }
.settings-panel h4 {
  margin: 22px 0 10px; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}
.settings-panel h4:first-of-type { margin-top: 6px; }
.settings-panel input, .settings-panel textarea, .settings-panel select { padding: 9px 12px; }
.settings-panel > button { align-self: flex-end; margin-top: 14px; padding: 9px 18px; }
.settings-panel .session-row, .history-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 10px; border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.session-row.current { background: var(--accent-soft); border-radius: var(--radius); border-bottom-color: transparent; padding: 12px; }
.sess-info { font-size: 13px; }
.sess-info > div { margin-bottom: 2px; }
.history-row { font-size: 12px; gap: 8px; }
.history-row.fail { color: var(--danger); }
.history-row .ua { color: var(--muted); flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.ok { color: var(--ok); border-color: var(--ok); padding: 1px 6px; margin-left: 6px; font-size: 10px; border: 1px solid; border-radius: 8px; }
.backup-codes { background: var(--bg-3); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); user-select: all; font-family: monospace; line-height: 1.6; }
.blocked-list { display: flex; flex-direction: column; gap: 4px; }

/* ─── Unread badges in sidebar ────────────────────────────────────────────── */
.sidebar .list-item .unread-badge { background: var(--danger); color: white; border-radius: 10px; font-size: 11px; padding: 0 6px; min-width: 18px; height: 16px; display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
.sidebar .list-item.has-unread .label { font-weight: 600; color: var(--text); }
.sidebar .list-item .channel-icon { margin-right: 6px; }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.muted-text { color: var(--muted); font-size: 13px; }
.msg.blocked { padding: 6px 16px; opacity: 0.7; font-style: italic; font-size: 13px; }
.link-btn { text-decoration: underline; padding: 0; }
.update-banner button { margin-left: 12px; }

/* ─── Spatial audio ───────────────────────────────────────────────────────── */
.call-controls button.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.call-controls button.accent:hover { background: var(--accent-hover); }

.spatial-modal { max-width: 600px; }
.spatial-actions { align-items: center; }
.spatial-actions > button:first-child { margin-right: auto; }
.spatial-panel { display: flex; flex-direction: column; gap: 14px; }
.spatial-enable { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.spatial-enable input { width: 16px; height: 16px; accent-color: var(--accent); }
.spatial-body { display: flex; gap: 18px; flex-wrap: wrap; }
.spatial-body.disabled { filter: grayscale(0.6); opacity: 0.85; }

.spatial-room {
  position: relative;
  width: 280px; height: 280px;
  flex: 0 0 auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(circle at 50% 50%, var(--accent-soft) 0%, transparent 62%),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(255,255,255,0.03) 27px 28px),
    repeating-linear-gradient(90deg, transparent 0 27px, rgba(255,255,255,0.03) 27px 28px),
    var(--bg-input);
  overflow: hidden;
}
/* concentric distance rings + "front of room" label cue */
.spatial-room::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 70%; height: 70%; transform: translate(-50%, -50%);
  border-radius: 50%; border: 1px dashed var(--border-strong); opacity: 0.5;
}
.spatial-room::after {
  content: 'front'; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2);
}

.spatial-puck {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  user-select: none; transition: left 0.18s ease, top 0.18s ease;
}
.spatial-puck .avatar { box-shadow: 0 0 0 2px var(--bg-input), 0 0 0 3px var(--border-strong); }
.spatial-puck .puck-name {
  font-size: 10px; max-width: 64px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text);
  background: rgba(0,0,0,0.4); padding: 0 4px; border-radius: var(--radius-sm);
}
.spatial-puck.draggable { cursor: grab; }
.spatial-puck.draggable:active { cursor: grabbing; transition: none; }
.spatial-puck.draggable .avatar { box-shadow: 0 0 0 2px var(--bg-input), 0 0 0 3px var(--accent); }
.spatial-puck.you { transition: none; }
.spatial-puck.you {
  left: 50%; top: 50%;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 18px; box-shadow: 0 0 0 4px var(--accent-soft);
}

.spatial-controls { flex: 1 1 200px; display: flex; flex-direction: column; gap: 14px; min-width: 200px; }
.spatial-field { display: flex; flex-direction: column; gap: 6px; }
.spatial-field > label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.spatial-field input[type=range] { width: 100%; accent-color: var(--accent); }
.spatial-modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.spatial-modes button { font-size: 13px; padding: 7px 0; }
.spatial-modes button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.spatial-hint { font-size: 12px; color: var(--muted-2); margin: 0; line-height: 1.4; }
.spatial-size-val { color: var(--text); }

/* ─── Chat header search + composer (Discord touches) ─────────────────────── */
.main header .rhs { display: flex; align-items: center; gap: 10px; }
.header-search input {
  width: 160px; background: var(--bg-input); border: none;
  border-radius: var(--radius-sm); padding: 5px 8px; font-size: 13px;
  color: var(--text); box-shadow: none;
  transition: width 0.15s ease;
}
.header-search input::placeholder { color: var(--muted-2); }
.header-search input:focus { width: 220px; box-shadow: none; border: none; }
/* Discord sends on Enter — hide the explicit Send button on desktop */
.composer button[type=submit] { display: none; }

/* ─── Friends page (Discord) ──────────────────────────────────────────────── */
.friends-page { padding: 0 16px 16px; }
.friends-tabs {
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 16px; margin: 0 -16px 16px;
  border-bottom: 1px solid var(--border);
}
.friends-hd { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-bright); font-size: 15px; }
.friends-hd .fh-icon { opacity: 0.85; }
.friends-sep { width: 1px; height: 24px; background: var(--border-strong); margin: 0 4px; flex-shrink: 0; }
.tab.add-friend { background: var(--ok); color: #fff; font-weight: 600; }
.tab.add-friend:hover { background: #1e9150; color: #fff; }
.tab.add-friend.active { background: transparent; color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }

.friends-search {
  width: 100%; background: var(--bg-input); border: none;
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 14px;
  margin-bottom: 18px; box-shadow: none;
}
.friends-search:focus { box-shadow: none; border: none; }
.friends-count {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--muted); margin-bottom: 8px;
}
.friends-list { display: flex; flex-direction: column; }
.friends-page .friend-row {
  border-bottom: 1px solid var(--border); border-radius: 0;
  padding: 10px 8px; gap: 12px; cursor: pointer; align-items: center;
}
.friends-page .friend-row:hover { background: var(--bg-3); }
.friends-page .friend-row .fr-label { flex: 1; min-width: 0; line-height: 1.2; }
.fr-name { font-weight: 600; color: var(--text-bright); }
.fr-sub { font-size: 12px; color: var(--muted); }
.friend-row .actions { opacity: 0; display: flex; gap: 8px; }
.friend-row:hover .actions { opacity: 1; }
.fr-icon {
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  background: var(--bg-2); color: var(--muted); border: none;
  display: flex; align-items: center; justify-content: center; line-height: 1; font-size: 15px; box-shadow: none;
}
/* The message/chat bubble glyph has its tail at the bottom-left, so it reads as
   slightly off-centre in a round button — nudge it to optically centre it. */
.fr-icon svg.icon-message { transform: translate(0.5px, -0.5px); }
.fr-icon:hover { background: var(--bg-input); color: var(--text-bright); }
.fr-icon.danger { background: var(--bg-2); color: var(--muted); border: none; }
.fr-icon.danger:hover { color: var(--danger); background: var(--bg-input); }

/* ─── Active Now panel ────────────────────────────────────────────────────── */
.active-now-title { font-size: 16px; font-weight: 700; color: var(--text-bright); margin: 4px 0 14px; }
.active-now-empty {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.an-empty-title { font-weight: 600; color: var(--text-bright); margin-bottom: 6px; }
.an-empty-sub { font-size: 13px; color: var(--muted); line-height: 1.4; }
.active-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius); cursor: pointer; background: transparent;
}
.active-card:hover { background: var(--bg-3); }
.ac-info { min-width: 0; line-height: 1.2; }
.ac-name { font-weight: 600; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-sub { font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .header-search { display: none; }
  .composer button[type=submit] { display: inline-flex; }
}

/* ─── Full-screen Settings (Discord) ──────────────────────────────────────── */
.settings-fullscreen {
  position: fixed; inset: 0;
  background: var(--bg); padding: 0;
  display: block; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.settings-shell {
  display: grid;
  grid-template-columns: minmax(218px, 1fr) minmax(0, 2.4fr);
  width: 100vw; height: 100vh; height: 100dvh;
}
.settings-sidebar {
  background: var(--bg-2); display: flex; justify-content: flex-end;
  padding: 60px 6px 60px 20px; overflow-y: auto;
}
.settings-sidebar-inner { width: 218px; }
.settings-nav-group {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); padding: 16px 10px 6px;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: none; color: var(--muted);
  padding: 7px 10px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500;
  box-shadow: none; margin: 1px 0;
}
.settings-nav-item:hover { background: var(--bg-3); color: var(--text); }
.settings-nav-item.active { background: var(--bg-4); color: var(--text-bright); }
.settings-nav-item.danger:hover { background: rgba(242,63,67,0.1); color: var(--danger); }
.settings-nav-item .sn-icon { width: 18px; text-align: center; opacity: 0.9; flex-shrink: 0; }
.settings-nav-sep { height: 1px; background: var(--border); margin: 8px 10px; }
.settings-content { background: var(--bg); position: relative; overflow-y: auto; padding: 60px 40px; }
.settings-content-inner { max-width: 740px; }
.settings-content .settings-panel { padding: 0; }
.settings-title { font-size: 20px; font-weight: 700; color: var(--text-bright); margin: 0 0 20px; }
.avatar-edit-row { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.avatar-edit-actions { display: flex; flex-direction: column; gap: 8px; }
.avatar-edit-actions button { padding: 7px 14px; }

/* ─── Account status popover (bottom-left user panel) ─────────────────────── */
.status-popover { min-width: 250px; padding: 8px; }
.status-popover .sp-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px; }
.status-popover .sp-head-info { min-width: 0; line-height: 1.2; }
.status-popover .sp-name { font-weight: 600; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-popover .sp-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-popover .sp-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.status-popover .sp-custom-row { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.status-popover .sp-custom { flex: 1; min-width: 0; background: var(--bg-input); border: none; border-radius: var(--radius-sm); padding: 7px 8px; font-size: 13px; box-shadow: none; }
.status-popover .sp-custom:focus { box-shadow: none; border: none; }
.status-popover .sp-save, .status-popover .sp-clear { width: 30px; height: 30px; padding: 0; background: transparent; border: none; color: var(--muted); border-radius: var(--radius-sm); box-shadow: none; display: grid; place-items: center; font-size: 15px; }
.status-popover .sp-save:hover { background: var(--bg-3); color: var(--ok); }
.status-popover .sp-clear:hover { background: var(--bg-3); color: var(--danger); }
.status-popover .sp-option { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 8px; border-radius: var(--radius-sm); box-shadow: none; font-weight: 500; }
.status-popover .sp-option:hover { background: var(--bg-3); }
.status-popover .sp-option.active { background: var(--bg-4); }
.status-popover .sp-option .status-dot { width: 10px; height: 10px; flex-shrink: 0; }
.status-popover .sp-opt-text > div:first-child { font-size: 14px; color: var(--text-bright); }
.status-popover .sp-opt-sub { font-size: 11px; color: var(--muted); margin-top: 1px; line-height: 1.3; }
.status-popover .sp-option .sn-icon { width: 14px; text-align: center; flex-shrink: 0; }
.settings-close {
  position: absolute; top: 60px; right: 40px;
  width: 36px; height: 36px; border-radius: 50%; padding: 0;
  background: transparent; border: 2px solid var(--muted-2); color: var(--muted);
  font-size: 15px; display: grid; place-items: center; box-shadow: none;
}
.settings-close:hover { background: var(--bg-3); color: var(--text-bright); border-color: var(--text); }
/* Banner editor (profile settings / edit-profile modal) */
.banner-edit-preview {
  height: 84px; border-radius: 10px; border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-bottom: 10px;
}
.banner-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.banner-edit-actions button { font-size: 13px; padding: 7px 12px; }
.banner-editor .accent-row { margin-bottom: 4px; }

/* Mobile-only chrome for the two-level settings (hidden on desktop) */
.settings-back {
  display: none; align-items: center; gap: 6px;
  background: transparent; border: none; box-shadow: none;
  color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 8px 10px 8px 2px; margin: -4px 0 8px -2px;
}
.settings-back:hover, .settings-back:active { color: var(--text-bright); background: transparent; }
.settings-nav-mobile-head { display: none; }

@media (max-width: 760px) {
  /* Two-level settings: nav list screen ⇄ panel screen.
     .settings-shell carries .s-list or .s-panel (toggled in app.js). */
  .settings-shell { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .settings-shell.s-list .settings-content { display: none; }
  .settings-shell.s-panel .settings-sidebar { display: none; }
  .settings-sidebar {
    justify-content: flex-start;
    padding: 12px 14px 40px;
    overflow-y: auto;
  }
  .settings-sidebar-inner { width: 100%; }
  .settings-nav-mobile-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px 10px;
  }
  .settings-nav-mobile-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.2px; color: var(--text-bright); }
  .settings-nav-group { padding: 20px 10px 8px; }
  .settings-nav-item { padding: 13px 10px; font-size: 15px; border-radius: 10px; }
  .settings-nav-item .sn-icon { width: 22px; }
  .settings-back { display: inline-flex; }
  .settings-content { padding: 12px 14px 48px; }
  .settings-title { font-size: 19px; margin-bottom: 14px; }
  .settings-close { top: 10px; right: 12px; width: 32px; height: 32px; font-size: 13px; }
  .settings-close-list { position: static; }
  /* Panel content that used to overflow narrow screens */
  .history-table { overflow-x: auto; }
  .history-row { grid-template-columns: 12px 104px 90px 1fr; gap: 8px; padding: 9px 10px; }
  .acct-row { flex-wrap: wrap; }
  .discover-shell-head { padding: 16px 16px 14px; flex-wrap: wrap; gap: 10px; }
  .discover-shell-head h2 { font-size: 19px; }
  .discover-search { width: 100%; max-width: none; margin-left: 0; order: 3; }
  .discover-shell-body { padding: 16px 16px 40px; }
  .discover-grid { grid-template-columns: 1fr; }
}

/* ─── SVG icons ───────────────────────────────────────────────────────────── */
svg.icon { display: block; flex-shrink: 0; }
/* Center icons inside every icon button */
.icon-btn, .hd-actions .ghost.icon-btn, .call-controls button,
.user-panel .up-actions .icon-btn, .composer .ghost.icon-btn,
.tab .badge, .in-call-chip {
  display: inline-flex; align-items: center; justify-content: center;
}
.in-call-chip { gap: 5px; }
.list-item .channel-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; }
.fh-icon, .sn-icon, .sp-option .sn-icon { display: inline-flex; align-items: center; }
.fr-icon svg, .sp-option svg, .call-controls svg, .settings-nav-item svg { display: block; }
/* Server-rail icons stay text (DM / +); rail SVGs would go here if added */

/* ─── Screen share tiles ──────────────────────────────────────────────────── */
.call-tile.screen-tile { grid-column: span 2; aspect-ratio: 16 / 9; padding: 0; overflow: hidden; }
.call-tile.screen-tile video { width: 100%; height: 100%; object-fit: contain; background: #000; border-radius: 10px; }
.call-tile.screen-tile .tile-name {
  position: absolute; left: 8px; bottom: 8px; right: auto;
  background: rgba(0,0,0,0.65); padding: 3px 8px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
}

/* ─── Themes ─────────────────────────────────────────────────────────────── */
body.theme-light {
  --bg: #ffffff; --bg-2: #f2f3f5; --bg-3: #e3e5e8; --bg-4: #d4d7dc;
  --bg-input: #ebedef; --bg-rail: #e3e5e8; --bg-floating: #ffffff;
  --border: #e0e1e5; --border-strong: #c7ccd1;
  --text: #2e3338; --text-bright: #060607; --muted: #5c5e66; --muted-2: #6d6f78;
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1); --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
}
body.theme-light .icon { stroke: currentColor; }
body.theme-midnight {
  --bg: #0b0b0f; --bg-2: #08080b; --bg-3: #15151c; --bg-4: #1d1d27;
  --bg-input: #050507; --bg-rail: #040406; --bg-floating: #000000;
  --border: #15151c; --border-strong: #26262f;
  --text: #e3e5f0; --text-bright: #ffffff; --muted: #8a8d99; --muted-2: #74777f;
}
body.theme-crimson {
  --bg: #1a1012; --bg-2: #150d0f; --bg-3: #241619; --bg-4: #2e1b1f;
  --bg-input: #0f0809; --bg-rail: #0d0708; --bg-floating: #080405;
  --border: #2a1a1d; --border-strong: #3d2429;
  --text: #f0dcdf; --text-bright: #ffffff; --muted: #b08a8f; --muted-2: #8a6a6f;
  --accent: #e23b4e; --accent-hover: #c42e40; --accent-press: #a32635; --accent-soft: rgba(226,59,78,0.16); --accent-2: #ff8a95;
}
body.theme-aurora {
  --bg: #0e1620; --bg-2: #0a1119; --bg-3: #152230; --bg-4: #1d2f40;
  --bg-input: #070d14; --bg-rail: #060b11; --bg-floating: #04080d;
  --border: #15222e; --border-strong: #243749;
  --text: #d6e6ef; --text-bright: #ffffff; --muted: #8aa3b5; --muted-2: #6b8295;
  --accent: #2dd4bf; --accent-hover: #22b3a1; --accent-press: #1a8c7e; --accent-soft: rgba(45,212,191,0.16); --accent-2: #7c9cff;
}
body.theme-forest {
  --bg: #0e1a12; --bg-2: #0a140d; --bg-3: #142a1b; --bg-4: #1b3826;
  --bg-input: #08110b; --bg-rail: #070f09; --bg-floating: #050b07;
  --border: #163020; --border-strong: #244a32;
  --text: #d6efdf; --text-bright: #ffffff; --muted: #8ab59a; --muted-2: #6b8f78;
  --accent: #3fb96b; --accent-hover: #34a05c; --accent-press: #2a8049; --accent-soft: rgba(63,185,107,0.16); --accent-2: #8ee0a6;
}
body.theme-sunset {
  --bg: #1d1412; --bg-2: #170f0d; --bg-3: #2a1c17; --bg-4: #37241d;
  --bg-input: #120b09; --bg-rail: #100a08; --bg-floating: #0b0605;
  --border: #2c1d17; --border-strong: #42301f;
  --text: #f0e0d5; --text-bright: #ffffff; --muted: #bfa08f; --muted-2: #967a6c;
  --accent: #f0883e; --accent-hover: #db7530; --accent-press: #bb5f22; --accent-soft: rgba(240,136,62,0.16); --accent-2: #ffb27c;
}
body.theme-dracula {
  --bg: #1e1b2e; --bg-2: #181527; --bg-3: #282440; --bg-4: #332d52;
  --bg-input: #14111f; --bg-rail: #100e1a; --bg-floating: #0c0a14;
  --border: #2a2540; --border-strong: #3d3660;
  --text: #e6e3f5; --text-bright: #ffffff; --muted: #9a93c4; --muted-2: #776fa0;
  --accent: #bd93f9; --accent-hover: #a87fe6; --accent-press: #8b63d4; --accent-soft: rgba(189,147,249,0.18); --accent-2: #ff79c6;
}
body.theme-rose {
  --bg: #1f1419; --bg-2: #190f14; --bg-3: #2c1c24; --bg-4: #39252f;
  --bg-input: #140b10; --bg-rail: #11090d; --bg-floating: #0c0609;
  --border: #2e1c25; --border-strong: #432a37;
  --text: #f3dde7; --text-bright: #ffffff; --muted: #c094a6; --muted-2: #996f81;
  --accent: #ff5d8f; --accent-hover: #ec4a7d; --accent-press: #c93a66; --accent-soft: rgba(255,93,143,0.16); --accent-2: #ff9ebc;
}
body.theme-slate {
  --bg: #16181d; --bg-2: #101216; --bg-3: #212429; --bg-4: #2c3036;
  --bg-input: #0c0e11; --bg-rail: #0a0c0f; --bg-floating: #070809;
  --border: #23262c; --border-strong: #363b43;
  --text: #e7eaf0; --text-bright: #ffffff; --muted: #969ba6; --muted-2: #767b85;
  --accent: #7aa2f7; --accent-hover: #6690ec; --accent-press: #5078d4; --accent-soft: rgba(122,162,247,0.16); --accent-2: #9ece6a;
}
/* Chat font customization (Appearance → Chat font) */
body.font-serif .msg .text, body.font-serif .messages { font-family: Georgia, 'Times New Roman', serif; }
body.font-mono .msg .text, body.font-mono .messages { font-family: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, monospace; }
body.font-rounded .msg .text, body.font-rounded .messages { font-family: 'ui-rounded', 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', 'Quicksand', 'Segoe UI', system-ui, sans-serif; letter-spacing: 0.1px; }
.theme-prev-crimson .ts-dot { background: #241619; box-shadow: inset 0 0 0 7px #150d0f, inset 0 0 0 9px #e23b4e; }
.theme-prev-aurora .ts-dot { background: #152230; box-shadow: inset 0 0 0 7px #0a1119, inset 0 0 0 9px #2dd4bf; }
.theme-prev-forest .ts-dot { background: #142a1b; box-shadow: inset 0 0 0 7px #0a140d, inset 0 0 0 9px #3fb96b; }
.theme-prev-sunset .ts-dot { background: #2a1c17; box-shadow: inset 0 0 0 7px #170f0d, inset 0 0 0 9px #f0883e; }
.theme-prev-dracula .ts-dot { background: #282440; box-shadow: inset 0 0 0 7px #181527, inset 0 0 0 9px #bd93f9; }
.theme-prev-rose .ts-dot { background: #2c1c24; box-shadow: inset 0 0 0 7px #190f14, inset 0 0 0 9px #ff5d8f; }
.theme-prev-slate .ts-dot { background: #212429; box-shadow: inset 0 0 0 7px #101216, inset 0 0 0 9px #7aa2f7; }
.font-prev-serif { font-family: Georgia, 'Times New Roman', serif; }
.font-prev-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.font-prev-rounded { font-family: 'ui-rounded', 'SF Pro Rounded', 'Quicksand', 'Segoe UI', system-ui, sans-serif; }

/* Theme + accent pickers (Appearance settings) */
.theme-row { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  width: 88px; padding: 10px; background: var(--bg-3); color: var(--text);
  border: 2px solid var(--border); border-radius: 10px; cursor: pointer;
}
.theme-swatch:hover { border-color: var(--border-strong); }
.theme-swatch.active { border-color: var(--accent); }
.theme-swatch .ts-dot { width: 100%; height: 40px; border-radius: 6px; }
.theme-prev-dark .ts-dot { background: #313338; box-shadow: inset 0 0 0 7px #2b2d31, inset 0 0 0 9px #1e1f22; }
.theme-prev-light .ts-dot { background: #ffffff; box-shadow: inset 0 0 0 7px #f2f3f5, inset 0 0 0 9px #e3e5e8; }
.theme-prev-midnight .ts-dot { background: #0b0b0f; box-shadow: inset 0 0 0 7px #08080b, inset 0 0 0 9px #040406; }
.theme-swatch .ts-label { font-size: 12px; font-weight: 500; }

/* Custom sound effects (Appearance → Custom sound effects) */
.settings-hint { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.sfx-custom { display: flex; flex-direction: column; gap: 6px; }
.sfx-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; }
.sfx-name { flex: 1; font-size: 13px; font-weight: 500; }
.sfx-status { font-size: 11px; color: var(--muted); min-width: 52px; text-align: right; }
.sfx-status.on { color: var(--accent-2); font-weight: 600; }
.sfx-row .ghost { padding: 4px 9px; font-size: 12px; line-height: 1; }
.sfx-row .sfx-reset { font-size: 14px; }
.accent-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.accent-swatch {
  width: 34px; height: 34px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--bg-2);
}
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.active { border-color: var(--text-bright); }
.accent-reset { background: var(--bg-3); color: var(--muted); display: grid; place-items: center; font-size: 15px; box-shadow: none; }

/* ─── DM profile panel (right side) ──────────────────────────────────────── */
.dm-profile { margin: -14px -14px 0; }
.dmp-banner { height: 92px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.dmp-avatar-wrap { position: relative; width: 84px; height: 84px; margin: -42px 0 0 16px; }
.dmp-avatar-wrap .avatar.large {
  width: 84px; height: 84px; border-radius: 50%; font-size: 30px;
  border: 6px solid var(--bg-2); background: var(--bg-3);
}
.dmp-avatar-wrap .status-dot {
  position: absolute; right: 2px; bottom: 2px; width: 18px; height: 18px;
  border-radius: 50%; border: 4px solid var(--bg-2);
}
.dmp-card {
  margin: 12px 16px 16px; background: var(--bg-floating);
  border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.dmp-name { font-size: 20px; font-weight: 700; color: var(--text-bright); display: flex; align-items: center; }
.dmp-tag { font-size: 13px; color: var(--muted); margin-top: 1px; }
.dmp-statustext { font-size: 13px; color: var(--text); margin-top: 8px; white-space: pre-wrap; }
.dmp-divider { height: 1px; background: var(--border-strong); margin: 14px 0; }
.dmp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-bright); }
.dmp-value { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }
.dmp-stat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-top: 1px solid var(--border); cursor: default;
  font-size: 13px; font-weight: 500;
}
.dmp-chev { color: var(--muted); font-size: 16px; }
.dmp-view { width: 100%; margin-top: 14px; background: var(--bg-3); }

/* ─── Fullscreen call stage ──────────────────────────────────────────────── */
body.stage-open { overflow: hidden; }
.call-stage {
  position: fixed; inset: 0; z-index: 6000;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg) 0%, var(--bg-floating) 100%);
  display: flex; flex-direction: column;
}
.stage-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; }
.stage-title { display: flex; align-items: center; font-weight: 600; font-size: 16px; color: var(--text-bright); }
.stage-grid {
  flex: 1; min-height: 0; display: grid; gap: 14px;
  padding: 0 22px 16px; overflow: auto; align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}
.stage-grid.n1 { grid-template-columns: minmax(0, 70vw); justify-content: center; }
.stage-grid .call-tile {
  aspect-ratio: 16 / 9; height: auto; max-height: 78vh; cursor: pointer;
  border-radius: 12px;
}
.stage-grid .call-tile video { object-fit: contain; background: #000; }
.stage-grid .call-tile .tile-name { font-size: 13px; }
.stage-grid.has-focus { display: flex; }
.stage-grid.has-focus .call-tile { display: none; }
.stage-grid.has-focus .call-tile.focused {
  display: block; flex: 1; aspect-ratio: auto; max-height: none; width: 100%;
}
.call-stage .call-controls { padding: 10px; margin: 0 auto 20px; }
.call-stage .call-controls button { width: 48px; height: 48px; }

/* ─── Mobile call controls (touch-friendly, labelled) ──────────────────────── */
.call-controls.mobile-call-controls {
  display: flex; justify-content: space-around; align-items: flex-start;
  gap: 6px; row-gap: 10px; width: 100%; flex-wrap: wrap; padding: 6px 4px;
  background: none; border: none; border-radius: 0; box-shadow: none;
}
.call-controls.mobile-call-controls .mcc-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  flex: 1 1 0; min-width: 0;
}
.call-controls.mobile-call-controls .mcc-btn {
  width: 52px; height: 52px; min-width: 52px; border-radius: 16px; padding: 0;
  display: grid; place-items: center; box-shadow: none;
  background: var(--bg-4); border: 1px solid var(--border); color: var(--text);
  transition: transform 0.08s ease, background 0.15s ease;
}
.call-controls.mobile-call-controls .mcc-btn svg { width: 22px; height: 22px; display: block; }
.call-controls.mobile-call-controls .mcc-btn:active { transform: scale(0.9); }
.call-controls.mobile-call-controls .mcc-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.call-controls.mobile-call-controls .mcc-btn.danger,
.call-controls.mobile-call-controls .mcc-btn.leave { background: var(--danger); border-color: var(--danger); color: #fff; }
.call-controls.mobile-call-controls .mcc-label {
  font-size: 11px; color: var(--muted); white-space: nowrap; line-height: 1;
}
/* In the inline voice bar, drop the pill wrapper so the labelled buttons breathe */
.voice-bar .call-controls.mobile-call-controls { background: none; border: none; border-radius: 0; padding: 4px 2px; }
/* Give the full-screen call view a comfortable control bar on phones */
@media (max-width: 760px) {
  .call-stage .call-controls.mobile-call-controls { padding: 10px 6px calc(16px + env(safe-area-inset-bottom)); }
  .call-stage .call-controls.mobile-call-controls .mcc-btn { width: 56px; height: 56px; min-width: 56px; }

  /* Never crop the camera on phones — show the whole frame (letterboxed) instead
     of zooming in. Cropping a landscape frame into a small portrait card was only
     showing a sliver of the picture. */
  .call-tile video, .voice-bar .call-tile video { object-fit: contain !important; background: #000; }

  /* Full-screen call view: let tiles use the real screen, and in landscape make
     the video fill it edge-to-edge. */
  .call-stage .stage-grid { padding: 8px 8px 4px; gap: 8px; }
  .call-stage .stage-grid .call-tile { aspect-ratio: auto; max-height: none; height: 100%; min-height: 0; }
  .call-stage .stage-grid.n1 { grid-template-columns: 1fr; }
}
/* Landscape phones: hand the whole screen to the video, controls overlay the bottom. */
@media (max-width: 920px) and (orientation: landscape) {
  .call-stage .stage-head { padding: 6px 14px; }
  .call-stage .stage-grid { padding: 4px 6px; }
  .call-stage .call-controls.mobile-call-controls {
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
  }
  .call-stage .call-controls.mobile-call-controls .mcc-btn { width: 48px; height: 48px; min-width: 48px; }
  .call-stage .call-controls.mobile-call-controls .mcc-label { color: #fff; }
}

/* ─── Profile popout (Discord-style) ─────────────────────────────────────── */
.profile-pop {
  width: 740px; max-width: 94vw; max-height: 86vh; padding: 0;
  display: flex; overflow: hidden; position: relative; border-radius: 12px;
}
.pp-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  background: rgba(0,0,0,0.4); border: none; color: #fff; display: grid; place-items: center;
}
.pp-close:hover { background: rgba(0,0,0,0.6); }
.pp-left { width: 300px; flex: none; background: var(--bg-2); display: flex; flex-direction: column; overflow-y: auto; }
.pp-banner { height: 120px; flex: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.pp-avatar-wrap { position: relative; width: 92px; height: 92px; margin: -46px 0 0 20px; flex: none; }
.pp-avatar-wrap .avatar.large {
  width: 92px; height: 92px; border-radius: 50%; font-size: 32px;
  border: 6px solid var(--bg-2); background: var(--bg-3);
}
.pp-avatar-wrap .status-dot {
  position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px;
  border-radius: 50%; border: 5px solid var(--bg-2);
}
.pp-left-body { padding: 12px 20px 22px; }
.pp-name { font-size: 22px; font-weight: 800; color: var(--text-bright); line-height: 1.2; }
.pp-handle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.pp-sep { opacity: 0.7; }
.pp-badge { margin-left: 4px; }
.pp-actions { display: flex; gap: 8px; align-items: center; margin: 16px 0 4px; flex-wrap: wrap; }
.pp-actions .pp-primary { flex: 1; min-width: 130px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.pp-divider { height: 1px; background: var(--border-strong); margin: 16px 0 14px; }
.pp-bio { font-size: 13px; white-space: pre-wrap; margin-bottom: 16px; color: var(--text); }
.pp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-bright); }
.pp-value { font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.pp-note { margin-top: 2px; }
.pp-note-input {
  width: 100%; resize: vertical; min-height: 30px; margin-top: 4px;
  background: transparent; border: none; padding: 4px 0; font-size: 13px; color: var(--text);
}
.pp-note-input:focus { outline: none; }
.pp-note-input::placeholder { color: var(--muted-2); }
.pp-right { flex: 1; min-width: 0; background: var(--bg); display: flex; flex-direction: column; }
.pp-tabs { display: flex; gap: 20px; padding: 18px 22px 0; border-bottom: 1px solid var(--border); }
.pp-tab {
  background: none; border: none; border-radius: 0; color: var(--muted);
  padding: 0 0 14px; font-size: 14px; font-weight: 600; box-shadow: none;
  border-bottom: 2px solid transparent;
}
.pp-tab:hover { color: var(--text); background: none; }
.pp-tab.active { color: var(--text-bright); border-bottom-color: var(--accent); }
.pp-tab-content { flex: 1; overflow-y: auto; padding: 18px 22px; min-height: 260px; }
.pp-activity {
  height: 100%; min-height: 220px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 8px; color: var(--muted);
}
.pp-activity-title { font-weight: 600; color: var(--text); max-width: 280px; }
.pp-activity-sub { font-size: 13px; max-width: 280px; }
.pp-msg-big { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; }
.pp-empty { color: var(--muted); padding: 8px; }
.pp-right .mutual-row { padding: 8px; }
.pp-right .mutual-row .avatar.small img { border-radius: 8px; }

@media (max-width: 680px) {
  .profile-pop { flex-direction: column; width: 94vw; max-height: 90vh; }
  .pp-left { width: 100%; }
  .pp-right { min-height: 220px; }
}

/* ─── Voice: Discord-style call view + connected panel ───────────────────── */
.voice-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-floating); padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 54vh;
}
.voice-bar .voice-head { display: flex; align-items: center; gap: 10px; }
.voice-bar .vlabel {
  font-size: 13px; font-weight: 600; color: var(--text-bright);
  display: inline-flex; align-items: center; gap: 6px;
}
.voice-bar .vlabel .icon { color: var(--muted); }
.voice-bar .call-tiles {
  display: grid; gap: 10px; flex: 1; min-height: 0; overflow: auto;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-content: center; justify-items: center;
}
.voice-bar .call-tile {
  width: 100%; aspect-ratio: 16 / 9; max-height: 34vh; max-width: 360px;
  padding: 0; background: var(--bg-3); border-radius: 12px; overflow: hidden;
  justify-content: center;
}
.voice-bar .call-tile video { object-fit: cover; border-radius: 0; }
.voice-bar .call-tile .tile-avatar .avatar.large { width: 64px; height: 64px; }
.voice-bar .call-tile .tile-name {
  position: absolute; left: 8px; bottom: 8px; right: auto;
  background: rgba(0,0,0,0.6); padding: 3px 8px; border-radius: 6px; font-size: 12px;
}
.voice-bar .call-controls { padding: 7px; }
.voice-bar .call-controls button { width: 42px; height: 42px; }

.voice-panel {
  background: var(--bg-2); border-top: 1px solid var(--border);
  padding: 8px 8px 6px; display: flex; flex-direction: column; gap: 7px;
}
.vp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 0; }
.vp-info { min-width: 0; }
.vp-status { display: flex; align-items: center; gap: 7px; }
.vp-signal { width: 14px; height: 14px; border-radius: 50%; background: var(--ok); flex: none; }
.vp-signal.connecting, .vp-signal.reconnecting { background: var(--warn); }
.vp-signal.failed { background: var(--danger); }
.vp-status-label { font-size: 13px; font-weight: 700; color: var(--ok); }
.vp-status-label.connecting, .vp-status-label.reconnecting { color: var(--warn); }
.vp-status-label.failed { color: var(--danger); }
.vp-chan {
  font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}
.vp-controls { display: flex; gap: 4px; }
.vp-controls .icon-btn {
  flex: 1; background: var(--bg-4); border: none; color: var(--text);
  height: 32px; border-radius: 6px; display: grid; place-items: center; padding: 0;
}
.vp-controls .icon-btn:hover { background: var(--border-strong); }
.vp-controls .icon-btn.on { color: var(--accent-2); }
.vp-leave {
  flex: 1; background: transparent; border: none; color: var(--muted);
  height: 32px; border-radius: 6px; display: grid; place-items: center; padding: 0;
}
.vp-leave:hover { background: var(--danger); color: #fff; }

/* ─── Settings: status presets, accessibility, text sizes ─────────────────── */
.sp-presets {
  display: flex; flex-wrap: nowrap; gap: 6px; padding: 8px 10px;
  overflow-x: auto; scrollbar-width: none;
}
.sp-presets::-webkit-scrollbar { display: none; }
.sp-preset {
  flex: none; width: 34px; height: 34px; padding: 0; font-size: 17px; line-height: 1;
  display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text); border-radius: 8px;
}
.sp-preset:hover { background: var(--bg-4); border-color: var(--border-strong); }

.size-swatch {
  background: var(--bg-3); border: 2px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 16px; font-weight: 500;
}
.size-swatch:hover { border-color: var(--border-strong); }
.size-swatch.active { border-color: var(--accent); }
.size-swatch:nth-child(1) { font-size: 12px; }
.size-swatch:nth-child(3) { font-size: 17px; }

/* ─── Language picker (Settings → Language) ──────────────────────────────────── */
.lang-row { display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.lang-swatch {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--bg-3); border: 2px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 16px; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.lang-swatch:hover { border-color: var(--border-strong); background: var(--bg-4); }
.lang-swatch.active { border-color: var(--accent); }
.lang-flag { font-size: 26px; line-height: 1; flex: none; }
.lang-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.lang-native { font-weight: 600; color: var(--text-bright); }
.lang-en { font-size: 12px; color: var(--muted); }
.lang-check { color: var(--accent); display: inline-flex; flex: none; }

/* ─── Roles management (Server settings → Roles) ─────────────────────────────── */
.role-mgmt-list { display: flex; flex-direction: column; gap: 6px; }
.role-mgmt-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px;
}
.role-mgmt-row:hover { border-color: var(--border-strong); }
.role-mgmt-name { font-weight: 600; }
.role-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.perm-row { align-items: flex-start !important; }
.member-manage-row { align-items: center; }
.member-role-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.role-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; line-height: 1;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--text); background: var(--bg-2);
}
/* Channel permission overrides editor */
.chan-perm-role { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.chan-perm-role-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.chan-perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.chan-perm-label { font-size: 14px; }
.perm-tri { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; }
.perm-tri-btn { background: var(--bg-2); border: none; color: var(--muted); width: 38px; padding: 5px 0; cursor: pointer; box-shadow: none; border-radius: 0; font-size: 14px; }
.perm-tri-btn + .perm-tri-btn { border-left: 1px solid var(--border-strong); }
.perm-tri-btn:hover { background: var(--bg-4); }
.perm-tri-btn.pt-deny.active { background: var(--danger); color: #fff; }
.perm-tri-btn.pt-allow.active { background: var(--ok, #23a55a); color: #fff; }
.perm-tri-btn.pt-neutral.active { background: var(--bg-5, var(--border-strong)); color: var(--text-bright); }

/* ─── Create-server modal ────────────────────────────────────────────────── */
.create-server { width: 440px; max-width: 94vw; padding: 0; overflow: hidden; position: relative; }
.cs-head { padding: 24px 22px 12px; text-align: center; position: relative; }
.cs-title { margin: 0; font-size: 22px; font-weight: 800; color: var(--text-bright); }
.cs-sub { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.create-server .pp-close { background: transparent; color: var(--muted); }
.create-server .pp-close:hover { background: var(--bg-3); color: var(--text); }
.cs-options { display: flex; flex-direction: column; gap: 10px; padding: 8px 16px 4px; }
.cs-option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-bright); font-weight: 600; font-size: 15px;
}
.cs-option:hover { background: var(--bg-3); border-color: var(--border-strong); }
.cs-option-ic { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; flex: none; }
.cs-option-label { flex: 1; }
.cs-chev { color: var(--muted); font-size: 22px; }
.cs-foot-note { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 16px 22px; }
.cs-body { padding: 8px 22px 4px; }
.cs-icon-row { display: flex; justify-content: center; margin: 6px 0 18px; }
.cs-icon-pick {
  width: 80px; height: 80px; border-radius: 50%; padding: 0; overflow: hidden;
  background: var(--bg-3); border: 2px dashed var(--border-strong); color: var(--muted);
  display: grid; place-items: center;
}
.cs-icon-pick:hover { border-color: var(--accent); color: var(--text); }
.cs-icon-ph { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
.cs-icon-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cs-field-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-bright); margin-bottom: 6px; }
.cs-body input { width: 100%; }
.cs-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px 22px; margin-top: 6px; }
.cs-footer .ghost { background: transparent; border: none; color: var(--text); }
.cs-footer .ghost:hover { text-decoration: underline; background: transparent; }
.cs-create-btn { flex: 1; max-width: 60%; }

/* ─── Settings: account card, sliders, media tests, keybinds ─────────────── */
.acct-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px 14px; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.acct-row:last-child { border-bottom: none; }
.acct-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); flex: none; }
.acct-val { color: var(--text); font-size: 14px; display: flex; align-items: center; gap: 8px; text-align: right; }
.acct-id code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; }
.acct-copy { padding: 3px 8px; font-size: 12px; }

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; }
.slider-val { font-variant-numeric: tabular-nums; color: var(--muted); width: 44px; text-align: right; }

.mic-meter { height: 10px; background: var(--bg-input); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.mic-meter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ok), var(--warn)); transition: width 0.05s linear; }
.cam-preview { margin-top: 8px; }
.cam-preview video { width: 100%; max-width: 320px; border-radius: 10px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }

/* Live preview shown above the Compact-mode switch. */
.density-preview {
  margin: 6px 0 4px; padding: 12px 14px 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); pointer-events: none; user-select: none;
  overflow: hidden;
}
.density-preview .dp-head {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.density-preview .dp-msg { display: flex; gap: 12px; padding: 7px 0; align-items: flex-start; }
.density-preview .dp-av {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 600;
}
.density-preview .dp-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.density-preview .dp-name { font-size: 13px; font-weight: 600; color: var(--text-bright); }
.density-preview .dp-name .dp-time { font-size: 10px; font-weight: 400; color: var(--muted); margin-left: 7px; }
.density-preview .dp-text { font-size: 13px; color: var(--text); line-height: 1.3; }
.density-preview .dp-mention { color: var(--accent); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-weight: 500; }
/* Mirror the chat text-size setting so the preview tracks it live. */
body.text-small .density-preview .dp-text { font-size: 12px; }
body.text-large .density-preview .dp-text { font-size: 16px; }
/* Compact: drop avatars, single-line rows, tighter spacing. */
.density-preview.is-compact .dp-msg { padding: 1px 0; gap: 8px; align-items: baseline; }
.density-preview.is-compact .dp-av { display: none; }
.density-preview.is-compact .dp-body { flex-direction: row; gap: 8px; align-items: baseline; }
.density-preview.is-compact .dp-name .dp-time { margin-left: 0; margin-right: 2px; }

.media-blur { position: relative; cursor: pointer; overflow: hidden; }
.media-blur img { filter: blur(28px); }
.media-blur::after { content: 'Click to reveal'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 600; background: rgba(0,0,0,0.3); }

/* ─── Explicit (NSFW) media: blur + click-to-reveal; locked for under-18 ─── */
.attach-image.nsfw-attach img { filter: blur(34px); }
/* Use the rich .nsfw-cover overlay instead of the generic "Click to reveal" one. */
.attach-image.nsfw-attach.media-blur::after { content: none; }
.attach-image.nsfw-attach:not(.media-blur) .nsfw-cover { display: none; }
.attach-image.nsfw-attach:not(.media-blur) img { filter: none; }
.nsfw-cover {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; text-align: center;
  color: #fff; background: rgba(22,10,16,0.6); padding: 8px; pointer-events: none;
}
.nsfw-cover .nsfw-main { font-weight: 700; font-size: 13px; }
.nsfw-cover .nsfw-sub { font-size: 11px; opacity: 0.82; }
.attach-image.nsfw-tile, .attach-image.nsfw-locked {
  position: relative; width: 240px; max-width: 70%; height: 160px; border-radius: 10px;
  background: repeating-linear-gradient(45deg, #1b1217, #1b1217 12px, #21171c 12px, #21171c 24px);
}
.attach-image.nsfw-locked { cursor: not-allowed; }
.attach-image.nsfw-tile { cursor: pointer; }

.keybinds { display: flex; flex-direction: column; }
.keybind-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.keybind-row:last-child { border-bottom: none; }
.keybind-row kbd { background: var(--bg-input); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 8px; font-size: 12px; font-family: inherit; color: var(--text-bright); }

/* ─── New-messages divider ───────────────────────────────────────────────── */
.date-sep { display: flex; align-items: center; gap: 10px; margin: 18px 16px 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.date-sep::before, .date-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.new-divider { display: flex; align-items: center; gap: 8px; margin: 8px 16px; color: var(--danger); }
.new-divider::before { content: ''; flex: 1; height: 1px; background: var(--danger); opacity: 0.6; }
.new-divider span { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; background: var(--danger); color: #fff; padding: 1px 6px; border-radius: 6px; }
.msg.flash { animation: msg-flash 1.4s ease; }
@keyframes msg-flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ─── Mentions inbox ─────────────────────────────────────────────────────── */
.inbox-item { display: flex; gap: 10px; padding: 10px 8px; border-radius: 8px; cursor: pointer; }
.inbox-item:hover { background: var(--bg-3); }
.inbox-item .avatar.small { width: 32px; height: 32px; flex: none; }
.inbox-body { min-width: 0; flex: 1; }
.inbox-top { display: flex; align-items: baseline; gap: 8px; }
.inbox-name { font-weight: 600; color: var(--text-bright); }
.inbox-ctx { font-size: 12px; color: var(--accent-2); }
.inbox-time { font-size: 11px; color: var(--muted); margin-left: auto; }
.inbox-text { color: var(--text); font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Composer autocomplete ──────────────────────────────────────────────── */
.ac-pop {
  position: fixed; z-index: 6200; background: var(--bg-floating);
  border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-lg);
  max-height: 264px; overflow-y: auto; padding-bottom: 4px;
}
.ac-head { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); padding: 8px 12px 4px; }
.ac-item { display: flex; align-items: center; gap: 9px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.ac-item.active { background: var(--accent-soft); }
.ac-item .avatar.small { width: 22px; height: 22px; font-size: 10px; flex: none; }
.ac-emoji-char { font-size: 18px; width: 22px; text-align: center; flex: none; }
.ac-emoji-img { width: 20px; height: 20px; object-fit: contain; flex: none; }
.ac-role-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; margin: 0 4px; }
.ac-slash { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pp-about { margin-bottom: 10px; }
.pp-about .pp-bio { white-space: pre-wrap; }
.ac-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Inline message edit ────────────────────────────────────────────────── */
.edit-wrap { margin-top: 3px; }
.edit-box {
  width: 100%; resize: none; min-height: 38px; font: inherit; color: var(--text);
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
.edit-box:focus { outline: none; border-color: var(--accent); }
.edit-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ─── Activity ("Playing X") ─────────────────────────────────────────────── */
.activity-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.activity-game { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-game .icon { color: var(--ok); flex: none; }
.activity-game strong { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.activity-elapsed { font-variant-numeric: tabular-nums; flex: none; }
.activity-line.compact { font-size: 11px; }
.dmp-activity { margin-top: 12px; }
.dmp-activity .activity-line { background: var(--bg-3); border-radius: 8px; padding: 8px 10px; margin-top: 5px; }
.pp-act-head { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 10px; }
.pp-act-game { display: flex; align-items: center; gap: 14px; background: var(--bg-2); border-radius: 10px; padding: 14px; }
.pp-act-icon { width: 54px; height: 54px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.pp-act-name { font-weight: 700; color: var(--text-bright); font-size: 15px; }
.pp-act-elapsed { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ─── Incoming call (ringing) ────────────────────────────────────────────── */
.incoming-call { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 6500; display: flex; justify-content: center; pointer-events: none; }
.ic-card {
  pointer-events: auto; background: var(--bg-floating); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 18px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 260px;
  animation: ic-pop 0.18s ease;
}
@keyframes ic-pop { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.ic-avatar .avatar.large { width: 72px; height: 72px; border-radius: 50%; font-size: 26px; }
.ic-avatar.ringing { border-radius: 50%; box-shadow: 0 0 0 0 var(--ok); animation: ic-ring 1.4s ease-out infinite; }
@keyframes ic-ring { 0% { box-shadow: 0 0 0 0 rgba(35,165,90,0.5); } 70% { box-shadow: 0 0 0 14px rgba(35,165,90,0); } 100% { box-shadow: 0 0 0 0 rgba(35,165,90,0); } }
.ic-name { font-size: 17px; font-weight: 700; color: var(--text-bright); margin-top: 4px; }
.ic-sub { font-size: 13px; color: var(--muted); }
.ic-actions { display: flex; gap: 28px; margin-top: 12px; }
.ic-btn { width: 54px; height: 54px; border-radius: 50%; padding: 0; display: grid; place-items: center; border: none; color: #fff; }
.ic-accept { background: var(--ok); }
.ic-accept:hover { filter: brightness(1.1); }
.ic-decline { background: var(--danger); }
.ic-decline:hover { filter: brightness(1.1); }
body.reduce-motion .ic-avatar.ringing { animation: none; }

/* ─── Call log message ───────────────────────────────────────────────────── */
.call-msg { display: flex; align-items: center; gap: 12px; padding: 7px 16px; }
.call-msg-icon {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--ok); color: #fff;
}
.call-msg.missed .call-msg-icon { background: var(--danger); }
.call-msg-text { color: var(--text); font-size: 14px; }
.call-msg-time { color: var(--muted); font-size: 11px; }

body.text-small .messages { font-size: 13px; }
body.text-large .messages { font-size: 17px; }

/* ─── Micro-interaction / animation layer ──────────────────────────────────────
 * Tasteful entrance + feedback animations. Everything here is wiped by the
 * .reduce-motion kill-switch below (and the OS prefers-reduced-motion media query),
 * so it never fights accessibility settings. */

/* New chat messages slide+fade in. Class is added on append, removed after 400ms. */
.msg.msg-enter { animation: msg-enter 0.26s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes msg-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Buttons gain a quick press-down + spring-back. */
button:active:not(:disabled),
.settings-nav-item:active,
.server-icon:active,
.tab-btn:active { transform: scale(0.94); }
button, .settings-nav-item, .server-icon, .tab-btn { transition: transform 0.08s cubic-bezier(0.3, 0.7, 0.4, 1.4), background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease; }

/* Dropdown / floating menus pop in. */
.floating-menu, .ctx-menu, .sp-menu, .emoji-picker, .gif-grid {
  animation: menu-pop 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* Sidebar rows + server icons settle in with a subtle stagger-friendly fade. */
.sidebar-item, .server-icon { animation: row-fade 0.22s ease both; }
@keyframes row-fade { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* Server-rail hover lift + active pill already exist; add a gentle hover scale. */
.server-icon:hover { transform: translateY(-1px); }

/* Toast / banner entrances. */
.toast, .announce-banner, .update-banner { animation: toast-in 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Reaction pop when added. */
.reaction.just-added { animation: react-pop 0.3s cubic-bezier(0.3, 0.7, 0.4, 1.5); }
@keyframes react-pop { 0% { transform: scale(0.4); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* Failed send shake. */
.msg.send-failed { animation: shake 0.32s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
/* Also respect the OS-level setting even without the in-app toggle. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── UI refresh: icon-heading, sec-cards, pw-toggle, sessions, blocked ── */

/* 1. icon + text heading alignment */
.icon-heading, .modal h3, .spatial-modal h3 {
  display: flex; align-items: center; gap: 7px;
}
.icon-heading svg, .modal h3 svg, .spatial-modal h3 svg { flex-shrink: 0; }

/* 2. settings section grouping */
.settings-section {
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px 0; border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section-head {
  display: flex; align-items: center; justify-content: space-between;
}
.settings-section-head h4 {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}

/* 3. security status cards */
.sec-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong); border-radius: var(--radius);
  padding: 13px 16px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.sec-card.ok   { border-left-color: var(--ok); }
.sec-card.warn { border-left-color: var(--warn); }
.sec-card-body { flex: 1; min-width: 0; }
.sec-card-title {
  font-size: 14px; font-weight: 600; color: var(--text-bright);
  display: flex; align-items: center; gap: 7px; margin-bottom: 3px;
}
.sec-card-sub { font-size: 12px; color: var(--muted); }
.sec-card-actions { display: flex; gap: 6px; align-items: flex-start; flex-shrink: 0; }

/* 4. password eye toggle */
.pw-field { position: relative; }
.pw-field input { padding-right: 40px; width: 100%; }
.pw-toggle {
  position: absolute; right: 0; top: 0; bottom: 0; width: 38px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted); padding: 0;
}
.pw-toggle:hover { color: var(--text); background: transparent; }

/* 5. login history table */
.history-table {
  display: flex; flex-direction: column;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
}
.history-row {
  display: grid; grid-template-columns: 14px 130px 110px 1fr;
  gap: 10px; align-items: center; padding: 9px 14px; font-size: 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: var(--bg-3); }
.hist-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.history-row.fail { color: rgba(242,63,67,.85); }
.history-row.fail .hist-dot { background: var(--danger); }
.history-row .ua { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 6. session device cards */
.session-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 16px;
  display: flex; gap: 14px; align-items: flex-start; transition: border-color .15s;
}
.session-card.current { border-color: var(--accent); background: var(--accent-soft); }
.session-card-icon {
  width: 36px; height: 36px; background: var(--bg-3); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); flex-shrink: 0;
}
.session-card.current .session-card-icon { background: rgba(88,101,242,.2); color: var(--accent); }
.session-card-body { flex: 1; min-width: 0; }
.session-card-name {
  font-weight: 600; font-size: 14px; color: var(--text-bright);
  display: flex; align-items: center; gap: 7px; margin-bottom: 3px;
}
.session-card-meta { font-size: 12px; color: var(--muted); line-height: 1.6; }
.session-card-actions { flex-shrink: 0; }

/* 7. blocked user rows */
.blocked-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.blocked-row-info { flex: 1; min-width: 0; }
.blocked-row-name { font-weight: 600; font-size: 14px; color: var(--text-bright); }
.blocked-row-sub { font-size: 12px; color: var(--muted); }

/* 8. danger zone */
.danger-zone {
  border: 1px solid rgba(242,63,67,.35); border-radius: var(--radius);
  padding: 16px; background: rgba(242,63,67,.05);
}
.danger-zone-head {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--danger); margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.danger-zone .muted-text { margin-bottom: 12px; }

/* 9. empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 36px 20px; color: var(--muted);
}
.empty-state svg { opacity: .3; }
.empty-state p { margin: 0; font-size: 14px; }

/* ════════════════════════════════════════════
   ANIMATION ADDITIONS
   ════════════════════════════════════════════ */

/* Settings panel slides in from right each tab switch (DOM recreated each time) */
.settings-panel {
  animation: panel-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes panel-in {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: none; }
}

/* Settings sections stagger in with per-child delay */
.settings-section {
  animation: section-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.settings-section:nth-child(2) { animation-delay: 45ms; }
.settings-section:nth-child(3) { animation-delay: 90ms; }
.settings-section:nth-child(4) { animation-delay: 135ms; }
.settings-section:nth-child(5) { animation-delay: 180ms; }
@keyframes section-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Security / session / blocked card hover lift */
.sec-card, .session-card, .blocked-row {
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.18s ease, border-color 0.15s ease;
}
.sec-card:hover, .session-card:hover, .blocked-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Online presence dot — gentle glow ripple */
.online-dot.online { animation: presence-pulse 3s ease-in-out infinite; }
.status-dot.status-online { animation: presence-pulse 3s ease-in-out infinite; }
@keyframes presence-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(35,165,90,0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(35,165,90,0); }
}

/* Voice call tile enter when someone joins */
.call-tile { animation: tile-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes tile-in {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: none; }
}

/* Reply / attach preview slides up when opened */
.attach-preview { animation: attach-up 0.18s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes attach-up {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

/* Date separators fade in */
.date-sep { animation: sep-fade 0.3s ease both; }
@keyframes sep-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Reaction chip hover scale */
.reaction-chip {
  transition: transform 0.12s cubic-bezier(0.3, 0.7, 0.4, 1.4),
              background 0.1s ease, border-color 0.1s ease;
}
.reaction-chip:hover { transform: scale(1.1); }

/* Member avatar hover lift */
.member-avatar-wrap {
  transition: transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1.4);
  cursor: pointer;
}
.member-avatar-wrap:hover { transform: scale(1.1); }

/* Pending (optimistic) message breathes while waiting for ack */
.msg.pending { animation: pending-breathe 1.8s ease-in-out infinite; }
@keyframes pending-breathe {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.68; }
}

/* Channel switch — messages area fades + rises when new chat loads */
.messages.chan-switch { animation: chan-in 0.22s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes chan-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

/* Unread badge pops in */
.unread-badge { animation: badge-pop 0.26s cubic-bezier(0.3, 0.7, 0.4, 1.5) both; }
.list-item.bumped { animation: list-bump 0.38s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes list-bump {
  0%   { transform: translateX(-10px); background: rgba(88,101,242,0.18); }
  60%  { transform: translateX(2px);   background: rgba(88,101,242,0.07); }
  100% { transform: translateX(0);     background: transparent; }
}
@keyframes badge-pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ── uploading file indicator ── */
.uploading-chip {
  position: relative;
  opacity: 0.85;
  overflow: hidden;
  border-color: var(--accent) !important;
  padding-bottom: 10px !important;
}
.uploading-chip::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  width: var(--upload-pct, 0%);
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  transition: width 0.2s ease;
}
.uploading-chip:not([style]) { animation: upload-indeterminate 1.4s ease-in-out infinite; }
@keyframes upload-indeterminate {
  0%   { border-color: var(--accent); }
  50%  { border-color: var(--accent-2); }
  100% { border-color: var(--accent); }
}
.upload-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid var(--bg-4);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-pct { color: var(--accent); font-size: 11px; font-variant-numeric: tabular-nums; }

/* settings modal close animation */
.settings-fullscreen.closing {
  animation: settings-out 0.18s ease-in forwards;
  pointer-events: none;
}
.settings-fullscreen.closing .settings-shell {
  animation: settings-shell-out 0.18s ease-in forwards;
}
@keyframes settings-out {
  to { opacity: 0; }
}
@keyframes settings-shell-out {
  to { opacity: 0; transform: translateY(6px) scale(0.985); }
}
/* discover-servers full-screen close animation (reuses the settings keyframes) */
.discover-fullscreen.closing { animation: settings-out 0.18s ease-in forwards; pointer-events: none; }
.discover-fullscreen.closing .discover-shell { animation: settings-shell-out 0.18s ease-in forwards; }

/* ── Markdown: blockquote + lists ───────────────────────────────────────────── */
.msg .text .md-bq {
  border-left: 4px solid var(--accent);
  margin: 4px 0;
  padding: 2px 10px;
  color: var(--text);
  background: rgba(var(--accent-rgb, 88,101,242), 0.08);
  border-radius: 0 4px 4px 0;
}
.msg .text .md-list {
  margin: 4px 0 4px 18px;
  padding: 0;
}
.msg .text .md-list li {
  margin: 2px 0;
}

/* ── Message search dropdown ─────────────────────────────────────────────────── */
.search-drop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: var(--bg-float, #2b2d31);
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 900;
  max-height: 380px;
  overflow-y: auto;
  min-width: 320px;
}
.search-drop-empty {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.search-drop-row {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.04));
  transition: background 0.1s;
}
.search-drop-row:last-child { border-bottom: none; }
.search-drop-row:hover { background: var(--bg-hover, rgba(255,255,255,0.05)); }
.search-drop-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.search-drop-meta strong { color: var(--text-bright); }
.search-drop-time { font-size: 11px; }
.search-drop-body { font-size: 13px; color: var(--text); line-height: 1.4; word-break: break-word; }
.search-drop-body mark { background: rgba(255,210,0,0.25); color: inherit; border-radius: 2px; }
.search-drop-all {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; cursor: pointer; font-size: 12.5px; color: var(--muted);
  border-top: 1px solid var(--border, rgba(255,255,255,0.06));
  position: sticky; bottom: 0; background: var(--bg-float, #2b2d31);
}
.search-drop-all:hover { background: var(--bg-hover, rgba(255,255,255,0.05)); color: var(--text-bright); }
.search-drop-all span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-drop-all kbd {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--bg-2, rgba(255,255,255,0.06)); border: 1px solid var(--border, rgba(255,255,255,0.08));
  color: var(--muted); font-family: inherit;
}

/* ── Global (all-chats) message search modal ─────────────────────────────────── */
.gsearch-box {
  display: flex; align-items: center; gap: 9px;
  margin: 4px 0 12px; padding: 9px 12px;
  background: var(--bg-2, rgba(0,0,0,0.2)); border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px; color: var(--muted);
}
.gsearch-box .gsearch-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text-bright); font-size: 15px;
}
.gsearch-box .gsearch-input::placeholder { color: var(--muted-2); }
.gsearch-results { max-height: 58vh; overflow-y: auto; margin: 0 -6px; }
.gsearch-empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.gsearch-row {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background 0.1s;
}
.gsearch-row:hover { background: var(--bg-hover, rgba(255,255,255,0.05)); }
.gsearch-rmain { min-width: 0; flex: 1; }
.gsearch-rmeta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.gsearch-rmeta strong { color: var(--text-bright); font-size: 13.5px; }
.gsearch-rloc { font-size: 11.5px; color: var(--accent, #8aa0ff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gsearch-rtime { font-size: 11px; color: var(--muted); margin-left: auto; }
.gsearch-rbody { font-size: 13px; color: var(--text); line-height: 1.42; word-break: break-word; }
.gsearch-rbody mark { background: rgba(255,210,0,0.25); color: inherit; border-radius: 2px; }

/* ── DM sidebar avatar ───────────────────────────────────────────────────────── */
.list-item .avatar.dm-av {
  width: 24px;
  height: 24px;
  font-size: 10px;
  flex-shrink: 0;
  border-radius: 50%;
}

/* ── Group settings modal ────────────────────────────────────────────────────── */
.gc-member-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; margin-bottom: 4px; }
.gc-member-row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: var(--radius-sm); }
.gc-member-row:hover { background: var(--bg-3); }
.gc-member-name { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-creator-badge { font-size: 10px; background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 7px; flex-shrink: 0; }
.gc-kick-btn { background: transparent; border: none; box-shadow: none; color: var(--muted); padding: 2px 4px; border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; }
.gc-kick-btn:hover { color: var(--danger); background: rgba(242,63,67,0.1); }
.gc-add-row { display: flex; gap: 6px; margin-bottom: 10px; }
.gc-add-row input { flex: 1; min-width: 0; }
.gc-section-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; margin-top: 14px; }

/* ── Sidebar last-message preview ───────────────────────────────────────────── */
.list-item .list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-item .list-text .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .list-preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.75; }
.list-item.has-unread .list-preview { opacity: 1; color: var(--text); }

/* ── Saved messages ─────────────────────────────────────────────────────────── */
.saved-msgs-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.saved-msg-item { background: var(--bg-3); border-radius: var(--radius); padding: 12px 14px; }
.saved-msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.saved-msg-info { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.saved-msg-author { font-weight: 600; font-size: 13px; color: var(--text); }
.saved-msg-chat { font-size: 11px; color: var(--muted); background: var(--bg-2); border-radius: 99px; padding: 1px 7px; }
.saved-msg-time { font-size: 11px; color: var(--muted); margin-left: auto; }
.saved-msg-content { font-size: 14px; color: var(--text-secondary); }
.saved-unsave-btn { color: var(--muted); padding: 3px 5px; }
.saved-unsave-btn:hover { color: var(--danger); background: rgba(242,63,67,.12); }
.saved-indicator { color: var(--accent); margin-left: 5px; vertical-align: middle; opacity: .7; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-icon { opacity: .3; }

/* ── v0.8.x — render-memory + micro-polish ──────────────────────────────────── */
/* Skip layout/paint/style work for off-screen messages. On long chats this is
   the single biggest render-memory win available in pure CSS. */
.msg { content-visibility: auto; contain-intrinsic-size: auto 56px; }

/* Typing indicator: three bouncing dots before the "X is typing…" text */
.typing-dots { display: inline-flex; gap: 3px; margin-right: 7px; align-items: center; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: typing-bounce 1.2s ease-in-out infinite; }
.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: none; opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* Soft focus behind dialogs */
.modal-bg { backdrop-filter: blur(3px); }

/* Images fade in instead of popping */
.attachments img, .inline-gif img { animation: img-fade 0.28s ease; }
@keyframes img-fade { from { opacity: 0; } }

/* Reaction chips pop in */
.reaction-chip { animation: chip-in 0.18s cubic-bezier(0.3, 0.7, 0.4, 1.3); }
@keyframes chip-in { from { opacity: 0; transform: scale(0.85); } }

/* Jump-to-present slides up when it appears */
.jump-bottom { animation: jump-in 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes jump-in { from { opacity: 0; transform: translateY(8px); } }

/* Sidebar items nudge right on hover */
.list-item { transition: background 0.1s ease, color 0.1s ease, transform 0.12s ease; }
.list-item:hover { transform: translateX(2px); }

@media (prefers-reduced-motion: reduce) {
  .typing-dots i, .attachments img, .inline-gif img, .reaction-chip, .jump-bottom { animation: none; }
  .list-item:hover { transform: none; }
}

/* ─── Spotify integration ─────────────────────────────────────────────────── */
/* Inline embed player for Spotify links in chat */
.spotify-embed {
  display: block; width: min(420px, 100%); height: 152px;
  border: 0; border-radius: 12px; margin-top: 8px; background: transparent;
  animation: img-fade 0.28s ease;
}
.spotify-embed.tall { height: 352px; }

/* "Listening to ..." activity line (member list, user panel) */
.activity-line.spotify .activity-game svg { color: #1db954; }
.activity-line.spotify strong { color: var(--text-bright); }

/* Profile popout — Spotify card */
.pp-activity-card.spotify .pp-act-head { color: #1db954; }
/* Spotify logo: green on dark, never recolored (brand guidelines) */
.pp-act-icon.spotify { background: #191414; color: #1db954; }
.pp-act-art { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; flex: none; }
.pp-act-artist { font-size: 13px; color: var(--muted); margin-top: 1px; }
a.pp-act-name { text-decoration: none; }
a.pp-act-name:hover { text-decoration: underline; }

/* Settings → Connections */
.conn-card .conn-head { display: flex; align-items: center; gap: 9px; }
.conn-logo { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.conn-logo.spotify { color: #1db954; }
.conn-connect-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: #1db954; color: #fff; border: 0; border-radius: 6px;
  padding: 9px 16px; font-weight: 600; cursor: pointer;
}
.conn-connect-btn:hover { background: #1ed760; }

@media (prefers-reduced-motion: reduce) {
  .spotify-embed { animation: none; }
}


/* ── Avatar ornaments (decorations) ───────────────────────────────────────────
   Real animated decorations, not flat rings: a masked pseudo-element holds a
   conic-gradient ring that spins (drop-shadow gives the glow), and ::after adds
   orbiting sparkles on some. has-orn flips the avatar to overflow:visible so the
   ring/sparkles sit just outside the circular avatar without clipping. */
.avatar.has-orn { position: relative; overflow: visible; }
.avatar.has-orn img { border-radius: 50%; }
.avatar.has-orn::before,
.avatar.has-orn::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  pointer-events: none;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
}
.avatar.has-orn::after { background: none; } /* default: only ::before draws a ring */

@keyframes orn-spin { to { transform: rotate(360deg); } }
@keyframes orn-flicker { 0%, 100% { opacity: .82; } 45% { opacity: 1; } 70% { opacity: .9; } }
@keyframes orn-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.avatar[data-orn="gold"]::before {
  background: conic-gradient(from 0deg, #b8860b, #ffe9a8, #f6c453, #fff6d0, #d4a017, #ffe9a8, #b8860b);
  filter: drop-shadow(0 0 5px rgba(246,196,83,.65));
  animation: orn-spin 6s linear infinite;
}
.avatar[data-orn="neon"]::before {
  inset: -5px;
  background: conic-gradient(from 0deg, #00e5ff, #7c87ff, #ff4ecd, #00e5ff);
  filter: drop-shadow(0 0 8px rgba(124,135,255,.85));
  animation: orn-spin 2.6s linear infinite;
}
.avatar[data-orn="ember"]::before {
  background: conic-gradient(from 0deg, #ff3d00, #ff8a00, #ffd000, #ff8a00, #ff3d00);
  filter: drop-shadow(0 0 7px rgba(255,95,0,.8));
  animation: orn-spin 3.5s linear infinite, orn-flicker 1.5s ease-in-out infinite;
}
.avatar[data-orn="frost"]::before {
  background: conic-gradient(from 0deg, #a8eaff, #ffffff, #6fd0ff, #e6f9ff, #a8eaff);
  filter: drop-shadow(0 0 6px rgba(143,216,255,.75));
  animation: orn-spin 7s linear infinite;
}
.avatar[data-orn="frost"]::after {
  inset: -7px;
  -webkit-mask: none; mask: none;
  background:
    radial-gradient(circle at 50% 0,    #fff 0 1.4px, transparent 2.2px),
    radial-gradient(circle at 100% 50%, #fff 0 1.2px, transparent 2px),
    radial-gradient(circle at 50% 100%, #fff 0 1.4px, transparent 2.2px),
    radial-gradient(circle at 0 50%,    #fff 0 1.2px, transparent 2px);
  filter: drop-shadow(0 0 2px #cdeeff);
  animation: orn-spin 9s linear infinite reverse;
}
.avatar[data-orn="emerald"]::before {
  background: conic-gradient(from 0deg, #0f9d58, #5dffb0, #34d399, #0a7d44, #5dffb0, #0f9d58);
  filter: drop-shadow(0 0 6px rgba(52,211,153,.65));
  animation: orn-spin 5.5s linear infinite;
}
.avatar[data-orn="amethyst"]::before {
  background: conic-gradient(from 0deg, #7a1fff, #c08bff, #b07bff, #5e17c0, #e0c3ff, #7a1fff);
  filter: drop-shadow(0 0 7px rgba(176,123,255,.75));
  animation: orn-spin 4.5s linear infinite;
}
.avatar[data-orn="rose"]::before {
  background: conic-gradient(from 0deg, #ff5fa2, #ffd1e6, #ff8fc7, #ff2e88, #ffd1e6, #ff5fa2);
  filter: drop-shadow(0 0 6px rgba(255,143,199,.7));
  animation: orn-spin 5s linear infinite;
}
.avatar[data-orn="rainbow"]::before {
  inset: -5px;
  background: conic-gradient(from 0deg, #ff0040, #ff8a00, #ffe600, #00e000, #00b3ff, #7a3cff, #ff00c8, #ff0040);
  filter: drop-shadow(0 0 8px rgba(255,0,140,.55));
  animation: orn-spin 3s linear infinite;
}
.avatar[data-orn="midnight"]::before {
  background: conic-gradient(from 0deg, #1b2452, #5c6ecd, #2a3a8f, #8aa0ff, #2a3a8f, #1b2452);
  filter: drop-shadow(0 0 9px rgba(92,110,205,.8));
  animation: orn-spin 6s linear infinite;
}
.avatar[data-orn="midnight"]::after {
  inset: -8px;
  -webkit-mask: none; mask: none;
  background:
    radial-gradient(circle at 50% 0,   #fff    0 1.4px, transparent 2.2px),
    radial-gradient(circle at 86% 78%, #cdd6ff 0 1.2px, transparent 2px),
    radial-gradient(circle at 14% 75%, #fff    0 1px,   transparent 1.8px);
  filter: drop-shadow(0 0 3px #8aa0ff);
  animation: orn-spin 12s linear infinite;
}

/* Ornament picker grid in Settings → Profile */
.orn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.orn-cell { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 6px 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.orn-cell:hover { border-color: var(--border-strong); }
.orn-cell.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-input)); }
.orn-cell .avatar.orn-preview { width: 44px; height: 44px; font-size: 17px; }
.orn-name { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.orn-cell.active .orn-name { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .avatar.has-orn::before, .avatar.has-orn::after { animation: none !important; }
}

/* Ornaments on profile avatars: the .pp/.dmp large avatars carry a thick 6px
   border (banner cutout) that would hide a -4px ring, so push it outside. */
.pp-avatar-wrap .avatar.large.has-orn::before,
.dmp-avatar-wrap .avatar.large.has-orn::before { inset: -9px; }
.pp-avatar-wrap .avatar.large.has-orn::after,
.dmp-avatar-wrap .avatar.large.has-orn::after { inset: -12px; }

/* ── Profile card color (user.card_color → --card-accent) ──────────────────── */
/* Colours the profile PANEL background only — not text, and not the activity
   section (the popout's .pp-right column / the DM panel's .dmp-activity block). */
.card-color-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.card-color-preview {
  --card-accent: var(--accent);
  width: 172px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 10px;
  background: color-mix(in srgb, var(--card-accent) 30%, var(--bg-2)); padding: 10px;
}
.card-color-preview .ccp-row { display: flex; gap: 8px; align-items: center; }
.card-color-preview .ccp-av { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.28); flex: 0 0 auto; }
.card-color-preview .ccp-lines { flex: 1; }
.card-color-preview .ccp-l1 { height: 8px; width: 70%; border-radius: 4px; background: rgba(255,255,255,.48); }
.card-color-preview .ccp-l2 { height: 6px; width: 45%; border-radius: 4px; background: rgba(255,255,255,.22); margin-top: 5px; }
.card-color-preview .ccp-activity { margin-top: 10px; font-size: 10px; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 6px 8px; }
.card-color-input { width: 38px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); cursor: pointer; }

/* Profile popout: tint the left profile panel; the activity column (.pp-right) stays default. */
.profile-pop.has-card-accent .pp-left { background: color-mix(in srgb, var(--card-accent) 30%, var(--bg-2)); }

/* DM side panel: tint the card; keep the activity block on its own neutral surface. */
.dm-profile.has-card-accent .dmp-card { background: color-mix(in srgb, var(--card-accent) 30%, var(--bg-floating)); }
.dm-profile.has-card-accent .dmp-activity .activity-line { background: var(--bg-3); }

/* ─── Events: admin editor + user popup modal ─────────────────────────────── */
.event-editor { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 10px; }
.event-form-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.ev-lbl { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.ev-lbl input, .ev-lbl textarea { width: 100%; }
.ev-lbl input[type="color"] { width: 52px; height: 38px; padding: 2px; cursor: pointer; }
.ev-field-row { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.ev-f-copy { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ev-f-del { padding: 6px 10px; }
.event-preview { margin-top: 16px; }

/* Popup modal (also rendered as live preview in the admin editor) */
.event-modal-root { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: grid; place-items: center; z-index: 5200; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)); animation: ev-fade 0.18s ease; }
@keyframes ev-fade { from { opacity: 0; } to { opacity: 1; } }
.ev-modal-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; width: 440px; max-width: 100%; max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 18px 50px rgba(0,0,0,0.5); animation: ev-pop 0.2s cubic-bezier(.2,.9,.3,1.2); }
/* Android/small screens: vh overshoots the visible viewport (system bars +
   collapsible browser chrome), pushing the card's bottom offscreen — size
   against the dynamic viewport instead. */
@supports (height: 100dvh) {
  .ev-modal-card { max-height: min(86vh, calc(100dvh - 56px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))); }
}
.event-preview .ev-modal-card { box-shadow: none; width: 100%; animation: none; }
@keyframes ev-pop { from { transform: translateY(10px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.ev-modal-accent { height: 6px; background: var(--ev-accent, var(--accent)); }
.ev-modal-body { padding: 22px 22px 20px; overflow: auto; position: relative; }
.ev-modal-close { position: absolute; top: 12px; right: 14px; background: transparent; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; line-height: 1; }
.ev-modal-close:hover { color: var(--text); }
.ev-modal-title { margin: 0 28px 8px 0; font-size: 20px; color: var(--ev-accent, var(--accent)); }
.ev-modal-desc { margin: 0 0 16px; color: var(--text); font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.ev-modal-fields { display: flex; flex-direction: column; gap: 10px; }
.ev-field { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; transition: border-color 0.12s, background 0.12s; }
.ev-field.copyable { cursor: pointer; }
.ev-field.copyable:hover { border-color: var(--ev-accent, var(--accent)); background: color-mix(in srgb, var(--ev-accent, var(--accent)) 12%, var(--bg-3)); }
.ev-field.copied { border-color: var(--ev-accent, var(--accent)); background: color-mix(in srgb, var(--ev-accent, var(--accent)) 20%, var(--bg-3)); }
.ev-field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 3px; }
.ev-field-value { font-size: 15px; color: var(--text); font-weight: 600; word-break: break-word; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ev-copy-hint { font-size: 11px; font-weight: 500; color: var(--ev-accent, var(--accent)); opacity: 0.85; white-space: nowrap; flex-shrink: 0; }
.ev-modal-ok { margin-top: 18px; width: 100%; padding: 11px; font-size: 14px; background: var(--ev-accent, var(--accent)); border: none; border-radius: 8px; color: #fff; cursor: pointer; }
.ev-modal-ok:hover { filter: brightness(1.08); }
@media (max-width: 560px) {
  .event-form-grid { grid-template-columns: 1fr; }
  .ev-field-row { grid-template-columns: 1fr 1fr; }
  .ev-field-row .ev-f-value { grid-column: 1 / -1; }
}

/* ─── Events list inside user Settings ─────────────────────────────────────── */
.events-settings-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.event-list-card { background: var(--bg-3); border: 1px solid var(--border); border-left: 3px solid var(--ev-accent, var(--accent));
  border-radius: 8px; padding: 12px 14px; }
.event-list-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.event-list-title { font-weight: 700; font-size: 15px; color: var(--ev-accent, var(--accent)); }
.event-list-desc { color: var(--text); font-size: 13px; margin-top: 3px; white-space: pre-wrap; }
.event-list-fields { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.event-list-field { background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 9px; font-size: 12px; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.event-list-field.copyable { cursor: pointer; }
.event-list-field.copyable:hover { border-color: var(--ev-accent, var(--accent)); }
.event-list-field.copied { border-color: var(--ev-accent, var(--accent)); color: var(--ev-accent, var(--accent)); }

/* ─── Polls ─────────────────────────────────────────────────────────────── */
.poll-card {
  margin-top: 6px;
  max-width: 480px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.poll-head {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.02em;
  margin-bottom: 8px;
}
.poll-question { font-weight: 600; }
.poll-opt {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  width: 100%; gap: 10px; overflow: hidden;
  margin: 0 0 6px; padding: 8px 10px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.poll-opt:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-4); }
.poll-opt.voted { border-color: var(--accent); }
.poll-opt:disabled { cursor: default; }
.poll-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent-soft);
  transition: width 0.35s ease;
  pointer-events: none;
}
.poll-opt.voted .poll-fill { background: rgba(88, 101, 242, 0.3); }
.poll-opt-label { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.poll-opt-label .icon-check { color: var(--accent); flex: none; }
.poll-opt-count { position: relative; flex: none; color: var(--muted); font-size: 12px; }
.poll-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--muted); font-size: 12px; margin-top: 2px;
}
.poll-close-btn { padding: 0; font-size: 12px; }
.poll-card.closed .poll-opt { opacity: 0.85; }
.poll-editor-opts { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.poll-editor-row { display: flex; gap: 6px; align-items: center; }
.poll-editor-row .input { flex: 1; }
.poll-editor-add { align-self: flex-start; margin-bottom: 6px; }

/* Timed-out member badge (right-panel member list) */
.member .timeout-badge {
  display: inline-flex; align-items: center;
  color: var(--danger); flex: none; margin-left: auto;
  opacity: 0.9;
}

/* ─── Watch Together (shared YouTube player in calls) ─────────────────────── */
/* Fixed overlay that position-tracks the .watch-slot placeholder — the iframe
   can't live inside the voice bar / stage because those rebuild constantly and
   reparenting an iframe reloads it. Parked offscreen (audio keeps playing)
   when no slot is visible. z: above page content but under modals normally;
   above the call stage (6000) while it's open, still under menus (6200). */
#watchOverlay {
  position: fixed; z-index: 45; display: flex; flex-direction: column;
  background: #000; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
body.stage-open #watchOverlay { z-index: 6100; }
#watchOverlay.watch-hidden { left: -10000px !important; top: 0 !important; box-shadow: none; }
.watch-head {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 34px;
  flex: none; background: var(--bg-floating); color: var(--text-bright);
  font-size: 13px; border-bottom: 1px solid var(--border);
}
.watch-head > svg { color: #ff4d4d; flex: none; }
.watch-head .watch-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch-head button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 6px; display: flex; flex: none;
}
.watch-head button:hover { color: var(--text-bright); background: var(--bg-3); }
.watch-body { position: relative; flex: 1; min-height: 0; }
.watch-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.watch-gesture {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: rgba(0, 0, 0, 0.6);
}
.watch-gesture button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 12px 22px; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* Placeholder the overlay tracks. Voice bar: player above a strip of small
   tiles; call stage: player takes the space, tiles become a bottom strip. */
.voice-bar .watch-slot { width: 100%; max-width: 660px; margin: 0 auto; aspect-ratio: 16 / 9; max-height: 38vh; flex: none; }
.voice-bar.watching { max-height: 80vh; }
.voice-bar.watching .call-tiles { flex: none; display: flex; gap: 8px; overflow-x: auto; justify-content: center; align-content: initial; }
.voice-bar.watching .call-tile { flex: 0 0 150px; width: 150px; max-height: none; }
.call-stage .watch-slot { flex: 1 1 auto; min-height: 0; margin: 0 22px; }
.call-stage.watching .stage-grid {
  flex: 0 0 auto; display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden;
  padding: 10px 22px 4px; align-content: initial;
}
.call-stage.watching .stage-grid .call-tile { flex: 0 0 170px; width: 170px; aspect-ratio: 16 / 9; max-height: none; cursor: default; }

/* Search results in the "Watch together" modal */
.watch-results { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; margin-top: 10px; }
.watch-result { display: flex; gap: 10px; padding: 6px; border-radius: 8px; cursor: pointer; align-items: flex-start; }
.watch-result:hover { background: var(--bg-3); }
.watch-thumb { position: relative; flex: none; }
.watch-thumb img { width: 122px; height: 69px; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.watch-dur {
  position: absolute; right: 4px; bottom: 4px; background: rgba(0, 0, 0, 0.8);
  color: #fff; font-size: 11px; padding: 1px 4px; border-radius: 4px;
}
.watch-meta { flex: 1; min-width: 0; }
.watch-rtitle {
  font-size: 14px; font-weight: 600; color: var(--text-bright); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.watch-rsub { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px) {
  .voice-bar .watch-slot { max-height: 30vh; }
  .call-stage .watch-slot { margin: 0 10px; }
  .call-stage.watching .stage-grid { padding: 8px 10px 2px; }
  .call-stage.watching .stage-grid .call-tile { flex: 0 0 130px; width: 130px; }
  .watch-thumb img { width: 104px; height: 59px; }
}

/* ─── Whiteboard (Activities) ─────────────────────────────────────────────────
   Same slot-tracking overlay pattern as #watchOverlay; the .wb-slot placeholder
   also carries .watch-slot so it inherits all the slot sizing rules above.
   z: just under the watch player so both can coexist, still under menus. */
#wbOverlay {
  position: fixed; z-index: 44; display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
body.stage-open #wbOverlay { z-index: 6090; }
#wbOverlay.watch-hidden { left: -10000px !important; top: 0 !important; box-shadow: none; }
#wbOverlay .watch-head > svg { color: var(--accent); }
.wb-body { position: relative; flex: 1; min-height: 0; background: var(--bg-1); }
.wb-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.wb-tools {
  display: flex; align-items: center; gap: 7px; padding: 6px 10px; flex: none;
  background: var(--bg-floating); border-top: 1px solid var(--border); flex-wrap: wrap;
}
.wb-swatch {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid transparent;
  cursor: pointer; padding: 0; flex: none;
}
.wb-swatch.sel { border-color: var(--text-bright); }
.wb-gap { flex: 1; }
.wb-size, .wb-tool {
  width: 26px; height: 26px; border-radius: 6px; border: 0; background: none;
  color: var(--muted); cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex: none; padding: 0;
}
.wb-size:hover, .wb-tool:hover { background: var(--bg-3); color: var(--text-bright); }
.wb-size.sel, .wb-tool.sel { background: var(--bg-3); color: var(--text-bright); }
.wb-tool.sel { color: var(--accent); }
.wb-size i { border-radius: 50%; background: currentColor; display: block; }

/* ─── Embedded game overlay (Activities) — same pattern as #watchOverlay ───── */
#gameOverlay {
  position: fixed; z-index: 43; display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
body.stage-open #gameOverlay { z-index: 6085; }
#gameOverlay.watch-hidden { left: -10000px !important; top: 0 !important; box-shadow: none; }
#gameOverlay .watch-head > svg { color: var(--accent); }
#gameOverlay iframe { background: #000; }

/* ─── Activities picker: big logo-card launcher (Discord-style), not a menu ── */
.activities-modal { max-width: 470px; width: min(470px, calc(100vw - 32px)); }
.activities-head { display: flex; align-items: center; justify-content: space-between; }
.activities-head h3 { margin: 0; }
.activities-sub { margin: 4px 0 14px; }
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-row {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2);
  cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.activity-row:hover { background: var(--bg-3); border-color: var(--accent); }
.activity-row:active { transform: scale(0.985); }
.activity-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.activity-row > .icon-arrow-right { color: var(--muted); flex: none; }
.activity-logo {
  width: 56px; height: 56px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.activity-logo.yt, .activity-logo.gartic, .activity-logo.twitch { background: #fff; }
.activity-logo.wb { background: var(--accent-soft); color: var(--accent); }
.activity-logo img { width: 40px; height: 40px; display: block; object-fit: contain; }
.activity-logo svg { display: block; }
.activity-meta { flex: 1; min-width: 0; }
.activity-name {
  font-size: 15px; font-weight: 700; color: var(--text-bright);
  display: flex; align-items: center; gap: 8px;
}
.activity-live {
  font-size: 10px; font-weight: 800; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 6px; background: var(--accent); color: #fff;
}
.activity-desc { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.activity-end {
  flex: none; background: none; border: 1px solid var(--border);
  color: #e5484d; border-radius: 8px; padding: 6px 12px; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.activity-end:hover { background: rgba(229, 72, 77, 0.12); border-color: #e5484d; }

/* ─── Soundboard (Discord-style popover anchored to the call controls) ────── */
/* .sb-pop rides on .floating-menu (stage z-index bump, Escape close, phone
   bottom sheet); everything inside is scoped .sb-pop so the generic
   .floating-menu button rules don't restyle the sound buttons. */
.sb-pop {
  position: fixed;
  width: min(440px, calc(100vw - 24px));
  padding: 12px;
  background: var(--bg-2);
}
.sb-pop .sb-search { position: relative; display: flex; align-items: center; margin-bottom: 12px; }
.sb-pop .sb-search-input {
  flex: 1; min-width: 0; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 34px 9px 12px; color: var(--text); font-size: 14px;
}
.sb-pop .sb-search-input:focus { outline: none; border-color: var(--accent); }
.sb-pop .sb-search > svg { position: absolute; right: 11px; color: var(--muted); pointer-events: none; }
.sb-pop .sb-body { max-height: min(46vh, 400px); overflow-y: auto; padding-right: 2px; }
.sb-section { margin-bottom: 14px; }
.sb-section:last-child { margin-bottom: 2px; }
.sb-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--muted); margin: 2px 0 8px;
}
.sb-srv-icon {
  flex: none; width: 20px; height: 20px; border-radius: 6px; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-srv-initial { background: var(--bg-3); font-size: 10px; letter-spacing: 0; color: var(--text); }
.sb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sb-pop .sb-sound {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px;
  padding: 8px 10px; border-radius: 8px; text-align: center;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 13px;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.sb-pop .sb-sound:hover { border-color: var(--border-strong); background: var(--bg-4); }
.sb-pop .sb-sound:active { transform: scale(0.96); }
.sb-pop .sb-sound:disabled { opacity: 0.45; cursor: default; transform: none; }
.sb-sound .sb-emoji { flex: none; font-size: 15px; line-height: 1; }
.sb-sound .sb-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; font-weight: 600; min-width: 0;
}
.sb-emoji-pick {
  flex: none; width: 38px; height: 38px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 18px; line-height: 1; padding: 0;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.sb-emoji-pick:hover { border-color: var(--accent); }
@media (max-width: 760px) {
  /* Bottom sheet on phones (the generic .floating-menu rules pin it); just
     cap the list height so the search bar stays reachable. */
  .sb-pop .sb-body { max-height: 52dvh; }
  .sb-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Mobile friendliness (2026-07-04) ────────────────────────────────────── */
/* Floating menus become bottom sheets on phones: full-width, thumb-reachable,
   with a dimmed backdrop (the huge-spread shadow trick — tapping it closes the
   menu via the existing outside-click handler). !important beats the inline
   top/left that positionFloatingMenu sets for the desktop anchor position. */
@keyframes sheet-up { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 760px) {
  .floating-menu {
    position: fixed !important;
    left: 10px !important; right: 10px !important;
    top: auto !important; bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    max-width: none; max-height: 62vh; overflow-y: auto;
    border-radius: 16px; padding: 8px;
    transform-origin: bottom center !important;
    animation: sheet-up 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45), var(--shadow-lg);
  }
  .floating-menu button { padding: 13px 14px; font-size: 15px; border-radius: 10px; }
  .floating-menu.fm-icons button svg { width: 18px; height: 18px; }
  /* Volume row fills the bottom sheet; booster stays a compact square */
  .fm-volume { width: 100%; padding: 10px 14px 12px; }
  .floating-menu .fm-boost { width: 34px; height: 28px; padding: 0; }
  .floating-menu.emoji-picker.wide { max-width: none; }
  /* Bigger touch targets in the sidebar + chat header */
  .list-item { min-height: 42px; }
  .vmem { min-height: 34px; }
  .hd-actions .ghost.icon-btn { min-width: 38px; min-height: 38px; }
}
/* Touch devices have no hover: keep the per-message ⋯ menu button visible so
   the message menu is discoverable without knowing about long-press. */
@media (hover: none) {
  .msg .msg-menu-btn { opacity: 0.55; }
  .reaction-chip { min-height: 30px; }
}
