:root {
  --bg-rail: #17181c;
  --bg-sidebar: #1f2026;
  --bg-main: #26272e;
  --bg-input: #31323a;
  --bg-hover: #2e2f37;
  --bg-active: #393a44;
  --bg-float: #121316;
  --border: #33343c;
  --text: #e4e5ea;
  --text-muted: #9a9ca7;
  --text-faint: #6c6e79;
  --accent: #7c5cff;
  --accent-hover: #6a4cf0;
  --accent-soft: rgba(124, 92, 255, 0.16);
  --danger: #ef5b5b;
  --success: #2fbf71;
  --idle: #f0a020;
  --dnd: #ef5b5b;
  --offline: #80848e;
  --mention: rgba(240, 160, 32, 0.08);
  --mention-bar: #f0a020;
  --radius: 8px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: var(--bg-main);
  color: var(--text);
  font: 15px/1.4 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea, select { font: inherit; color: inherit; }
a { color: #6cb6ff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3b44; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
.hidden, [hidden] { display: none !important; }
svg.icon { width: 20px; height: 20px; flex: none; fill: currentColor; }

/* ---------- Auth ---------- */
.auth {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, .35), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(59, 167, 255, .3), transparent 60%),
    var(--bg-rail);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-sidebar);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.auth-card .brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 8px; }
.auth-card .brand img { width: 40px; height: 40px; }
.auth-card .brand span { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 12px 0 4px; }
.auth-card p.sub { text-align: center; color: var(--text-muted); margin: 0 0 20px; }
.auth-switch { margin-top: 14px; font-size: 14px; color: var(--text-muted); }
.auth-switch button { color: #6cb6ff; padding: 0; }
.auth-switch button:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  background: var(--bg-float);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 70px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: 6px;
  padding: 10px 16px;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.secondary { background: #4a4c57; }
.btn.secondary:hover { background: #575965; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #d94a4a; }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { text-decoration: underline; background: transparent; }
.form-error { color: var(--danger); font-size: 14px; min-height: 18px; margin: -4px 0 10px; }

/* ---------- App layout ---------- */
.shell {
  height: 100%;
  display: grid;
  grid-template-columns: 72px 240px 1fr auto;
}
.rail {
  background: var(--bg-rail);
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-sep { width: 32px; height: 2px; background: var(--border); border-radius: 1px; margin: 2px 0; flex: none; }
.rail-item { position: relative; flex: none; }
.rail-item::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 4px;
  height: 0;
  border-radius: 0 4px 4px 0;
  background: #fff;
  transform: translateY(-50%);
  transition: height .15s;
}
.rail-item.unread::before { height: 8px; }
.rail-item:hover::before { height: 20px; }
.rail-item.active::before { height: 40px; }
.rail-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-main);
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  overflow: hidden;
  transition: border-radius .15s, background .15s, color .15s;
}
.rail-btn img { width: 100%; height: 100%; object-fit: cover; }
.rail-btn .avatar { width: 100%; height: 100%; font-size: 18px; }
.rail-item:hover .rail-btn, .rail-item.active .rail-btn { border-radius: 16px; }
.rail-btn.home img { width: 30px; height: 30px; object-fit: contain; }
.rail-item.active .rail-btn.home, .rail-item:hover .rail-btn.home { background: var(--accent); }
.rail-btn.add { color: var(--success); }
.rail-item:hover .rail-btn.add { background: var(--success); color: #fff; }
.rail-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  border: 3px solid var(--bg-rail);
  box-sizing: content-box;
}

/* Sidebar */
.sidebar { background: var(--bg-sidebar); display: flex; flex-direction: column; min-width: 0; }
.sidebar-head {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(0, 0, 0, .3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02);
  gap: 8px;
}
.sidebar-head.clickable { cursor: pointer; }
.sidebar-head.clickable:hover { background: var(--bg-hover); }
.sidebar-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-list { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
}
.group-label button { color: var(--text-muted); padding: 0; display: flex; }
.group-label button:hover { color: var(--text); }
.chan {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-faint);
  text-align: left;
  margin: 1px 0;
  position: relative;
}
.chan:hover { background: var(--bg-hover); color: var(--text-muted); }
.chan.active { background: var(--bg-active); color: var(--text); }
.chan.unread { color: var(--text); font-weight: 600; }
.chan.unread::before {
  content: "";
  position: absolute;
  left: -8px;
  width: 4px;
  height: 8px;
  border-radius: 0 4px 4px 0;
  background: #fff;
}
.chan .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan .hash { font-size: 20px; line-height: 1; width: 20px; text-align: center; color: var(--text-faint); }
.chan .tools { display: none; color: var(--text-muted); }
.chan:hover .tools, .chan.active .tools { display: flex; }
.chan .tools:hover { color: var(--text); }
.chan .avatar { width: 32px; height: 32px; font-size: 14px; }
.chan.dm { padding: 6px 8px; }
.empty-hint { color: var(--text-faint); font-size: 13px; padding: 8px; }

/* User panel */
.user-panel {
  flex: none;
  height: 56px;
  background: #1a1b20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}
.user-panel .who {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.user-panel .who:hover { background: var(--bg-hover); }
.user-panel .names { min-width: 0; line-height: 1.2; }
.user-panel .names b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel .names small { color: var(--text-muted); font-size: 12px; }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  position: relative;
  flex: none;
  font-size: 16px;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.xs { width: 16px; height: 16px; font-size: 9px; }
.avatar.xl { width: 80px; height: 80px; font-size: 32px; }
.presence-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--bg-sidebar);
  background: var(--offline);
}
.avatar.xl .presence-dot { width: 24px; height: 24px; border-width: 5px; right: 0; bottom: 0; }
.presence-dot.online { background: var(--success); }
.presence-dot.idle { background: var(--idle); }
.presence-dot.dnd { background: var(--dnd); }
.presence-dot.offline, .presence-dot.invisible { background: var(--offline); }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); }
.main-head {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid rgba(0, 0, 0, .3);
  min-width: 0;
}
.main-head .title { font-weight: 700; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.main-head .title .hash { color: var(--text-faint); font-size: 22px; font-weight: 400; }
.main-head .topic {
  color: var(--text-muted);
  font-size: 14px;
  border-left: 1px solid var(--border);
  padding-left: 12px;
  margin-left: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.main-head .spacer { flex: 1; }
.main-head .icon-btn.on { color: var(--text); }
.menu-toggle { display: none; }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 0 16px; position: relative; }
.welcome { padding: 32px 16px 16px; }
.welcome .big-hash {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--bg-active);
  display: grid;
  place-items: center;
  font-size: 40px;
  margin-bottom: 8px;
}
.welcome h2 { margin: 8px 0 4px; font-size: 28px; }
.welcome p { color: var(--text-muted); margin: 0; }
.loading-more { text-align: center; color: var(--text-faint); padding: 12px; font-size: 13px; }

.day-divider {
  display: flex;
  align-items: center;
  margin: 20px 16px 4px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
}
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.day-divider span { padding: 0 8px; }

.msg {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  column-gap: 16px;
  padding: 2px 48px 2px 16px;
  margin-top: 16px;
}
.msg.cont { margin-top: 0; }
.msg:hover { background: rgba(0, 0, 0, .1); }
.msg.mentioned { background: var(--mention); box-shadow: inset 2px 0 0 var(--mention-bar); }
.msg.highlight { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.msg .avatar { cursor: pointer; margin-top: 2px; }
.msg .gutter-time {
  font-size: 11px;
  color: var(--text-faint);
  text-align: right;
  visibility: hidden;
  line-height: 22px;
}
.msg.cont:hover .gutter-time { visibility: visible; }
.msg .head { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 600; cursor: pointer; }
.msg .author:hover { text-decoration: underline; }
.msg .time { font-size: 12px; color: var(--text-faint); }
.msg .owner-crown { font-size: 13px; }
.msg .content { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; min-width: 0; }
.msg .content .edited { font-size: 11px; color: var(--text-faint); margin-left: 4px; }
.msg .content code {
  font-family: var(--mono);
  background: var(--bg-float);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 13px;
}
.msg .content pre {
  font-family: var(--mono);
  background: var(--bg-float);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 6px;
  margin: 4px 0;
  white-space: pre-wrap;
  font-size: 13px;
}
.msg .content pre code { background: none; padding: 0; }
.msg .content blockquote { margin: 2px 0; padding-left: 10px; border-left: 4px solid #4e505b; }
.msg .content .spoiler { background: #111; color: transparent; border-radius: 3px; cursor: pointer; }
.msg .content .spoiler.shown { background: var(--bg-active); color: inherit; }
.mention {
  background: var(--accent-soft);
  color: #b9a8ff;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 500;
}
.msg.system .content { color: var(--text-muted); }
.reply-ref {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 20px;
  position: relative;
  cursor: pointer;
  min-width: 0;
  margin-bottom: 2px;
}
.reply-ref::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 9px;
  width: 30px;
  height: 10px;
  border-left: 2px solid #4e505b;
  border-top: 2px solid #4e505b;
  border-top-left-radius: 6px;
}
.reply-ref .avatar { margin-left: 36px; }
.reply-ref b { color: var(--text); font-weight: 600; white-space: nowrap; }
.reply-ref .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-ref:hover .preview { color: var(--text); }

.attachment { margin-top: 6px; }
.attachment img {
  max-width: min(400px, 100%);
  max-height: 320px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
}
.attachment .file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 100%;
  text-decoration: none;
}
.attachment .file small { color: var(--text-faint); display: block; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--bg-sidebar);
  border: 1px solid transparent;
  font-size: 14px;
}
.reaction:hover { border-color: #4e505b; }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction .count { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.reaction.mine .count { color: #c7b9ff; }

.msg-actions {
  position: absolute;
  right: 16px;
  top: -16px;
  display: none;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
  z-index: 2;
}
.msg:hover .msg-actions { display: flex; }
.msg-actions button { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-muted); }
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }
.msg-actions button.danger:hover { color: var(--danger); }
.edit-box textarea {
  width: 100%;
  background: var(--bg-input);
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  margin-top: 4px;
}
.edit-box small { color: var(--text-muted); font-size: 12px; }
.edit-box small button { color: #6cb6ff; padding: 0; }

/* Composer */
.composer-wrap { padding: 0 16px 0; flex: none; }
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-sidebar);
  border-radius: 8px 8px 0 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.composer-bar b { color: var(--text); }
.composer-bar .file-chip { display: flex; align-items: center; gap: 8px; min-width: 0; }
.composer-bar .file-chip img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.composer {
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 0 8px;
}
.composer-bar + .composer { border-radius: 0 0 8px 8px; }
.composer textarea {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
  padding: 12px 4px;
  max-height: 40vh;
  line-height: 1.375;
}
.composer .icon-btn { margin: 6px 0; }
.typing { height: 24px; font-size: 13px; color: var(--text-muted); padding: 2px 16px 0; display: flex; align-items: center; gap: 6px; }
.typing b { color: var(--text); }
.typing .dots { display: inline-flex; gap: 3px; }
.typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); 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: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* Member list */
.members { width: 240px; background: var(--bg-sidebar); overflow-y: auto; padding: 8px; }
.members.collapsed { display: none; }
.members.hidden-panel { display: none !important; }
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}
.member:hover { background: var(--bg-hover); }
.member.offline { opacity: .45; }
.member.offline:hover { opacity: 1; }
.member .label { min-width: 0; flex: 1; }
.member .label b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .label small { color: var(--text-faint); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Home */
.home-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
}
.home-empty img { width: 96px; opacity: .9; }
.home-empty h2 { color: var(--text); margin: 16px 0 6px; }

/* Overlays */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#layer > * { pointer-events: auto; }
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--bg-main);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  animation: pop .15s ease-out;
}
.modal.wide { max-width: 640px; }
.modal-body { padding: 24px; }
.modal h2 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.modal p.sub { color: var(--text-muted); text-align: center; margin: 0 0 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  background: var(--bg-sidebar);
  border-radius: 0 0 12px 12px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  text-align: left;
  font-weight: 600;
}
.choice:hover { background: var(--bg-hover); }
.choice .emoji { font-size: 28px; }
.choice .chev { margin-left: auto; color: var(--text-muted); }
.icon-picker {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px dashed var(--text-faint);
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  overflow: hidden;
}
.icon-picker img { width: 100%; height: 100%; object-fit: cover; }
.invite-box { display: flex; gap: 8px; }
.invite-box .input { flex: 1; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; }
.color-swatch.sel { border-color: #fff; }
.status-select { display: grid; gap: 4px; }
.status-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; text-align: left; }
.status-opt:hover { background: var(--bg-hover); }
.status-opt.sel { background: var(--bg-active); }
.status-opt .presence-dot { position: static; border: 0; width: 10px; height: 10px; }
.settings-section { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 16px; }
.settings-section h3 { font-size: 13px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 12px; letter-spacing: .03em; }
.list-rows .row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-rows .row:last-child { border-bottom: 0; }
.list-rows .row .grow { flex: 1; min-width: 0; }

/* Popovers & menus */
.popover {
  position: fixed;
  background: var(--bg-float);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: pop .1s ease-out;
  z-index: 60;
}
.menu { padding: 6px; min-width: 200px; }
.menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger); color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
.emoji-picker { padding: 8px; display: grid; grid-template-columns: repeat(8, 36px); gap: 2px; }
.emoji-picker button { width: 36px; height: 36px; font-size: 22px; border-radius: 6px; }
.emoji-picker button:hover { background: var(--bg-active); }
.profile-card { width: 300px; overflow: hidden; }
.profile-card .banner { height: 60px; }
.profile-card .body { padding: 0 16px 16px; }
.profile-card .avatar { margin-top: -40px; border: 6px solid var(--bg-float); box-sizing: content-box; }
.profile-card .avatar .presence-dot { border-color: var(--bg-float); }
.profile-card h3 { margin: 8px 0 0; font-size: 20px; }
.profile-card .uname { color: var(--text-muted); font-size: 14px; }
.profile-card .bio { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; white-space: pre-wrap; }
.profile-card .bio h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.profile-card .btn { margin-top: 14px; width: 100%; }

.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; }
.toast {
  background: var(--bg-float);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: pop .15s ease-out;
  font-size: 14px;
}
.toast.error { border-left: 4px solid var(--danger); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
.conn-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--idle);
  color: #000;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 14px;
  border-radius: 0 0 8px 8px;
  z-index: 90;
}

/* Responsive */
@media (max-width: 1100px) {
  .shell > .members { display: none; }
  .shell.members-overlay > .members {
    display: block !important;
    position: fixed;
    right: 0;
    top: 48px;
    bottom: 0;
    z-index: 20;
    box-shadow: -8px 0 24px rgba(0, 0, 0, .4);
  }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .shell > .rail, .shell > .sidebar { display: none; }
  .shell.nav-open > .rail, .shell.nav-open > .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 30;
  }
  .shell.nav-open > .rail { left: 0; width: 72px; }
  .shell.nav-open > .sidebar { left: 72px; width: min(260px, calc(100vw - 72px)); box-shadow: 8px 0 24px rgba(0, 0, 0, .4); }
  .menu-toggle { display: grid; }
  .msg { padding-right: 16px; }
  .msg-actions { top: -30px; }
}

/* ---------- Voice ---------- */
.chan.voice .hash { display: grid; place-items: center; }
.chan.voice.connected { color: var(--text); }
.chan.voice.connected .hash { color: var(--success); }
.voice-users { padding: 0 0 4px 28px; }
.voice-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}
.voice-user:hover { background: var(--bg-hover); color: var(--text); }
.voice-user .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-user .vs-icon { color: var(--text-faint); display: flex; }
.avatar.vs { width: 24px; height: 24px; font-size: 11px; transition: box-shadow .1s; }
.voice-user.speaking .avatar { box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--success); }
.voice-user.speaking .label { color: var(--text); }
.voice-panel {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: #1a1b20;
  border-bottom: 1px solid var(--border);
}
.voice-panel .info { flex: 1; min-width: 0; cursor: pointer; line-height: 1.3; }
.voice-panel .info b { display: flex; align-items: center; gap: 4px; color: var(--success); font-size: 14px; }
.voice-panel .info small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-panel .info:hover small { text-decoration: underline; }
.voice-panel .icon-btn:hover { color: var(--danger); }
.icon-btn.off { color: var(--danger); }
.user-panel { gap: 2px; }
label.choice { cursor: pointer; flex-wrap: wrap; font-weight: 600; }
label.choice input { accent-color: var(--accent); margin: 0; }
label.choice .emoji { width: 28px; text-align: center; font-size: 22px; color: var(--text-muted); }
label.choice small { flex-basis: 100%; padding-left: 52px; color: var(--text-muted); font-weight: 400; font-size: 13px; margin-top: -4px; }
label.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
