/* ============================================================ Lounge theme */
:root {
  --rail:        #1e1f22;
  --sidebar:     #2b2d31;
  --chat:        #313338;
  --panel:       #232428;
  --elevated:    #111214;
  --floating:    #111214;
  --hover:       rgba(78,80,88,.3);
  --active:      rgba(78,80,88,.6);
  --divider:     rgba(255,255,255,.06);
  --text:        #dbdee1;
  --text-strong: #f2f3f5;
  --muted:       #949ba4;
  --faint:       #80848e;
  --link:        #00a8fc;
  --blurple:     #5865f2;
  --blurple-h:   #4752c4;
  --green:       #23a559;
  --yellow:      #f0b132;
  --red:         #f23f43;
  --radius:      8px;
  --font: "gg sans", "Helvetica Neue", Helvetica, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--chat);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #141517; }
::selection { background: rgba(88,101,242,.5); }
.hidden { display: none !important; }

/* ============================================================== auth screen */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% 10%, #5865f2 0%, transparent 55%),
    radial-gradient(900px 500px at 85% 85%, #7b3fe4 0%, transparent 60%),
    #1e1f22;
  overflow: auto;
}
.auth-card {
  width: min(460px, 100%);
  background: #313338;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
  padding: 32px;
  color: var(--text);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-logo {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  background: var(--blurple); color: #fff;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 800;
}
.auth-brand h1 { margin: 0; font-size: 24px; color: #fff; letter-spacing: -.02em; }
.auth-brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; padding: 9px 10px; border-radius: 6px; font-size: 14px; font-weight: 600;
  color: var(--muted); background: rgba(255,255,255,.04); transition: .12s;
}
.auth-tab:hover { color: var(--text); background: rgba(255,255,255,.08); }
.auth-tab.active { color: #fff; background: var(--blurple); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 4px; font-size: 15px;
  background: #1e1f22; border: 1px solid rgba(255,255,255,.06); color: var(--text); outline: none;
}
.field input:focus { border-color: var(--blurple); }
.auth-hint { margin: -6px 0 14px; font-size: 12.5px; color: var(--muted); }
.auth-error { background: rgba(242,63,67,.12); border: 1px solid rgba(242,63,67,.4); color: #ffb4b6; padding: 9px 11px; border-radius: 4px; font-size: 13.5px; margin-bottom: 12px; }
.btn { border-radius: 4px; font-size: 14.5px; font-weight: 600; padding: 11px 16px; transition: .12s; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blurple); color: #fff; }
.btn-primary:hover { background: var(--blurple-h); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: rgba(255,255,255,.07); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-link { background: none; color: var(--link); padding: 4px 6px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--faint); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
.auth-fineprint { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: var(--faint); }
.auth-foot { color: rgba(255,255,255,.55); font-size: 12.5px; }

/* ================================================================== layout */
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- server rail ---------- */
.rail {
  width: 72px; flex: none; background: var(--rail);
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 12px 0; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { width: 0; }
.rail-item { position: relative; width: 48px; height: 48px; flex: none; }
.rail-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sidebar); color: var(--text-strong);
  font-size: 15px; font-weight: 600; letter-spacing: -.02em;
  transition: border-radius .15s, background .15s, color .15s;
  overflow: hidden; text-align: center; line-height: 1.1;
}
.rail-btn:hover { border-radius: 16px; background: var(--blurple); color: #fff; }
.rail-btn.active { border-radius: 16px; background: var(--blurple); color: #fff; }
.rail-btn.home { background: var(--blurple); color: #fff; }
.rail-btn.home:hover { filter: brightness(1.1); }
.rail-btn svg { width: 26px; height: 26px; }
.rail-btn.plain { background: var(--sidebar); color: var(--green); font-size: 22px; font-weight: 400; }
.rail-btn.plain:hover { background: var(--green); color: #fff; }
.rail-pill {
  position: absolute; left: -16px; top: 50%; width: 8px; height: 0;
  background: #fff; border-radius: 0 4px 4px 0; transform: translateY(-50%);
  transition: height .18s;
}
.rail-item.unread .rail-pill { height: 20px; }
.rail-item.active .rail-pill { height: 40px; }
.rail-sep { width: 32px; height: 2px; background: var(--divider); flex: none; border-radius: 2px; }
.rail-badge {
  position: absolute; bottom: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 3px solid var(--rail);
}

/* ---------- sidebar ---------- */
.sidebar {
  width: 240px; flex: none; background: var(--sidebar);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-header {
  height: 48px; flex: none; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text-strong);
  box-shadow: 0 1px 0 rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.1);
  text-align: left;
}
.sidebar-header:hover { background: var(--hover); }
.sidebar-header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-header .chev { flex: none; opacity: .8; }
.sidebar-body { flex: 1; overflow-y: auto; padding: 8px 8px 20px; min-height: 0; }

.cat {
  display: flex; align-items: center; gap: 2px; width: 100%;
  padding: 16px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted);
}
.cat:hover { color: var(--text); }
.cat .cat-add { margin-left: auto; opacity: 0; font-size: 16px; font-weight: 500; }
.cat:hover .cat-add { opacity: 1; }
.cat-chevron { width: 12px; height: 12px; transition: transform .15s; }
.cat.collapsed .cat-chevron { transform: rotate(-90deg); }

.chan {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 6px 8px; margin-bottom: 2px; border-radius: 4px;
  color: var(--muted); font-size: 15px; font-weight: 500; text-align: left;
}
.chan:hover { background: var(--hover); color: var(--text); }
.chan.active { background: var(--active); color: #fff; }
.chan .hash { font-size: 19px; font-weight: 400; opacity: .75; line-height: 1; }
.chan .chan-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chan.unread { color: var(--text-strong); font-weight: 600; }
.chan.unread::before {
  content: ""; position: absolute; left: -8px; width: 8px; height: 8px;
  background: #fff; border-radius: 0 4px 4px 0;
}
.chan { position: relative; }
.chan .badge {
  min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.chan .chan-x { opacity: 0; color: var(--muted); font-size: 15px; line-height: 1; }
.chan:hover .chan-x { opacity: 1; }
.chan .chan-x:hover { color: var(--red); }

.dm-search { padding: 0 8px 8px; }
.dm-search input {
  width: 100%; padding: 6px 8px; border-radius: 4px; font-size: 13.5px;
  background: #1e1f22; border: 0; color: var(--text); outline: none;
}
.side-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 4px; color: var(--muted); font-size: 15px; font-weight: 600; text-align: left;
}
.side-link:hover { background: var(--hover); color: var(--text); }
.side-link.active { background: var(--active); color: #fff; }
.side-link svg { width: 22px; height: 22px; flex: none; }
.dm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 4px; text-align: left; }
.dm-item:hover { background: var(--hover); }
.dm-item.active { background: var(--active); }
.dm-name { color: var(--muted); font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dm-item.active .dm-name, .dm-item:hover .dm-name { color: var(--text-strong); }
.dm-item.unread .dm-name { color: #fff; font-weight: 600; }
.dm-item .dm-x { opacity: 0; color: var(--muted); }
.dm-item:hover .dm-x { opacity: 1; }
.dm-item .dm-x:hover { color: var(--red); }
.empty-note { padding: 10px 8px; font-size: 13px; color: var(--faint); line-height: 1.5; }

/* ---------- user panel ---------- */
.user-panel {
  height: 52px; flex: none; background: var(--panel);
  display: flex; align-items: center; padding: 0 8px; gap: 4px;
}
.user-panel-btn { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px; border-radius: 4px; }
.user-panel-btn:hover { background: var(--hover); }
.user-panel-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.user-panel-text strong { font-size: 13.5px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel-text small { font-size: 11.5px; color: var(--muted); }
.icon-btn { width: 32px; height: 32px; border-radius: 4px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text-strong); }

/* ---------- chat ---------- */
.chat { flex: 1; min-width: 0; background: var(--chat); display: flex; flex-direction: column; }
.chat-header {
  height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.1);
}
.chat-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: var(--text-strong); min-width: 0; }
.chat-title .hash { font-size: 22px; color: var(--faint); font-weight: 400; }
.chat-topic {
  color: var(--muted); font-size: 13.5px; padding-left: 12px; margin-left: 4px;
  border-left: 1px solid var(--divider); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%;
}
.chat-header-spacer { flex: 1; }
.chat-body { flex: 1; display: flex; min-height: 0; }
.messages-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 8px; min-width: 0; }
.messages { display: flex; flex-direction: column; justify-content: flex-end; min-height: 100%; padding: 16px 0 8px; }

.welcome { padding: 0 16px 24px; }
.welcome-icon {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.06); font-size: 30px; font-weight: 700; color: var(--text-strong); margin-bottom: 8px;
}
.welcome h2 { margin: 8px 0 8px; font-size: 30px; color: var(--text-strong); }
.welcome p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }

.divider { display: flex; align-items: center; margin: 18px 16px 8px; color: var(--faint); font-size: 11.5px; font-weight: 700; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
.divider span { padding: 0 8px; }

.msg { position: relative; display: flex; gap: 16px; padding: 2px 48px 2px 16px; }
.msg:hover { background: rgba(2,2,2,.06); }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.msg .avatar { margin-top: 2px; flex: none; }
.msg-content { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-author { font-size: 15px; font-weight: 600; color: var(--text-strong); }
.msg-author:hover { text-decoration: underline; cursor: pointer; }
.msg-time { font-size: 11.5px; color: var(--faint); }
.msg-text { font-size: 15px; line-height: 1.375; color: var(--text); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-text .edited { font-size: 10px; color: var(--faint); margin-left: 3px; }
.msg-text .mention { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; cursor: pointer; }
.msg-text code { background: #2b2d31; padding: 1.6px 3px; border-radius: 3px; font-family: Consolas, "Andale Mono WT", monospace; font-size: 85%; }
.msg-text pre { background: #2b2d31; border: 1px solid #1e1f22; border-radius: 4px; padding: 8px; margin: 6px 0; overflow-x: auto; }
.msg-text pre code { background: none; padding: 0; }
.msg-text a { color: var(--link); }
.msg-text a:hover { text-decoration: underline; }
.msg-text .blockquote { border-left: 4px solid #4e5058; padding-left: 8px; color: var(--muted); }
.msg-system { padding: 4px 16px; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 14px; }
.msg-system svg { width: 18px; height: 18px; flex: none; color: var(--green); }
.msg-system .msg-text { color: var(--muted); }
.msg.action .msg-text { color: var(--text); font-style: italic; }
.msg.action .msg-author { display: none; }

.attachments { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 6px; }
.attachment-img { max-width: min(400px, 100%); max-height: 340px; width: auto; height: auto; border-radius: 6px; cursor: pointer; display: block; }
.attachment-video { max-width: min(420px, 100%); max-height: 340px; border-radius: 6px; display: block; background: #000; }
.file-chip {
  display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 10px;
  border: 1px solid var(--divider); border-radius: 4px; background: #2b2d31; text-decoration: none; color: var(--text);
}
.file-chip:hover { border-color: rgba(255,255,255,.15); }
.file-chip .fc-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 4px; background: rgba(255,255,255,.06); }
.file-chip .fc-name { font-size: 14px; color: var(--link); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-size { font-size: 11.5px; color: var(--faint); }

.msg-actions {
  position: absolute; top: -16px; right: 16px; display: none; gap: 2px;
  background: var(--chat); border: 1px solid var(--divider); border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.msg:hover .msg-actions { display: flex; }
.msg-actions button { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); border-radius: 4px; }
.msg-actions button:hover { background: var(--hover); color: var(--text-strong); }
.msg-actions button.danger:hover { color: var(--red); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 8px;
  background: rgba(255,255,255,.04); border: 1px solid transparent; font-size: 13.5px; color: var(--muted);
}
.reaction:hover { border-color: rgba(255,255,255,.2); }
.reaction.mine { background: rgba(88,101,242,.16); border-color: var(--blurple); color: #c9cdfb; }
.reaction .count { font-weight: 600; font-size: 12.5px; }
.reaction.add { padding: 2px 8px; }

.typing-bar { height: 24px; padding: 0 16px; font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.typing-bar .dots { display: inline-flex; gap: 2px; }
.typing-bar .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing-bar .dots i:nth-child(2) { animation-delay: .15s; }
.typing-bar .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ---------- members ---------- */
.members { width: 240px; flex: none; background: var(--sidebar); overflow-y: auto; padding: 8px 8px 20px; }
.members.hidden { display: none; }
.member-group { padding: 16px 8px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }
.member {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border-radius: 4px; text-align: left;
}
.member:hover { background: var(--hover); }
.member-name { font-size: 15px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member:hover .member-name { color: var(--text); }
.member.offline { opacity: .45; }
.admin-tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: rgba(88, 101, 242, .18); color: #8b95f7; border: 1px solid rgba(88, 101, 242, .5);
  padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: middle; white-space: nowrap;
}
.member .admin-tag { margin-left: auto; flex: none; }
.msg-head .admin-tag { transform: translateY(-1px); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex: none; position: relative; background: #5865f2; }
.avatar-sm { width: 32px; height: 32px; font-size: 12.5px; }
.avatar-lg { width: 80px; height: 80px; font-size: 28px; }
.avatar .status-dot {
  position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid var(--sidebar); background: var(--faint);
}
.user-panel .avatar .status-dot { border-color: var(--panel); }
.messages .avatar .status-dot { display: none; }
.status-online { background: var(--green) !important; }
.status-idle { background: var(--yellow) !important; }
.status-dnd { background: var(--red) !important; }
.status-invisible, .status-offline { background: var(--faint) !important; }

/* ---------- composer ---------- */
.composer-area { flex: none; padding: 0 16px 24px; position: relative; }
.composer {
  display: flex; align-items: flex-end; gap: 4px;
  background: #383a40; border-radius: 8px; padding: 0 8px 0 0;
}
.composer.editing { box-shadow: 0 0 0 1px var(--blurple); }
.composer-btn { width: 40px; height: 44px; flex: none; display: grid; place-items: center; color: var(--muted); }
.composer-btn:hover { color: var(--text-strong); }
.composer-btn.send { color: var(--blurple); }
.composer-btn.send:hover { filter: brightness(1.2); }
.composer-input-wrap { flex: 1; min-width: 0; padding: 11px 0; }
.composer-input {
  max-height: 340px; overflow-y: auto; outline: none; font-size: 15px; line-height: 1.375;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.composer-input:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }
.composer-meta { display: flex; gap: 10px; justify-content: space-between; height: 18px; padding: 4px 2px 0; font-size: 12px; color: var(--faint); }
.composer-meta button { color: var(--link); }
.attachment-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; }
.pending-file {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px;
  background: #2b2d31; border: 1px solid var(--divider); font-size: 13px; max-width: 260px;
}
.pending-file .pf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-file button { color: var(--muted); }
.pending-file button:hover { color: var(--red); }
.drop-overlay {
  position: absolute; inset: 0; z-index: 5; display: none;
  background: rgba(17,18,20,.75); border: 2px dashed var(--blurple); border-radius: 8px;
  place-items: center; font-weight: 600; color: var(--text-strong);
}
.composer-area.dragging .drop-overlay { display: grid; }

/* ======================================================== modals & popovers */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.75);
  display: grid; place-items: center; padding: 20px; overflow: auto;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal {
  width: min(520px, 100%); background: #313338; border-radius: 8px; overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.5); animation: pop .16s ease-out;
}
.modal.sm { width: min(400px, 100%); }
.modal-head { padding: 20px 20px 12px; }
.modal-head h2 { margin: 0 0 6px; font-size: 21px; color: var(--text-strong); }
.modal-head p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.modal-body { padding: 0 20px 4px; }
.modal-foot {
  padding: 16px 20px 20px; display: flex; gap: 8px; align-items: center;
  background: #2b2d31; margin-top: 16px;
}
.modal-foot .spacer { flex: 1; }
.modal .field { margin-bottom: 14px; }
.modal .field input, .modal .field textarea, .modal .field select {
  width: 100%; padding: 10px 12px; border-radius: 4px; font-size: 14.5px;
  background: #1e1f22; border: 1px solid rgba(255,255,255,.06); color: var(--text); outline: none;
}
.modal .field input:focus, .modal .field textarea:focus { border-color: var(--blurple); }
.modal .field textarea { resize: vertical; min-height: 70px; }
.modal .field .check { display: flex; align-items: center; gap: 8px; text-transform: none; font-size: 14px; font-weight: 500; color: var(--text); letter-spacing: 0; }
.modal-error { background: rgba(242,63,67,.12); border: 1px solid rgba(242,63,67,.4); color: #ffb4b6; padding: 9px 11px; border-radius: 4px; font-size: 13.5px; margin-bottom: 12px; }
.modal label.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; color: var(--text); font-size: 14.5px; border-bottom: 1px solid var(--divider); }
.modal label.switch:last-of-type { border-bottom: 0; }
.switch input { width: 40px; height: 22px; appearance: none; background: #72767d; border-radius: 11px; position: relative; cursor: pointer; transition: .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(18px); }
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented button { flex: 1; min-width: 84px; padding: 9px 8px; border-radius: 5px; font-size: 13.5px; font-weight: 600; background: rgba(255,255,255,.05); color: var(--muted); }
.segmented button:hover { background: rgba(255,255,255,.1); color: var(--text); }
.segmented button.active { background: var(--blurple); color: #fff; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 10px; }
.preview-grid img, .preview-grid video { width: 100%; height: 72px; object-fit: cover; border-radius: 6px; background: #000; }
.server-row {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 6px;
  background: #2b2d31; margin-bottom: 8px;
}
.server-row .sr-info { flex: 1; min-width: 0; }
.server-row .sr-name { font-size: 15px; font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-row .sr-meta { font-size: 12.5px; color: var(--muted); }
.invite-box { display: flex; align-items: center; gap: 8px; background: #1e1f22; border-radius: 6px; padding: 10px 12px; margin: 10px 0; }
.invite-box code { flex: 1; font-size: 15px; letter-spacing: .04em; color: #fff; overflow: hidden; text-overflow: ellipsis; }

.popover-root { position: fixed; inset: 0; z-index: 300; pointer-events: none; }
.popover { position: absolute; pointer-events: auto; }
.emoji-picker {
  width: 320px; max-height: 380px; background: #2b2d31; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid rgba(0,0,0,.3);
}
.emoji-search { padding: 8px; border-bottom: 1px solid var(--divider); }
.emoji-search input {
  width: 100%; padding: 7px 9px; border-radius: 4px; background: #1e1f22; border: 0; color: var(--text); outline: none; font-size: 13.5px;
}
.emoji-cats { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--divider); }
.emoji-cats button { padding: 4px 6px; border-radius: 4px; font-size: 16px; opacity: .6; }
.emoji-cats button:hover, .emoji-cats button.active { opacity: 1; background: var(--hover); }
.emoji-grid { flex: 1; overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; align-content: start; }
.emoji-grid button { font-size: 21px; padding: 4px 0; border-radius: 4px; line-height: 1.2; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-empty { padding: 20px; text-align: center; color: var(--faint); font-size: 13px; }

.menu {
  min-width: 200px; background: #111214; border-radius: 6px; padding: 6px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.06);
}
.menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 7px 8px; border-radius: 4px; font-size: 14px; color: var(--muted); text-align: left;
}
.menu button:hover { background: var(--blurple); color: #fff; }
.menu button.danger { color: #f23f43; }
.menu button.danger:hover { background: var(--red); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--divider); margin: 5px 0; }

.profile-card { width: 300px; background: #232428; border-radius: 8px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.profile-banner { height: 60px; background: var(--blurple); }
.profile-body { padding: 0 16px 16px; margin-top: -40px; }
.profile-avatar { border: 6px solid #232428; border-radius: 50%; width: 92px; height: 92px; }
.profile-body h3 { margin: 10px 0 2px; font-size: 19px; color: #fff; }
.profile-body .tag { font-size: 12.5px; color: var(--muted); }
.profile-meta { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--divider); font-size: 13px; color: var(--muted); display: grid; gap: 8px; }
.profile-meta strong { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-strong); margin-bottom: 2px; }
.profile-actions { padding: 0 16px 16px; display: grid; gap: 8px; }
.profile-actions .btn { width: 100%; }

/* ============================================================ toasts/banner */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 400; display: grid; gap: 8px; }
.toast {
  background: #111214; color: var(--text); border-radius: 6px; padding: 11px 16px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); border-left: 3px solid var(--blurple); max-width: 90vw;
  animation: pop .16s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.banner-root { position: fixed; top: 0; left: 0; right: 0; z-index: 350; display: grid; justify-items: center; }
.banner {
  margin-top: 8px; background: var(--yellow); color: #1e1f22; font-size: 13.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 0 0 6px 6px; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.9); display: grid; place-items: center; padding: 24px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; border-radius: 4px; }
.lightbox .lb-close { position: absolute; top: 16px; right: 20px; color: #fff; font-size: 30px; line-height: 1; }

/* ============================================================== responsive */
.mobile-only { display: none !important; }
@media (max-width: 900px) {
  .members { display: none; }
}
@media (max-width: 700px) {
  .app-shell { position: relative; }
  .rail { width: 60px; }
  .rail-btn { width: 42px; height: 42px; font-size: 13px; }
  .sidebar {
    position: absolute; inset: 0 auto 0 60px; z-index: 60; width: 250px;
    transform: translateX(-110%); transition: transform .2s ease;
    box-shadow: 0 0 20px rgba(0,0,0,.5);
  }
  .app-shell.nav-open .sidebar { transform: none; }
  .chat { padding-left: 0; }
  .mobile-only { display: grid !important; }
  .members { display: none !important; }
  .chat-topic { display: none; }
  .msg { padding-right: 16px; }
  .msg-actions { right: 4px; }
  .attachment-img, .attachment-video { max-width: 100%; }
}
