:root, :root[data-theme="dark"] {
  --bg-0: #13141c;      /* guild rail */
  --bg-1: #1a1b26;      /* sidebars */
  --bg-2: #1f2130;      /* chat */
  --bg-3: #292c3f;      /* inputs, hovers */
  --bg-4: #33374d;      /* active */
  --panel: #171821;     /* user panel */
  --line: #2b2e42;
  --text: #d5daf0;
  --text-2: #a1a8c9;
  --muted: #6e7596;
  /* Brand: #884499 plus #BB6688 #8888CC #CCAA88 #DDAACC (README → Customising). */
  --accent: #884499;
  --accent-2: #9b55ad;
  --accent-ink: #ffffff;
  --accent-text: #ddaacc;  /* the accent where it's text or a thin line on dark panels */
  --danger: #f7768e;
  --danger-bg: rgba(247, 118, 142, .12);
  --danger-text: #ffb3c1;
  --ok: #9ece6a;
  --warn: #e0af68;
  --idle: #e0af68;
  --dnd: #f7768e;
  --mention-bg: rgba(224, 175, 104, .09);
  --mention-bar: #e0af68;
  --pill-bg: rgba(136, 68, 153, .3);
  --pill-text: #eecce4;
  --code-bg: #15161f;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --scrim: rgba(8, 9, 14, .7);
  --radius: 8px;
  --rail-w: 72px;
  --side-w: 240px;
  --members-w: 240px;
  --font-size: 15px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-0: #e3e5ec;
  --bg-1: #f0f1f5;
  --bg-2: #ffffff;
  --bg-3: #e6e8ef;
  --bg-4: #d7dae5;
  --panel: #e8eaf0;
  --line: #d9dce6;
  --text: #1f2233;
  --text-2: #4a5070;
  --muted: #7a8099;
  --accent: #884499;
  --accent-2: #733a82;
  --accent-ink: #ffffff;
  --accent-text: #884499;
  --danger: #d63d5a;
  --danger-bg: rgba(214, 61, 90, .1);
  --danger-text: #a82540;
  --ok: #3f8f2a;
  --warn: #b7791f;
  --idle: #d69e2e;
  --dnd: #d63d5a;
  --mention-bg: rgba(214, 158, 46, .12);
  --mention-bar: #d69e2e;
  --pill-bg: rgba(136, 68, 153, .13);
  --pill-text: #6d3480;
  --code-bg: #f1f2f6;
  --shadow: 0 12px 40px rgba(20, 24, 40, .18);
  --scrim: rgba(20, 22, 32, .45);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-2);
  color: var(--text);
  font: var(--font-size)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.small { font-size: .87em; }
.block { display: block; }
.mono { font-family: var(--mono); }
.pad { padding: 8px; }
.scroll { overflow-y: auto; overscroll-behavior: contain; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer;
  background: var(--bg-3); color: var(--text); font-weight: 600; font-size: 14px;
  transition: background .12s, opacity .12s; white-space: nowrap;
}
.btn:hover { background: var(--bg-4); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.link { background: none; padding: 0; color: var(--accent-text); font-weight: 500; font-size: inherit; }
.btn.link:hover { text-decoration: underline; }
.btn.block { width: 100%; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.icon-btn {
  border: 0; background: none; color: var(--text-2); cursor: pointer; position: relative;
  width: 28px; height: 28px; border-radius: 6px; display: inline-grid; place-items: center;
  font-size: 16px; line-height: 1; flex: none;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
input, textarea, select {
  width: 100%; background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 11px; font-weight: 400; font-size: 15px;
}
input[type="color"] { width: 48px; height: 36px; padding: 2px; cursor: pointer; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-text); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text); font-size: 14px; }
.check input { width: auto; accent-color: var(--accent); }
.stack { display: grid; gap: 14px; }
.stack.narrow { max-width: 480px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row > input { flex: 1; }
.grow { flex: 1; }
.hint { margin: -6px 0 0; }

.error-box {
  margin-top: 14px; padding: 10px 12px; border-radius: 6px;
  background: var(--danger-bg); color: var(--danger-text); font-size: 14px;
}
.error-box.info { background: var(--pill-bg); color: var(--pill-text); margin-top: 0; }

.badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.badge.small { min-width: 14px; height: 14px; font-size: 9px; padding: 0 3px; position: absolute; top: -2px; right: -2px; }
.tag {
  display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 4px; vertical-align: middle;
  font-size: 10px; font-weight: 700; letter-spacing: .03em; background: var(--pill-bg); color: var(--pill-text);
}
.tag.ok { background: rgba(158, 206, 106, .15); color: var(--ok); }
.tag.warn, .tag.pending { background: rgba(224, 175, 104, .18); color: var(--warn); }
.tag.disabled, .tag.rejected { background: var(--danger-bg); color: var(--danger); }

/* ---------- full-screen cards (connect / setup / auth) ---------- */
.screen {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-3), var(--bg-1));
}
.card {
  width: 100%; max-width: 400px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.card.wide { max-width: 480px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 24px; letter-spacing: -.01em; }
/* The logo is client/assets/logo.png — swap the file to rebrand. */
.brand-mark { display: inline-block; width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.server-title { margin: 12px 0 2px; font-size: 22px; }
.card p { margin: 0 0 18px; }
.card .stack p { margin: 0; }

.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 16px 0 18px; counter-reset: step; }
.steps li {
  flex: 1; font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 8px;
  border-top: 3px solid var(--bg-3); counter-increment: step;
}
.steps li::before { content: counter(step) ". "; }
.steps li[aria-current="step"] { color: var(--text); border-color: var(--accent); }
.steps li.done { color: var(--text-2); border-color: var(--ok); }

.saved-servers { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.saved-servers:empty { display: none; }
.saved-server {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  background: var(--bg-1); border: 1px solid var(--line); cursor: pointer;
}
.saved-server:hover { border-color: var(--accent); }
.saved-server .meta { flex: 1; min-width: 0; }
.saved-server .name { font-weight: 600; }
.saved-server .url { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 4px; background: var(--bg-0); padding: 4px; border-radius: 8px; margin: 18px 0; }
.tabs.inline { margin: 0; }
.tab {
  flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer;
  color: var(--text-2); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--bg-3); color: var(--text); }

/* ---------- app layout ---------- */
#app {
  height: 100%; display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--members-w);
}
#app.members-hidden { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr); }
#app.members-hidden #member-list { display: none; }
#app.no-members { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr); }
#app.no-members #member-list, #app.no-members .members-btn { display: none !important; }
#guild-rail {
  background: var(--bg-0); padding: 12px 0; display: flex; flex-direction: column;
  align-items: center; gap: 8px; overflow-y: auto; scrollbar-width: none;
}
#guild-rail::-webkit-scrollbar { display: none; }
.rail-sep { width: 32px; height: 2px; background: var(--line); border-radius: 1px; flex: none; }
.rail-spacer { flex: 1; min-height: 8px; }
.guild-icon {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 24px; border: 0;
  background: var(--bg-2); color: var(--text); cursor: pointer; font-weight: 700; font-size: 16px;
  display: grid; place-items: center; transition: border-radius .15s, background .15s;
}
.guild-icon.static { width: 40px; height: 40px; font-size: 13px; cursor: default; border-radius: 12px; background: var(--bg-3); }
.guild-icon:not(.static):hover, .guild-icon.active { border-radius: 16px; background: var(--accent); color: var(--accent-ink); }
.guild-icon.home, .guild-icon.home:not(.static):hover, .guild-icon.home.active { background: none; }
.guild-icon.home .brand-mark { width: 48px; height: 48px; border-radius: inherit; transition: border-radius .15s, filter .15s; filter: saturate(.75); }
.guild-icon.home:hover .brand-mark, .guild-icon.home.active .brand-mark { filter: none; }
.guild-icon.add { color: var(--ok); font-size: 24px; font-weight: 400; }
.guild-icon.add:hover { background: var(--ok); color: var(--accent-ink); }
.guild-icon::before {
  content: ""; position: absolute; left: -12px; width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--text); transition: height .15s;
}
.guild-icon.unread::before { height: 8px; }
.guild-icon:not(.static):hover::before { height: 20px; }
.guild-icon.active::before { height: 36px; }
.guild-icon > .badge { position: absolute; right: -4px; bottom: -4px; border: 3px solid var(--bg-0); height: 22px; min-width: 22px; border-radius: 11px; }
.guild-icon .ghost-badge {
  position: absolute; right: -3px; top: -3px; font-size: 12px; background: var(--bg-0);
  border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center;
}

#channel-sidebar { background: var(--bg-1); display: flex; flex-direction: column; min-height: 0; }
#guild-header {
  height: 52px; flex: none; padding: 0 8px 0 16px; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--line); font-weight: 700;
}
#guild-header .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-header-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 100%; margin-left: -16px; padding: 0 12px 0 16px;
  border: 0; background: none; font-weight: 700; cursor: pointer; text-align: left;
}
.guild-header-btn:hover { background: var(--bg-3); }
.guild-header-btn .chev { color: var(--text-2); }
#channel-list { flex: 1; padding: 12px 8px; }
.section-label {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.section-label .icon-btn { width: 22px; height: 22px; }
.channel {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 1px 0; border-radius: 6px;
  color: var(--muted); cursor: pointer; user-select: none; position: relative; min-height: 34px;
}
.channel:hover { background: var(--bg-3); color: var(--text-2); }
.channel.active { background: var(--bg-4); color: var(--text); }
.channel.unread { color: var(--text); font-weight: 600; }
.channel.unread::before {
  content: ""; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text);
}
.channel.muted { opacity: .5; }
.channel .hash { color: var(--muted); font-weight: 500; width: 16px; text-align: center; flex: none; font-size: .95em; }
.channel .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .actions { display: none; }
.channel:hover .actions, .channel:focus-within .actions { display: flex; }
.channel:hover .badge { display: none; }
.channel .actions .icon-btn { width: 22px; height: 22px; font-size: 13px; }
.channel.dm { padding: 5px 8px; }
.dm-meta { flex: 1; min-width: 0; display: grid; }
.dm-meta .name, .dm-meta .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-meta .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

#user-panel {
  flex: none; display: flex; align-items: center; gap: 4px; padding: 8px;
  background: var(--panel); border-top: 1px solid var(--line);
}
#user-panel .me {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; text-align: left;
}
#user-panel .me:hover { background: var(--bg-3); }
#user-panel .who { flex: 1; min-width: 0; display: grid; }
#user-panel .who .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#user-panel .who .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #11131c; position: relative; user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.xs { width: 16px; height: 16px; font-size: 9px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.lg { width: 40px; height: 40px; font-size: 16px; }
.avatar.xl { width: 80px; height: 80px; font-size: 32px; }
.avatar.group { background: var(--bg-4); font-size: 15px; }
.avatar.everyone { background: var(--bg-4); color: var(--text); }
.avatar .dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  border: 3px solid var(--bg-1); background: var(--muted); box-sizing: content-box;
}
.avatar.lg .dot { width: 12px; height: 12px; }
.avatar.xl .dot { width: 18px; height: 18px; border-width: 5px; right: 0; bottom: 0; }
.avatar.sm .dot { width: 8px; height: 8px; border-width: 2px; }
.avatar .dot.online { background: var(--ok); }
.avatar .dot.idle { background: var(--idle); -webkit-mask: radial-gradient(circle at 25% 25%, transparent 32%, #000 33%); mask: radial-gradient(circle at 25% 25%, transparent 32%, #000 33%); }
.avatar .dot.dnd { background: var(--dnd); }
.avatar .dot.offline, .avatar .dot.invisible { background: var(--muted); }
.avatar .dot.invisible { box-shadow: inset 0 0 0 3px var(--muted); background: var(--bg-1); }

/* ---------- chat ---------- */
#chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-2); }
#chat-header {
  height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line); font-weight: 700;
}
#chat-header .hash { color: var(--muted); font-size: 20px; font-weight: 500; }
#chat-header .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chat-header .menu-btn { display: none; }
#status-banner { padding: 6px 16px; font-size: 13px; background: rgba(224, 175, 104, .15); color: var(--warn); }
#messages { flex: 1; padding: 16px 0 8px; display: flex; flex-direction: column; }
.history-edge { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 16px 16px; }
.channel-intro { padding: 16px 16px 20px; }
.channel-intro .intro-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--bg-3); display: grid; place-items: center;
  font-size: 36px; color: var(--text-2); margin-bottom: 8px;
}
.channel-intro .avatar { margin-bottom: 8px; }
.channel-intro h2 { margin: 0 0 4px; font-size: 26px; }
.channel-intro p { margin: 0; color: var(--text-2); }

.msg { position: relative; }
.msg-group {
  display: grid; grid-template-columns: 40px 1fr; column-gap: 14px; padding: 4px 48px 2px 16px; margin-top: 12px;
}
.msg-group:hover, .msg-line:hover { background: rgba(127, 127, 127, .05); }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 3px 0 0 var(--mention-bar); }
.msg.mentioned:hover { background: var(--mention-bg); }
.msg.editing { background: rgba(127, 127, 127, .06); }
.msg.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { background: var(--pill-bg); } }
.msg-group .avatar-btn { grid-row: span 3; align-self: start; margin-top: 2px; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.msg-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-author { border: 0; padding: 0; background: none; font-weight: 600; cursor: pointer; color: var(--text); }
.msg-author:hover { text-decoration: underline; }
.msg-head .tag { margin-left: 0; }
.msg-time { font-size: 12px; color: var(--muted); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.msg-group > .msg-body, .msg-group > .reactions, .msg-group > .edit-box { grid-column: 2; }
.msg-line { padding: 1px 48px 1px 70px; }
.msg-line .msg-time { position: absolute; left: 16px; width: 44px; text-align: right; top: 4px; font-size: 10px; visibility: hidden; }
.msg-line:hover .msg-time { visibility: visible; }
.edited { font-size: 11px; color: var(--muted); }
.reply-preview {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; margin: 0 0 4px 20px; font-size: 13px;
  color: var(--text-2); cursor: pointer; min-width: 0; position: relative;
}
.reply-preview:hover .reply-text { color: var(--text); }
.reply-preview.missing { cursor: default; font-style: italic; color: var(--muted); }
.reply-spine {
  position: absolute; left: -2px; top: 8px; width: 30px; height: 12px; border-left: 2px solid var(--bg-4);
  border-top: 2px solid var(--bg-4); border-top-left-radius: 6px; transform: translateX(-30px);
}
.reply-author { font-weight: 600; flex: none; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg-toolbar {
  position: absolute; right: 16px; top: -14px; display: none; gap: 2px; padding: 2px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 2;
}
.msg:hover > .msg-toolbar, .msg:focus-within > .msg-toolbar { display: flex; }
.msg-toolbar .icon-btn { width: 30px; height: 30px; font-size: 16px; }
.msg-toolbar .quick { font-size: 15px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: var(--bg-3); font-size: 14px; line-height: 1.4;
}
.reaction:hover:not(:disabled) { border-color: var(--muted); }
.reaction.mine { background: var(--pill-bg); border-color: var(--accent); }
.reaction .count { font-size: 12px; font-weight: 600; color: var(--text-2); }
.reaction.mine .count { color: var(--pill-text); }
.reaction.add { color: var(--muted); font-size: 12px; opacity: 0; }
.msg:hover .reaction.add { opacity: 1; }
.reaction:disabled { cursor: default; }

.edit-box { margin: 4px 0; }
.edit-input { width: 100%; resize: none; background: var(--bg-3); border: 0; border-radius: 8px; padding: 9px 12px; max-height: 50vh; }
.edit-hint { margin-top: 4px; }
.edit-hint .btn.link { font-size: 12px; }

/* markdown */
.md-code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
.md-pre {
  font-family: var(--mono); font-size: .86em; background: var(--code-bg); border: 1px solid var(--line);
  padding: 8px 10px; border-radius: 6px; margin: 4px 0; white-space: pre-wrap; overflow-x: auto; max-width: 100%;
}
.md-quote { margin: 2px 0; padding: 0 0 0 12px; border-left: 4px solid var(--bg-4); }
.md-spoiler { background: var(--text-2); color: transparent; border-radius: 4px; cursor: pointer; transition: all .1s; }
.md-spoiler * { visibility: hidden; }
.md-spoiler.shown { background: var(--bg-3); color: inherit; cursor: auto; }
.md-spoiler.shown * { visibility: visible; }
.mention {
  background: var(--pill-bg); color: var(--pill-text); border-radius: 4px; padding: 0 3px; font-weight: 500; cursor: pointer;
}
.mention:hover { background: var(--accent); color: var(--accent-ink); }
.mention.everyone { cursor: default; }

.day-divider, .new-divider {
  display: flex; align-items: center; gap: 10px; margin: 18px 16px 4px;
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.new-divider { margin: 8px 16px 0; color: var(--danger); }
.new-divider::before { content: ""; flex: 1; height: 1px; background: var(--danger); }
.new-divider span { background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }

#composer { flex: none; padding: 0 16px 0; position: relative; }
#composer .box { display: flex; align-items: flex-end; gap: 4px; background: var(--bg-3); border-radius: 10px; padding: 6px 6px 6px 6px; }
#composer .box.with-reply { border-top-left-radius: 0; border-top-right-radius: 0; }
#composer .emoji-btn { height: 34px; width: 34px; font-size: 20px; }
#composer textarea {
  flex: 1; border: 0; background: none; resize: none; padding: 7px 0; max-height: 40vh; line-height: 1.4;
}
#composer textarea:focus { outline: none; }
#composer .send { padding: 8px 14px; }
#composer .count { font-size: 12px; color: var(--muted); padding: 4px 8px 0; text-align: right; }
#composer .count.over { color: var(--danger); }
#composer .readonly { padding: 12px 14px; border-radius: 10px; background: var(--bg-1); color: var(--muted); font-size: 14px; }
.reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; background: var(--bg-1);
  border-radius: 10px 10px 0 0; font-size: 13px; color: var(--text-2);
}
.reply-bar > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .ping { font-weight: 700; color: var(--muted); }
.reply-bar .ping.on { color: var(--accent-text); }
.reply-bar .icon-btn { width: 22px; height: 22px; font-size: 12px; }
.autocomplete {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% + 6px); background: var(--bg-1);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; z-index: 5;
}
.ac-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 2px 8px 6px; letter-spacing: .04em; }
.ac-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.ac-item.active, .ac-item:hover { background: var(--bg-3); }
.ac-name { font-weight: 600; }
.ac-sub { color: var(--muted); font-size: 12px; margin-left: auto; }

#typing { flex: none; height: 24px; padding: 2px 20px; font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; overflow: hidden; }
#typing strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); animation: bounce 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

.empty-state { margin: auto; text-align: center; color: var(--text-2); padding: 24px; max-width: 380px; }
.empty-state h2 { color: var(--text); margin: 0 0 8px; }
.empty-state p { margin: 0 0 16px; }

/* compact mode */
.compact .msg-group { grid-template-columns: auto 1fr; padding-top: 1px; margin-top: 2px; column-gap: 8px; }
.compact .msg-group .avatar-btn { display: none; }
.compact .msg-group .msg-head { display: inline-flex; grid-column: 1; grid-row: 2; align-self: start; flex-direction: row-reverse; }
.compact .msg-group > .msg-body, .compact .msg-group > .edit-box { grid-row: 2; }
.compact .msg-group > .reply-preview { grid-row: 1; }
.compact .msg-group > .reactions { grid-row: 3; }
.compact .msg-group .reply-preview { margin-left: 0; }
.compact .reply-spine { display: none; }
.compact .msg-line { padding-left: 16px; }
.compact .msg-line .msg-time { position: static; visibility: visible; display: inline-block; width: auto; margin-right: 8px; }
.compact .msg-line .msg-body { display: inline; }

/* ---------- members ---------- */
#member-list { background: var(--bg-1); padding: 16px 8px; }
.member {
  display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; width: 100%;
  border: 0; background: none; cursor: pointer; text-align: left;
}
.member:hover { background: var(--bg-3); }
.member.offline { opacity: .45; }
.member-meta { flex: 1; min-width: 0; display: grid; }
.member .name, .member .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .name { font-weight: 500; }
.member .sub { font-size: 12px; color: var(--muted); }
.crown { color: var(--warn); font-size: 13px; }

/* ---------- modal & toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center;
  padding: 16px; z-index: 70; animation: fade .12s ease-out;
}
.modal {
  width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 22px;
  box-shadow: var(--shadow); animation: pop .14s ease-out;
}
.modal.wide { max-width: 560px; }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .sub { margin: 0 0 16px; color: var(--text-2); font-size: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.code-display {
  font: 600 20px var(--mono); letter-spacing: .12em; background: var(--bg-0); padding: 10px 14px;
  border-radius: 6px; flex: 1; text-align: center; user-select: all; overflow-wrap: anywhere;
}
.public-guild { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: var(--bg-1); }
.public-guild .meta { flex: 1; min-width: 0; display: grid; }
.public-guild .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.public-guild .sub { font-size: 12px; color: var(--muted); }
.public-list { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }
.check-list { display: grid; gap: 8px; padding: 10px; background: var(--bg-1); border-radius: 8px; }
.check-list p { margin: 0; }

.user-picker { display: grid; gap: 8px; }
.pick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-chips:empty { display: none; }
.pick-results { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; min-height: 40px; }
.pick-results p { margin: 8px 0; }
.pick-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; text-align: left; width: 100%;
}
.pick-row:hover { background: var(--bg-3); }
.pick-row.on { background: var(--pill-bg); }
.pick-row .meta { flex: 1; display: grid; }
.pick-row .sub { font-size: 12px; color: var(--muted); }
.pick-row .tick { color: var(--accent-text); font-weight: 700; }

#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 90; }
.toast {
  background: var(--bg-4); color: var(--text); padding: 10px 16px; border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow); animation: pop .14s ease-out; max-width: calc(100vw - 32px);
}
.toast.error { background: #4a2330; color: #ffc2cf; }

/* ---------- popovers, menus, emoji picker, profile ---------- */
.popover {
  position: fixed; z-index: 80; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); animation: pop .1s ease-out; max-height: calc(100vh - 16px); overflow-y: auto;
}
.menu { display: grid; padding: 6px; min-width: 220px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; border-radius: 5px;
  background: none; cursor: pointer; text-align: left; font-size: 14px; color: var(--text-2);
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-icon { width: 18px; text-align: center; flex: none; }
.menu-label { flex: 1; }
.menu-check { font-size: 11px; }
.menu-hint { font-size: 11px; opacity: .7; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-heading { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 10px 2px; }

.emoji-pop { width: 340px; }
.emoji-picker { display: grid; grid-template-rows: auto 1fr; height: 360px; }
.emoji-search { margin: 8px; width: calc(100% - 16px); }
.emoji-grid { overflow-y: auto; padding: 0 8px 8px; display: grid; grid-template-columns: repeat(8, 1fr); align-content: start; }
.emoji-group { grid-column: 1 / -1; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 8px 2px 4px; letter-spacing: .04em; }
.emoji-cell { border: 0; background: none; font-size: 22px; padding: 4px 0; border-radius: 6px; cursor: pointer; line-height: 1.2; }
.emoji-cell:hover { background: var(--bg-3); }
.emoji-empty { grid-column: 1 / -1; }

.profile-pop { width: 300px; overflow: hidden; }
/* overflow keeps the card's bottom margin inside, so a themed gradient (below)
   reaches the bottom edge instead of stopping short. */
.profile, .profile-preview { position: relative; background: var(--bg-1); overflow: hidden; }
.profile-preview { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); max-width: 300px; }
.profile-banner { height: 60px; }
.profile-avatar { position: absolute; top: 18px; left: 14px; padding: 5px; background: var(--bg-1); border-radius: 50%; }
.profile-card { margin: 50px 12px 12px; padding: 12px; background: var(--bg-2); border-radius: 8px; display: grid; gap: 4px; }
.profile-name { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.profile-username { color: var(--text-2); font-size: 14px; }
.profile-status { font-size: 14px; }
.profile-section { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.profile-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-bottom: 4px; }
.profile-section p { margin: 0; font-size: 14px; }
.profile-bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-actions { display: flex; gap: 8px; margin-top: 12px; }
.profile-actions .btn { flex: 1; }
.timeout-note { margin: 8px 0 0; font-size: 13px; color: var(--warn); }
.role-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px; background: var(--bg-3);
  font-size: 12px; font-weight: 500; border: 0;
}
.role-chip.add { cursor: pointer; color: var(--text-2); font-weight: 700; }
.role-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.role-x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.role-x:hover { color: var(--danger); }

/* ---------- full-screen settings ---------- */
.fullscreen { position: fixed; inset: 0; z-index: 60; display: flex; background: var(--bg-2); animation: fade .12s ease-out; }
.fs-side { flex: 1 0 218px; background: var(--bg-1); display: flex; justify-content: flex-end; overflow-y: auto; }
.fs-nav { width: 218px; padding: 60px 8px 24px 20px; display: grid; align-content: start; gap: 2px; }
.fs-heading { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 10px 4px; }
.fs-tab {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; text-align: left; font-size: 15px; font-weight: 500; color: var(--text-2);
}
.fs-tab:hover { background: var(--bg-3); color: var(--text); }
.fs-tab[aria-current="page"] { background: var(--bg-4); color: var(--text); }
.fs-tab.danger { color: var(--danger); }
.fs-sep { height: 1px; background: var(--line); margin: 8px 10px; }
.fs-main { flex: 1 1 800px; display: flex; position: relative; min-width: 0; }
.fs-body { flex: 1; overflow-y: auto; padding: 60px 40px 80px; }
.fs-content { max-width: 740px; }
.fs-title { margin: 0 0 20px; font-size: 20px; }
.fs-section h3 { margin: 28px 0 12px; font-size: 16px; }
.fs-section > p { margin: 0 0 14px; }
.fs-close {
  position: absolute; top: 60px; right: 40px; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--muted); background: none; color: var(--text-2); cursor: pointer; font-size: 14px;
}
.fs-close:hover { background: var(--bg-3); color: var(--text); }
.list { display: grid; gap: 2px; margin-bottom: 16px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 8px; background: var(--bg-1); }
.list-row .meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list-row .name { font-weight: 600; overflow-wrap: anywhere; }
.list-row .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.list-row .row { flex-wrap: wrap; justify-content: flex-end; }
.list-icon { font-size: 22px; }
.account-card { background: var(--bg-1); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.account-card .profile-banner { height: 80px; }
.account-row { display: flex; align-items: flex-end; gap: 16px; padding: 0 16px; margin-top: -30px; }
.account-row .avatar { border: 6px solid var(--bg-1); box-sizing: content-box; }
.account-row .meta { flex: 1; padding-bottom: 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 16px; padding: 16px; background: var(--bg-2); border-radius: 8px; }
.facts dt { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.avatar-edit { display: flex; align-items: center; gap: 16px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-card {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 8px; background: var(--bg-1);
  border: 1px solid var(--line); cursor: pointer; font-weight: 500; color: var(--text);
}
.radio-card input { width: auto; accent-color: var(--accent); }
.roles-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.role-list { display: grid; gap: 2px; position: sticky; top: 0; }
.role-list .btn { margin-bottom: 8px; }
.role-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; min-height: 34px; }
.role-item:hover { background: var(--bg-3); }
.role-item.active { background: var(--bg-4); }
.role-item.locked { opacity: .6; }
.role-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-item .icon-btn { width: 22px; height: 22px; font-size: 12px; }
.perm-list { display: grid; }
.perm-heading { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 16px 0 6px; }
.perm-row {
  display: flex; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line);
  font-weight: 400; color: var(--text); cursor: pointer;
}
.perm-row .meta { flex: 1; display: grid; gap: 2px; }
.perm-row .name { font-weight: 600; font-size: 15px; }
.perm-row .sub { font-size: 13px; color: var(--muted); }
.switch {
  appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--bg-4); border: 0; padding: 0;
  position: relative; cursor: pointer; flex: none; transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(16px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.tri-group { display: inline-flex; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); flex: none; }
.tri { border: 0; background: var(--bg-1); width: 34px; height: 30px; cursor: pointer; color: var(--muted); font-weight: 700; }
.tri + .tri { border-left: 1px solid var(--line); }
.tri.deny.on { background: var(--danger); color: #fff; }
.tri.inherit.on { background: var(--bg-4); color: var(--text); }
.tri.allow.on { background: var(--ok); color: #fff; }
.tri:disabled { opacity: .35; cursor: not-allowed; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: var(--bg-2); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } }
/* ================= v3 ================= */

/* connect: https:// prefix + quick-fill chips */
.url-field {
  display: flex; align-items: stretch; background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden;
}
.url-field:focus-within { border-color: var(--accent); }
.url-prefix {
  display: flex; align-items: center; padding: 0 2px 0 11px; color: var(--muted); font-family: var(--mono);
  font-size: 14px; user-select: none; background: var(--bg-0);
}
.url-field input { border: 0; border-radius: 0; padding-left: 2px; font-family: var(--mono); font-size: 14px; background: transparent; }
.url-field input:focus { border: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -6px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text-2); border-radius: 999px; padding: 3px 10px;
  font-family: var(--mono); font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.warning-body p { margin: 0; line-height: 1.5; }
.warning-body strong { color: var(--warn); }

/* documents (ToS / Privacy) */
.legal-doc {
  max-height: min(52vh, 520px); overflow-y: auto; padding: 4px 16px 12px; margin: 12px 0 16px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
}
.legal-modal .legal-doc { max-height: 60vh; margin-bottom: 0; }
.legal-links { margin: 12px 0 0; text-align: center; }
.doc { font-size: 14px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.doc .doc-h { margin: 18px 0 6px; line-height: 1.25; }
.doc h2.doc-h { font-size: 20px; }
.doc h3.doc-h { font-size: 17px; }
.doc h4.doc-h, .doc h5.doc-h, .doc h6.doc-h { font-size: 15px; }
.doc p { margin: 8px 0; white-space: pre-wrap; }
.doc ul, .doc ol { margin: 8px 0; padding-left: 22px; }
.doc li { margin: 3px 0; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.legal-edit { font-size: 13px; line-height: 1.5; min-height: 220px; }
.legal-preview { max-height: none; margin: 0; }
.legal-section { margin-top: 18px; max-width: 760px; }
.legal-section h3 { margin: 0; }

/* attachments */
.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; max-width: 100%; }
.attachments.gallery { flex-direction: row; flex-wrap: wrap; }
.att-image {
  display: block; border: 0; padding: 0; background: var(--bg-3); border-radius: 8px; overflow: hidden; cursor: zoom-in;
  max-width: min(400px, 100%); max-height: 300px;
}
.att-image img { display: block; max-width: 100%; max-height: 300px; width: 100%; height: 100%; object-fit: contain; }
.gallery .att-image { width: 180px; height: 140px; max-height: none; }
.gallery .att-image img { object-fit: cover; max-height: none; }
.att-video { max-width: min(400px, 100%); border-radius: 8px; overflow: hidden; background: #000; }
.att-video video { display: block; width: 100%; height: 100%; max-height: 300px; }
.att-audio { display: grid; gap: 6px; width: min(400px, 100%); }
.att-audio audio { width: 100%; }
.file-card {
  display: flex; align-items: center; gap: 10px; width: min(400px, 100%); padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
}
.file-icon { font-size: 26px; flex: none; }
.file-meta { flex: 1; min-width: 0; display: grid; }
.file-name { color: var(--accent-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.file-size { font-size: 12px; color: var(--muted); }
.file-card a.icon-btn { text-decoration: none; }
.lightbox-modal { max-width: min(96vw, 1200px) !important; width: auto; background: transparent; box-shadow: none; padding: 0; border: 0; }
.lightbox-modal h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lightbox { position: relative; display: grid; justify-items: center; gap: 8px; }
.lightbox-img { max-width: min(92vw, 1200px); max-height: 80vh; border-radius: 6px; background: var(--bg-3); }
.lightbox-caption { display: flex; gap: 16px; align-items: center; color: #eee; font-size: 13px; }
.lb-prev, .lb-next { position: absolute; top: 45%; background: rgba(0,0,0,.5); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 26px; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.text-modal { max-width: min(900px, 96vw) !important; }
.text-viewer {
  margin: 0; max-height: 65vh; overflow: auto; background: var(--code-bg); border-radius: 6px; padding: 10px 0;
  font: 12.5px/1.5 var(--mono); white-space: pre; counter-reset: line;
}
.tv-line { display: block; padding-right: 12px; }
.tv-no { display: inline-block; width: 44px; padding-right: 10px; text-align: right; color: var(--muted); user-select: none; }

/* composer: uploads, slowmode, drop zone */
#composer .attach-btn { height: 40px; width: 36px; font-size: 20px; align-self: flex-end; }
.upload-tray {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px; background: var(--bg-3);
  border-radius: 8px 8px 0 0; border-bottom: 1px solid var(--line);
}
.upload {
  position: relative; flex: none; width: 150px; display: grid; gap: 4px; padding: 8px; border-radius: 8px;
  background: var(--bg-1); font-size: 12px;
}
.upload.failed { outline: 1px solid var(--danger); }
.up-thumb { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; background: var(--bg-2); }
.up-thumb.icon { display: grid; place-items: center; font-size: 32px; }
.up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-size { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload.failed .up-size { color: var(--danger); }
.up-bar { height: 3px; border-radius: 2px; background: var(--bg-3); overflow: hidden; }
.up-bar > i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.up-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; background: var(--bg-0); font-size: 11px; }
#composer .slowmode { font-size: 12px; color: var(--text-2); text-align: right; margin-top: 2px; }
.drop-overlay {
  position: absolute; inset: 8px; z-index: 25; display: grid; place-items: center; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--bg-2) 85%, transparent);
}
.drop-overlay > div { display: grid; gap: 4px; text-align: center; font-size: 18px; }
#chat { position: relative; }

/* sidebar: categories, voice, drag and drop */
.category {
  display: flex; align-items: center; gap: 4px; padding: 14px 4px 4px 2px; cursor: pointer; user-select: none;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.category:hover { color: var(--text-2); }
.cat-chev { width: 12px; font-size: 10px; transition: transform .12s; }
.category.collapsed .cat-chev { transform: rotate(-90deg); }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category .cat-add { width: 20px; height: 20px; font-size: 16px; }
.channel.nested { margin-left: 8px; }
.channel.voice.locked { opacity: .55; cursor: not-allowed; }
.voice-users { display: grid; gap: 1px; margin: 0 0 4px 32px; }
.voice-user {
  display: flex; align-items: center; gap: 8px; padding: 3px 6px; border: 0; border-radius: 6px; background: none;
  color: var(--text-2); font-size: 13px; cursor: pointer; text-align: left;
}
.voice-user:hover { background: var(--bg-3); color: var(--text); }
.voice-user .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vflag { font-size: 12px; color: var(--danger); }
.add-channel { display: block; margin: 12px 8px 4px; font-size: 13px; }
.dragging { opacity: .4; }
.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.drop-into { background: var(--pill-bg) !important; }
.guild-icon img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.guild-icon.static img { border-radius: inherit; }
.guild-icon.lg { width: 80px; height: 80px; border-radius: 24px; font-size: 26px; }
.guild-icon.xs { width: 20px; height: 20px; border-radius: 6px; font-size: 8px; }
#user-panel { flex-wrap: wrap; }
.voice-panel { width: 100%; padding: 6px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; gap: 4px; }
.vp-top { display: flex; align-items: center; gap: 6px; }
.vp-meta { flex: 1; min-width: 0; display: grid; }
.vp-status { color: var(--ok); font-weight: 700; font-size: 13px; }
.vp-where { font-size: 12px; color: var(--text-2) !important; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-leave { color: var(--danger); font-size: 18px; }
.vp-note { font-size: 11px; }
.vp-buttons { display: flex; gap: 6px; }
.vp-buttons .btn { flex: 1; }
.small-btn { padding: 4px 8px; font-size: 12px; }
.btn.on { background: var(--danger-bg); color: var(--danger-text); }
.icon-btn.on { color: var(--accent-text); }

/* chat header additions */
#chat-header .topic {
  flex: 1; min-width: 0; margin-left: 8px; padding: 0 0 0 12px; border: 0; border-left: 1px solid var(--line);
  background: none; color: var(--text-2); font-size: 13px; text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#chat-header .topic:hover { color: var(--text); }
.slow-tag { font-size: 14px; }
.search-btn {
  display: flex; align-items: center; gap: 24px; justify-content: space-between; height: 26px; padding: 0 8px;
  border: 0; border-radius: 4px; background: var(--bg-0); color: var(--muted); font-size: 13px; cursor: text; flex: none;
}
.search-btn:hover { color: var(--text-2); }
.topic-full { font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* system messages, pins, staff tags */
.msg-system {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 4px 48px 4px 28px; margin-top: 2px;
  color: var(--text-2); font-size: 14px;
}
.msg-system:hover { background: var(--bg-1); }
.msg-system .msg-time { font-size: 11px; }
.msg-system .reactions { width: 100%; margin-left: 32px; }
.sys-icon { width: 24px; text-align: center; font-weight: 700; flex: none; }
.sys-icon.join { color: var(--ok); }
.sys-icon.leave { color: var(--danger); }
.sys-text { flex: 1 1 200px; min-width: 0; }
.sys-name { border: 0; background: none; padding: 0; font-weight: 600; color: var(--text); cursor: pointer; }
.sys-name:hover { text-decoration: underline; }
.sys-text .btn.link { font-weight: 600; }
.msg.pinned > .msg-body::after { content: " 📌"; font-size: 11px; opacity: .7; }
.tag.staff.owner { background: rgba(224, 175, 104, .2); color: var(--warn); }
.tag.staff.admin { background: var(--danger-bg); color: var(--danger); }
.tag.staff.moderator { background: rgba(158, 206, 106, .15); color: var(--ok); }
.jump-present {
  position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 5; display: flex; justify-content: space-between;
  align-items: center; padding: 8px 14px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; cursor: pointer; box-shadow: var(--shadow);
}

/* pins + search */
.pins-pop { width: min(440px, calc(100vw - 16px)); padding: 0; }
.pins-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pins-list { max-height: min(60vh, 520px); overflow-y: auto; padding: 8px; display: grid; gap: 6px; }
.pin { display: flex; gap: 10px; padding: 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.pin-main, .hit-body { flex: 1; min-width: 0; }
.pin-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.pin-body { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: hidden; }
.pin-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.empty-pins { text-align: center; padding: 24px 12px; }
.empty-pins .big { font-size: 40px; }
.empty-pins p { margin: 6px 0; }
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(440px, 100vw);
  display: flex; flex-direction: column; background: var(--bg-1); border-left: 1px solid var(--line); box-shadow: var(--shadow);
}
.side-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); height: 52px; }
.side-head input { flex: 1; }
.search-hint { margin: 8px 14px 0; }
.search-hint code { font-size: 11px; background: var(--bg-3); padding: 1px 4px; border-radius: 3px; }
.search-results { flex: 1; padding: 8px 12px; display: grid; align-content: start; gap: 6px; }
.search-panel > .btn { margin: 0 12px 12px; width: auto; }
.search-count { padding: 2px 2px 4px; }
.search-hit { padding: 8px 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); cursor: pointer; }
.search-hit:hover, .search-hit:focus { border-color: var(--accent); outline: none; }
.hit-main { display: flex; gap: 10px; }
.hit-channel { margin-bottom: 4px; }

/* quick switcher */
.modal.switcher { max-width: 560px; width: min(560px, calc(100vw - 32px)); }
.modal.switcher h2 { font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.modal.switcher input { font-size: 18px; padding: 12px 14px; margin-top: 6px; }
.switcher-list { margin-top: 10px; display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; }
.sw-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.sw-item.active { background: var(--bg-4); }
.sw-hash { width: 20px; text-align: center; color: var(--muted); font-weight: 600; }
.sw-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-sub { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sw-tip { margin: 10px 0 0; }

/* invites */
.invite-link input { font-family: var(--mono); font-size: 13px; }
.invite-opts > label { flex: 1; min-width: 160px; }
.invite-modal { max-width: 400px; }
.invite-card { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 8px 0 0; }
.invite-name { font-size: 22px; font-weight: 800; }
.invite-counts { display: flex; gap: 16px; color: var(--text-2); font-size: 14px; }
.invite-counts .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.invite-counts .dot.online { background: var(--ok); }
.invite-counts .dot.offline { background: var(--muted); }
.vanity { margin: 12px 0 20px; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { padding: 14px; border-radius: 10px; background: var(--bg-1); border: 1px solid var(--line); }
.stat-n { font-size: 24px; font-weight: 800; }
.stat-l { color: var(--muted); font-size: 13px; }

/* role editor: unsaved-changes bar */
.unsaved-bar {
  position: sticky; bottom: 12px; display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px;
  border-radius: 8px; background: var(--bg-0); box-shadow: var(--shadow); animation: fade .12s ease-out;
}
.unsaved-bar > span { flex: 1; font-weight: 600; }
.sync-box {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 12px; border-radius: 8px;
  background: var(--bg-1); border: 1px solid var(--line); font-size: 14px;
}
.sync-box > span { flex: 1; }
.sync-box.synced { border-color: var(--accent); }
.kind-row { display: grid; gap: 6px; }
.radio-card.kind { display: flex; align-items: center; gap: 12px; }
.radio-card.kind.disabled { opacity: .5; }
.kind-icon { width: 28px; font-size: 20px; text-align: center; color: var(--text-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  #app, #app.members-hidden { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr); }
  #member-list {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(280px, 85vw); z-index: 40;
    transform: translateX(100%); transition: transform .18s;
  }
  #app.members-hidden #member-list { display: block; }
  #app.members-open #member-list { transform: none; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  #app, #app.members-hidden, #app.no-members { grid-template-columns: minmax(0, 1fr); }
  #guild-rail, #channel-sidebar {
    position: fixed; top: 0; bottom: 0; z-index: 40; transition: transform .18s;
  }
  #guild-rail { left: 0; width: var(--rail-w); transform: translateX(-100%); }
  #channel-sidebar { left: var(--rail-w); width: min(var(--side-w), calc(100vw - var(--rail-w) - 16px)); transform: translateX(calc(-100% - var(--rail-w))); }
  #app.nav-open #guild-rail, #app.nav-open #channel-sidebar { transform: none; }
  #chat-header .menu-btn { display: inline-grid; }
  #chat-header { padding-left: 8px; }
  .msg-group, .msg-line { padding-right: 12px; }
  .msg-toolbar { right: 8px; }
  #composer { padding: 0 12px; }
  .channel .actions { display: flex; }
  .channel .badge { display: inline-grid !important; }
  .fullscreen { flex-direction: column; }
  .fs-side { flex: none; justify-content: stretch; border-bottom: 1px solid var(--line); }
  .fs-nav { width: 100%; padding: 12px 56px 12px 12px; display: flex; overflow-x: auto; gap: 4px; }
  .fs-heading, .fs-sep { display: none; }
  .fs-tab { flex: none; font-size: 14px; }
  .fs-main { flex: 1; min-height: 0; position: static; }
  .fs-body { padding: 20px 16px 60px; }
  .fs-close { top: 10px; right: 12px; }
  .roles-layout { grid-template-columns: 1fr; }
  .role-list { position: static; }
  .list-row { flex-wrap: wrap; }
  .emoji-pop { width: calc(100vw - 16px); }
  .search-btn span:first-child, .hide-narrow { display: none; }
  .search-btn { gap: 0; background: none; }
  #chat-header .topic { display: none; }
  .msg-system { padding-left: 12px; padding-right: 12px; }
  .jump-present { bottom: 88px; left: 8px; right: 8px; }
  .gallery .att-image { width: calc(50vw - 40px); height: 120px; }
}
#drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
.dm-profile { margin: -16px -8px; border-radius: 0; }
.dm-profile .profile-banner { height: 90px; }
.dm-profile .profile-avatar { top: 48px; }
.row > input[type="color"] { flex: none; }

/* ---------- v4: custom emoji, stickers, role styles, profile themes ---------- */
.emoji-picker { grid-template-rows: auto 1fr auto; height: 400px; }
.emoji-body { display: flex; min-height: 0; }
.emoji-tabs { display: flex; flex-direction: column; gap: 2px; padding: 0 4px 8px 8px; overflow-y: auto; flex: none; border-right: 1px solid var(--line); }
.emoji-tab {
  width: 32px; height: 32px; flex: none; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 18px;
  display: grid; place-items: center; padding: 0; color: var(--text-2); opacity: .75;
}
.emoji-tab:hover { background: var(--bg-3); opacity: 1; }
.emoji-tab img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.emoji-tab .tab-initials { font-size: 10px; font-weight: 700; }
.emoji-body .emoji-grid { flex: 1; padding-left: 6px; }
.emoji-preview { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); min-height: 40px; background: var(--bg-0); }
.emoji-preview .emoji.big, .emoji-preview .cemoji.big { font-size: 24px; width: 26px; height: 26px; }
.emoji-cell.custom { display: grid; place-items: center; }
.cemoji { width: 1.375em; height: 1.375em; object-fit: contain; vertical-align: -.3em; display: inline-block; }
.cemoji[role="button"] { cursor: pointer; }
.emoji-cell .cemoji { width: 28px; height: 28px; }
.cemoji.big { width: 32px; height: 32px; }
.cemoji.huge { width: 64px; height: 64px; }
.msg-body.jumbo .cemoji { width: 3rem; height: 3rem; vertical-align: -.8rem; }
.msg-body.jumbo { font-size: 2.6rem; line-height: 1.2; }
.msg-body.jumbo .edited { font-size: 12px; }
.reaction .cemoji { width: 18px; height: 18px; vertical-align: middle; }
.reaction .emoji { font-size: 16px; }
.ac-emoji { font-size: 20px; width: 22px; height: 22px; text-align: center; }
.emoji-info { display: flex; gap: 12px; align-items: center; padding: 12px; max-width: 300px; }
.emoji-info p { margin: 4px 0 0; }

.msg-stickers { display: flex; gap: 8px; margin-top: 4px; }
.sticker { width: 160px; height: 160px; object-fit: contain; }
.sticker-gone {
  width: 160px; height: 80px; display: grid; place-items: center; align-content: center; gap: 4px; border-radius: 8px;
  border: 1px dashed var(--line); color: var(--muted); font-size: 13px;
}
.sticker-picker { width: 100%; }
.sticker-grid { overflow-y: auto; padding: 0 8px 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-content: start; }
.sticker-cell { border: 0; background: none; border-radius: 8px; padding: 6px; cursor: pointer; aspect-ratio: 1; }
.sticker-cell:hover { background: var(--bg-3); }
.sticker-thumb { width: 100%; height: 100%; object-fit: contain; }
#composer .sticker-btn { height: 34px; width: 34px; font-size: 18px; }

.expr-row .input.emoji-name { width: 180px; padding: 4px 8px; }
.expr-row .grow { flex: 1; text-align: right; }
.empty-note { text-align: center; padding: 32px; background: var(--bg-1); border-radius: 10px; }
.big-emoji { font-size: 40px; }
.sticker-form { display: flex; gap: 16px; align-items: stretch; margin: 16px 0 24px; padding: 16px; background: var(--bg-1); border-radius: 10px; }
.sticker-form .stack { flex: 1; }
.sticker-drop {
  width: 120px; height: 120px; flex: none; border: 2px dashed var(--line); border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); cursor: pointer; font-size: 13px; overflow: hidden;
}
.sticker-drop:hover { border-color: var(--accent); color: var(--text); }
.sticker-drop img { width: 100%; height: 100%; object-fit: contain; }
.sticker-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.sticker-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; background: var(--bg-1); }
.sticker-card .sticker-thumb { width: 64px; height: 64px; }
.sticker-meta { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.sticker-actions { display: flex; flex-direction: column; }

/* Gradient role names (background-clip text) and role icons. */
.grad-name {
  background-image: var(--grad); background-size: 200% auto; -webkit-background-clip: text; background-clip: text;
  color: transparent !important; -webkit-text-fill-color: transparent;
  animation: grad-slide 6s linear infinite;
}
@keyframes grad-slide { to { background-position: 200% center; } }
@media (prefers-reduced-motion: reduce) { .grad-name { animation: none; } }
.role-icon { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; margin-left: 4px; flex: none; }
.role-icon.emoji { font-size: 15px; width: auto; height: auto; line-height: 1; }
.role-chip .role-icon { margin: 0; width: 14px; height: 14px; }
.member .name-line { display: flex; align-items: center; min-width: 0; }
.member .name-line .name { min-width: 0; }
.msg-head .role-icon { margin: 0 2px 0 -2px; }
canvas.still { display: block; }
.avatar canvas.still { width: 100%; height: 100%; object-fit: cover; }

/* Profile banners and profile colours. */
.profile-banner.has-image { height: 105px; overflow: hidden; }
.profile-banner.has-image img, .profile-banner.has-image canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-banner.has-image ~ .profile-avatar { top: 62px; }
.profile-banner.has-image ~ .profile-card { margin-top: 50px; }
.profile.themed, .profile-preview.themed { background: linear-gradient(180deg, var(--p1), var(--p2)); }
.themed .profile-banner:not(.has-image) { background: none; }
.themed .profile-avatar { background: color-mix(in srgb, var(--p1) 70%, var(--p2)); }
.themed .profile-card { background: color-mix(in srgb, var(--bg-2) 72%, transparent); backdrop-filter: blur(6px); }

/* Custom gradient theme (themes.js): the gradient shows through translucent panels. */
:root.grad-theme #app, :root.grad-theme .screen { background: var(--grad) fixed; }
:root.grad-theme #guild-rail { background: color-mix(in srgb, var(--bg-0) calc(var(--glass) + 12%), transparent); }
:root.grad-theme #channel-sidebar, :root.grad-theme #member-list { background: color-mix(in srgb, var(--bg-1) calc(var(--glass) + 6%), transparent); }
:root.grad-theme #chat { background: color-mix(in srgb, var(--bg-2) var(--glass), transparent); }
:root.grad-theme #user-panel { background: color-mix(in srgb, var(--panel) calc(var(--glass) + 12%), transparent); }
:root.grad-theme #composer .box { background: color-mix(in srgb, var(--bg-3) calc(var(--glass) + 20%), transparent); }

.theme-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.theme-card {
  display: grid; gap: 6px; padding: 6px; border-radius: 10px; border: 2px solid transparent; background: var(--bg-1);
  cursor: pointer; text-align: left; font-size: 13px; font-weight: 600; color: var(--text-2);
}
.theme-card:hover { color: var(--text); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }
.theme-card:disabled { opacity: .5; cursor: not-allowed; }
.theme-swatch { height: 52px; border-radius: 6px; border: 1px solid var(--line); }
.theme-editor { display: grid; gap: 14px; margin-top: 16px; padding: 16px; background: var(--bg-1); border-radius: 10px; }
.theme-preview { height: 72px; border-radius: 8px; border: 1px solid var(--line); }
.theme-stops { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.theme-stop { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 8px; background: var(--bg-2); }
.theme-stop input[type="color"] { width: 38px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }

/* Crop before upload (cropper.js). */
.cropper { display: grid; gap: 12px; justify-items: center; }
.cropper-stage { background: var(--bg-0); border-radius: 8px; padding: 10px; }
.cropper-canvas { display: block; max-width: 100%; border-radius: 6px; touch-action: none; cursor: grab; background: var(--bg-0); }
.cropper-canvas:active { cursor: grabbing; }
.cropper-zoom { width: 100%; accent-color: var(--accent); }
.locked-note { padding: 10px 12px; border-radius: 8px; background: var(--bg-1); color: var(--text-2); font-size: 13px; }
.tag.perks { background: rgba(187, 154, 247, .18); color: #bb9af7; }

/* Guild banner behind the channel-list header (Discord style). */
#guild-header { position: relative; }
#guild-header.with-banner { height: 136px; align-items: flex-start; border-bottom: 0; padding-top: 0; }
#guild-header.with-banner .guild-header-btn { height: 52px; position: relative; z-index: 1; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
#guild-header.with-banner .guild-header-btn .chev { color: #fff; }
#guild-header.with-banner .guild-header-btn:hover { background: rgba(0, 0, 0, .25); }
.guild-banner { position: absolute; inset: 0; overflow: hidden; }
.guild-banner img, .guild-banner canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.guild-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .55), transparent 45%, transparent 70%, var(--bg-1)); }
.guild-banner-preview { width: 100%; max-width: 420px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.guild-banner-preview img, .guild-banner-preview canvas { width: 100%; height: 100%; object-fit: cover; }
.invite-banner { height: 96px; margin: -20px -20px 12px; overflow: hidden; border-radius: 10px 10px 0 0; }
.invite-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grad-sample { font-weight: 700; margin-left: 8px; }
.role-icon-preview { min-width: 28px; display: inline-flex; align-items: center; }
.role-icon-preview .role-icon { width: 24px; height: 24px; margin: 0; }
.guild-icon canvas.still { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* --- Friends page, message requests, inbox (ui/friends.js) --- */
.home-link { gap: 10px; }
.home-link .home-glyph { width: 32px; text-align: center; font-size: 18px; }
#chat-header .friends-title { flex: none; }
#chat-header .friends-tabs {
  display: flex; gap: 4px; flex: 1; min-width: 0; margin-left: 8px; overflow-x: auto; scrollbar-width: none;
}
#chat-header .friends-tabs::-webkit-scrollbar { display: none; }
.friends-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text-2); cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.friends-tab:hover { background: var(--bg-3); color: var(--text); }
.friends-tab.active { background: var(--bg-4); color: var(--text); }
.friends-tab.add { background: var(--accent); color: var(--accent-ink); }
.friends-tab.add.active { background: none; color: var(--accent-text); }
.friends-tab .badge { position: static; }
.friends-page { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px 32px; max-width: 900px; width: 100%; }
.friends-page .section-label { padding: 12px 8px 6px; }
.friends-h2 { margin: 4px 0; font-size: 18px; }
.friend-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 8px;
  border-top: 1px solid var(--line);
}
.friend-row.clickable { cursor: pointer; }
.friend-row:hover { background: var(--bg-3); border-top-color: transparent; }
.friend-row:hover + .friend-row { border-top-color: transparent; }
.friend-meta { flex: 1; min-width: 0; display: grid; }
.friend-meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-meta .handle { margin-left: 6px; font-weight: 400; color: var(--muted); font-size: 13px; }
.friend-meta .sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-actions { display: flex; gap: 6px; align-items: center; }
.friend-actions .icon-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-1); }
.friend-actions .icon-btn.ok:hover { color: var(--ok); }
.friends-empty { margin: 48px auto; text-align: center; max-width: 360px; }
.add-friend { display: flex; gap: 8px; padding: 6px; border-radius: 10px; background: var(--bg-0); border: 1px solid var(--line); margin-top: 8px; }
.add-friend:focus-within { border-color: var(--accent-text); }
.add-friend .input { flex: 1; border: 0; background: none; }
.add-friend-tip { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.ok-text { color: var(--ok); }
.error-text { color: var(--danger); }
.request-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px;
  background: var(--bg-1); border: 1px solid var(--line);
}
.msg-blocked { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; padding-top: 4px; padding-bottom: 4px; }
.announce-compose { display: grid; gap: 8px; padding: 12px; margin-bottom: 12px; border-radius: 10px; background: var(--bg-1); }
.announce-compose .section-label { padding: 0; }
.announcement {
  display: flex; gap: 12px; padding: 14px; border-radius: 10px; background: var(--bg-1); margin-bottom: 10px;
  border-left: 3px solid transparent;
}
.announcement.new { border-left-color: var(--accent); }
.announcement-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.announcement-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.announcement-head .tag.new { background: var(--accent); color: var(--accent-ink); }
.announcement-content { overflow-wrap: anywhere; }
.announcement .btn { justify-self: start; }
.avatar.system { display: grid; place-items: center; background: var(--pill-bg); font-size: 20px; }
@media (max-width: 1100px) { #chat-header .friends-title { display: none; } }
@media (max-width: 700px) {
  .friends-page { padding: 12px; }
}

/* --- Account switcher (ui/accounts.js) --- */
.accounts-pop { width: 300px; max-height: min(520px, 80vh); overflow-y: auto; padding: 8px; }
.account-switcher .switcher-title { font-weight: 700; padding: 4px 8px 8px; }
.account-server + .account-server { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.account-server .section-label { padding: 6px 8px 4px; }
.account-server .section-label .tag { margin-left: 6px; }
.account-row-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.account-row-item:hover { background: var(--bg-3); }
.account-row-item.current { cursor: default; background: var(--pill-bg); }
.account-row-item .meta { flex: 1; min-width: 0; display: grid; }
.account-row-item .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row-item .sub { font-size: 12px; color: var(--muted); }
.account-row-item .tick { color: var(--accent-text); font-weight: 700; }
.account-row-item .icon-btn { width: 26px; height: 26px; }
.add-account { padding: 6px 8px; font-size: 14px; }
.pad-x { padding: 0 8px; }
.account-footer { border-top: 1px solid var(--line); margin-top: 8px; padding: 10px 8px 4px; }

