/* Chattr — minimal black & white. sharp corners, no decoration. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --fs: 14px;
  --rail-w: 72px;
  --side-w: 260px;
  --member-w: 240px;
  --profile-w: 320px;
  --line-h: 1.55;
  --radius: 8px;
  --focus-ring: #8ac5bf;
}

html[data-theme="dark"] {
  --bg: #232428;
  --panel: #1e1f22;
  --panel-2: #191a1d;
  --panel-3: #2b2d31;
  --line: #2c2e33;
  --line-2: #3b3e45;
  --text: #f2f3f5;
  --text-2: #d7d9dd;
  --muted: #a6a9b2;
  --dim: #83868f;
  --good: #23a55a;
  --bad: #f23f43;
  --own: #26282c;
  --hover: #2e3035;
  --accent: #416b68;
  --overlay: rgba(0, 0, 0, .7);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f6f7f9;
  --panel-2: #eceef2;
  --panel-3: #e3e6ec;
  --line: #e2e4e9;
  --line-2: #cfd3da;
  --text: #101114;
  --text-2: #2c2f36;
  --muted: #5e626b;
  --dim: #787c85;
  --good: #14833b;
  --bad: #c0271f;
  --own: #fbfbfc;
  --hover: #eef0f4;
  --accent: #35635f;
  --overlay: rgba(0, 0, 0, .42);
  --focus-ring: #225e59;
  color-scheme: light;
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--line-h);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--muted); }
img { max-width: 100%; }
::selection { background: var(--text); color: var(--bg); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.is-hidden { display: none !important; }
.dim { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

html[data-ts="off"] .msg-time { display: none; }
html[data-density="compact"] { --line-h: 1.4; }
html[data-density="compact"] .line { padding-top: 0; padding-bottom: 0; }
html[data-density="compact"] .line.group-start { margin-top: 5px; }

/* ------------------------------------------------------------------ logo */

.logo { display: block; width: 100%; height: 100%; color: var(--text); overflow: visible; }
.logo use { color: inherit; }

/* ------------------------------------------------------------------ boot */

.startup-loading { color: var(--muted); font-size: 14px; text-align: center; }

.boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}

.boot-grid {
  width: min(960px, 100%);
  min-height: 540px;
  display: grid;
  grid-template-columns: 1.06fr .94fr;
  border: 1px solid var(--line-2);
  background: var(--panel);
}

.boot-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 54px 48px;
  border-right: 1px solid var(--line);
  background-color: var(--panel-2);
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  overflow: hidden;
}
.boot-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, var(--panel-2) 100%);
  pointer-events: none;
}
.boot-art > * { position: relative; z-index: 1; }

.boot-logo-wrap {
  width: 68px;
  height: 68px;
  margin-bottom: 24px;
  padding: 4px;
  border: 1px solid var(--line-2);
  background: var(--bg);
}
.boot-logo { width: 58px; height: 58px; }
.boot-wordmark {
  font-size: clamp(52px, 7vw, 76px);
  line-height: .9;
  font-weight: 750;
  letter-spacing: -.065em;
  color: var(--text);
}
.boot-tagline {
  margin: 14px 0 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .19em;
  text-transform: uppercase;
  color: var(--muted);
}
.boot-rule { width: 42px; height: 1px; margin: 30px 0 16px; background: var(--line-2); }
.boot-small { margin: 0; font-size: 11.5px; color: var(--dim); }

.boot-card { padding: 38px 36px; display: flex; flex-direction: column; justify-content: center; background: var(--panel); }
.boot-card-head { display: flex; align-items: baseline; justify-content: space-between; }
.boot-card-head h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.boot-mini { font-size: 10px; letter-spacing: .12em; color: var(--dim); }
.boot-sub { margin: 6px 0 20px; font-size: 12.5px; color: var(--muted); }

.auth-tabs { display: flex; border: 1px solid var(--line-2); margin-bottom: 18px; }
.auth-tab {
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-right: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .02em;
}
.auth-tab:last-child { border-right: 0; }
.auth-tab:hover { color: var(--text); background: var(--panel-2); }
.auth-tab.active { background: var(--text); color: var(--bg); }

.field-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 5px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

#auth-form input,
.boot-card input {
  width: 100%;
  margin-bottom: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#auth-form input:focus, .boot-card input:focus { border-color: var(--text); }
#auth-form input::placeholder, .boot-card input::placeholder { color: var(--dim); }

.boot-btn {
  width: 100%;
  margin-top: 2px;
  padding: 10px;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .01em;
}
.boot-btn:hover { opacity: .86; }
.boot-btn:disabled { opacity: .45; cursor: default; }

.auth-error {
  margin: 2px 0 12px;
  padding: 7px 9px;
  border-left: 2px solid var(--bad);
  background: var(--panel-2);
  color: var(--bad);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.boot-note { margin: 15px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.boot-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--dim);
}
.boot-dot { color: var(--line-2); }
.boot-download { display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------------------------- app */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr);
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  background: var(--bg);
}
.app.has-members { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--member-w); }

/* ------------------------------------------------------------------ rail */

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-height: 0;
  padding: 9px 0;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
}

.rail-btn {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  line-height: 1;
  overflow: hidden;
}
.rail-btn:hover { border-color: var(--text); background: var(--panel-3); }
.rail-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.rail-btn img { width: 100%; height: 100%; object-fit: cover; }
.rail-brand { border: 0; background: transparent; padding: 5px; }
.rail-brand:hover { background: transparent; }
.rail-brand .logo { width: 30px; height: 30px; }
.rail-divider { width: 24px; height: 1px; flex: none; background: var(--line-2); margin: 1px 0; }
.rail-scroll { display: flex; flex-direction: column; gap: 7px; align-items: center; width: 100%; overflow-y: auto; overflow-x: hidden; padding: 1px 0; }
.rail-scroll::-webkit-scrollbar { width: 0; }
.rail-actions { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.rail-add, .rail-join { color: var(--muted); font-size: 18px; font-weight: 400; }
.rail-add:hover, .rail-join:hover { color: var(--text); }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%; }
.rail-admin { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.rail-download { color: var(--muted); }
.rail-download:hover { color: var(--text); }
.rail-download .ico { width: 17px; height: 17px; }
.rail-me { width: 42px; height: 42px; padding: 2px; background: var(--panel); }
.rail-me .avatar { width: 34px; height: 34px; font-size: 12px; }
.rail-me-dot { position: absolute; right: 2px; bottom: 2px; width: 7px; height: 7px; background: var(--line-2); border: 1px solid var(--panel-2); }
.app.connected .rail-me-dot { background: var(--good); }

.rail-btn .unread-dot { position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; background: var(--text); }
.rail-btn.active .unread-dot { background: var(--bg); }

/* --------------------------------------------------------------- sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.server-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 55px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}
.server-head-main { min-width: 0; flex: 1; line-height: 1.2; }
.server-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-tag {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini {
  width: 21px;
  height: 21px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}
.mini:hover { color: var(--text); border-color: var(--text); }
.mini:disabled { opacity: .35; cursor: default; }

.side-section { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: 7px; }
.side-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 11px;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.count { font-weight: 400; color: var(--muted); letter-spacing: 0; }

.channel-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; flex: 1; }
.channel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  font-size: 13px;
  color: var(--text-2);
  border-left: 2px solid transparent;
  cursor: pointer;
  user-select: none;
}
.channel:hover { background: var(--hover); color: var(--text); }
.channel.active { background: var(--hover); color: var(--text); border-left-color: var(--text); }
.channel .hash { color: var(--dim); font-size: 12.5px; }
.channel .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .unread {
  margin-left: auto;
  min-width: 15px;
  padding: 0 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}
.channel .del {
  margin-left: auto;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  opacity: 0;
}
.channel:hover .del, .channel .del:focus-visible { opacity: 1; }
.channel .del:hover { color: var(--bad); }

.channel .name { flex: 1; }
.channel-select {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.chan-tools { flex: none; display: flex; align-items: center; gap: 1px; margin-left: 2px; opacity: 0; }
.channel:hover .chan-tools, .chan-tools:focus-within { opacity: 1; }
.chan-tools button {
  width: 16px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}
.chan-tools button:hover { background: var(--panel-3); color: var(--text); }
.chan-tools button:disabled { opacity: .25; cursor: default; }
.channel .chan-tools .del { margin-left: 0; opacity: 1; font-size: 12px; }
.channel .chan-tools .del:hover { background: var(--panel-3); color: var(--bad); }
@media (hover: none) { .chan-tools { opacity: 1; } }

.channel-form {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 6px 7px;
  padding: 4px 6px;
  border: 1px solid var(--line-2);
  background: var(--bg);
}
.channel-form .hash { color: var(--muted); font-size: 12.5px; }
.channel-form input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 1px 0; font-size: 12.5px; }

.side-foot { border-top: 1px solid var(--line); padding: 8px; }
.brand-line {
  margin: 0 0 7px;
  font-size: 8.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-card {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 3px;
  border: 0;
  background: transparent;
  text-align: left;
}
.me-card:hover { background: var(--hover); }
.me-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-host { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-dot { width: 7px; height: 7px; flex: none; margin-left: auto; background: var(--line-2); }
.app.connected .me-dot { background: var(--good); }
.foot-row { display: flex; gap: 5px; margin-top: 6px; }
.foot-btn {
  flex: 1;
  padding: 4px 0;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
}
.foot-btn:hover { color: var(--text); border-color: var(--text); }

/* ---------------------------------------------------------------- avatars */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text-2);
  font-weight: 650;
  line-height: 1;
  text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xs { width: 20px; height: 20px; font-size: 8px; }
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-md { width: 38px; height: 38px; font-size: 13px; }
.avatar-rail { width: 34px; height: 34px; font-size: 12px; }
.avatar-xl { width: 82px; height: 82px; font-size: 28px; }

/* ------------------------------------------------------------------ main */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 55px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.chan-head { display: flex; align-items: baseline; gap: 10px; min-width: 0; overflow: hidden; }
.chan-title { font-size: 14px; font-weight: 700; white-space: nowrap; letter-spacing: -.01em; }
.chan-title .hash { color: var(--muted); margin-right: 2px; font-weight: 400; }
.chan-topic {
  padding-left: 10px;
  border-left: 1px solid var(--line-2);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.conn { display: flex; align-items: center; gap: 6px; margin-right: 4px; font-size: 10.5px; color: var(--muted); }
.conn-dot { width: 6px; height: 6px; background: var(--line-2); }
.conn.live .conn-dot { background: var(--good); }
.conn.down .conn-dot { background: var(--bad); }
.conn.live { color: var(--text-2); }

.icon-btn {
  padding: 3px 8px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
  font-size: 10.5px;
  line-height: 1.7;
  white-space: nowrap;
}
.icon-btn:hover { color: var(--text); border-color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ------------------------------------------------------------------- log */

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
  padding: 12px 0 8px;
}

.log-day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 18px 10px 12px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.log-day::before,
.log-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.log-day:first-child { margin-top: 10px; }

.line {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  column-gap: 9px;
  padding: 1px 18px 1px 12px;
  font-size: var(--fs);
  line-height: var(--line-h);
}
.line:hover { background: var(--hover); }
.line.group-start { margin-top: 11px; }
.line.own { background: var(--own); }
.line.own:hover { background: var(--hover); }

.line-gutter { display: flex; justify-content: center; padding-top: 4px; min-width: 0; }
.line-gutter .avatar { width: 34px; height: 34px; font-size: 12px; }
.line-avatar-btn { padding: 0; border: 0; background: none; }
.line-avatar-btn:hover .avatar { border-color: var(--text); }

.line-time {
  display: none;
  padding-top: 4px;
  color: var(--dim);
  font-size: 9.5px;
  line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.line.grouped .line-time { display: block; visibility: hidden; }
.line.grouped:hover .line-time, .line.grouped:focus-within .line-time { visibility: visible; }
.line.grouped .line-gutter .avatar { display: none; }

.line-body { min-width: 0; overflow-wrap: anywhere; }
.msg-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; min-width: 0; }
.msg-name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: var(--fs);
  font-weight: 700;
  line-height: inherit;
}
.msg-name:hover { text-decoration: underline; text-underline-offset: 2px; }
.msg-role {
  padding: 0 3px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1.5;
}
.msg-time { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg-badges { display: inline-flex; gap: 3px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}
.badge .glyph { font-size: 10px; color: var(--text); letter-spacing: 0; }
.badge.role-owner, .badge.role-admin, .badge.role-moderator { border-color: var(--text); color: var(--text); }
.badge-glyph {
  display: inline-grid;
  place-items: center;
  min-width: 14px;
  height: 14px;
  padding: 0 2px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1;
}

.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text .msg-line { min-height: 1px; }
.msg-text blockquote {
  margin: 3px 0;
  padding: 0 0 0 9px;
  border-left: 2px solid var(--line-2);
  color: var(--text-2);
}
.msg-text .code-block {
  margin: 5px 0;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
}
.msg-text code.inline {
  padding: 0 4px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: .93em;
}
.msg-text .spoiler {
  padding: 0 3px;
  background: var(--text);
  color: transparent;
  cursor: pointer;
  user-select: none;
}
.msg-text .spoiler.revealed { background: var(--panel-2); color: var(--text); user-select: text; }
.msg-text .mention {
  padding: 0 2px;
  background: var(--panel-3);
  border-bottom: 1px solid var(--line-2);
  font-weight: 650;
  cursor: pointer;
}
.msg-text .mention.self { background: var(--text); color: var(--bg); border-bottom-color: var(--text); }
.msg-text a { text-decoration: underline; text-underline-offset: 2px; }

.line.action .msg-text { color: var(--text-2); font-style: italic; }
.line.action .action-star { color: var(--muted); margin-right: 5px; }

.line-actions {
  position: absolute;
  top: 1px;
  right: 10px;
  display: none;
  gap: 3px;
  padding: 2px;
  border: 1px solid var(--line-2);
  background: var(--panel);
}
.line:hover .line-actions, .line:focus-within .line-actions { display: flex; }
@media (hover: none) {
  .line-actions { position: static; display: flex; grid-column: 2; justify-self: start; border: 0; padding: 0; }
  .msg-action { min-height: 32px; }
}
.msg-action {
  padding: 1px 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
}
.msg-action:hover { color: var(--text); background: var(--panel-2); }
.msg-action.danger:hover { color: var(--bad); }

.attachment {
  display: inline-block;
  max-width: min(460px, 100%);
  margin: 5px 0 2px;
  padding: 3px;
  border: 1px solid var(--line-2);
  background: var(--panel);
}
.attachment img {
  display: block;
  max-width: 100%;
  max-height: 340px;
  min-width: 60px;
  object-fit: contain;
  background: var(--panel-2);
  cursor: zoom-in;
}
.attachment-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 3px 1px;
  color: var(--dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.attachment-video {
  display: block;
  width: min(420px, 100%);
  max-height: 340px;
  background: #000;
}
.attachment-foot .gif-tag,
.attachment-foot .video-tag { color: var(--text-2); font-weight: 700; }

.old-more { display: flex; justify-content: center; padding: 4px 0 14px; }
.old-more button {
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--muted);
  font-size: 10.5px;
}
.old-more button:hover { color: var(--text); border-color: var(--text); }

.empty { padding: 26px 16px; max-width: 640px; }
.empty strong { display: block; color: var(--text); font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.empty span { color: var(--muted); font-size: 12.5px; }
.empty .empty-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.empty .empty-actions button { padding: 5px 10px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); font-size: 11.5px; }
.empty .empty-actions button:hover { border-color: var(--text); color: var(--text); }

.typing { height: 0; overflow: hidden; padding: 0 15px; background: var(--bg); color: var(--muted); font-size: 10.5px; }
.typing.show { height: 19px; padding: 1px 15px 0; }

/* -------------------------------------------------------------- composer */

.composer-wrap { border-top: 1px solid var(--line); background: var(--bg); padding: 0 12px 9px; }

.format-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 0 3px;
  opacity: .8;
  transition: opacity .12s linear;
}
.composer-wrap:focus-within .format-bar, .format-bar:hover { opacity: 1; }
.format-bar button {
  width: 23px;
  height: 21px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1;
}
.format-bar button:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.format-bar button > * { pointer-events: none; }
.format-bar button code,
.format-bar button kbd {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
  line-height: 1;
}
.format-bar button strong,
.format-bar button em,
.format-bar button u,
.format-bar button s { font-size: inherit; line-height: 1; }
.format-hint { margin-left: auto; color: var(--muted); font-size: 10px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 4px;
  border: 1px solid var(--line-2);
  background: var(--panel);
}
.attach-preview img, .attach-preview video { width: 52px; height: 42px; object-fit: cover; border: 1px solid var(--line); background: #000; }
.attach-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.attach-info span:first-child { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-status { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.attach-remove { margin-left: auto; padding: 2px 7px; border: 0; background: transparent; color: var(--muted); font-size: 15px; }
.attach-remove:hover { color: var(--bad); }

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 7px 9px 7px 13px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel);
  transition: border-color .12s ease;
}
.composer:focus-within { border-color: var(--focus-ring); }

.composer-plus {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}
.composer .ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.composer-plus .ico { width: 22px; height: 22px; }
.composer-plus:hover { color: var(--text); background: var(--panel-3); }

.composer-actions { flex: none; display: flex; align-items: center; gap: 9px; }
.composer-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.composer-icon:hover { color: var(--text); background: var(--panel-3); }
.composer-icon .ico { width: 20px; height: 20px; }
.composer-icon.tool-gif {
  width: 29px;
  height: 21px;
  border: 1.5px solid var(--muted);
  border-radius: 4px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .01em;
}
.composer-icon.tool-gif:hover { border-color: var(--text); background: transparent; }

#input {
  flex: 1;
  min-width: 0;
  min-height: 28px;
  max-height: 170px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.5;
}
#input::placeholder { color: var(--dim); }
#input:disabled { opacity: .4; }

.send {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
}
.send .ico { width: 16px; height: 16px; }
.send:hover { opacity: .85; }
.send:disabled { display: none; }

.composer-hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 1px 0;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
}
.composer-hint kbd { border-color: var(--line-2); font-size: 8px; }
.composer-hint #composer-right { overflow: hidden; text-overflow: ellipsis; }

/* --------------------------------------------------------------- members */

.members {
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.app.has-members .members { display: flex; }
.members-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 0 8px; }

.member-group-label {
  padding: 9px 11px 4px;
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}
.member {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  text-align: left;
}
.member:hover { background: var(--hover); color: var(--text); }
.member.offline { opacity: .8; }
.member .avatar { width: 23px; height: 23px; font-size: 8.5px; }
.member-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .me-tag { margin-left: auto; color: var(--dim); font-size: 8.5px; text-transform: uppercase; letter-spacing: .05em; }
.member .badge-glyph { margin-left: auto; }
.member .role-mark { color: var(--muted); font-size: 9px; }

/* ----------------------------------------------------------------- boot2 */

/* --------------------------------------------------------------- dialogs */

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, .5);
}
.backdrop.visible { display: block; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
}

.dialog {
  width: 100%;
  max-width: 620px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  background: var(--panel);
}
.dialog.settings { max-width: 650px; }
.dialog.admin-dialog { max-width: 920px; }
.dialog.profile-dialog { max-width: 470px; overflow: hidden; }
.dialog.small-dialog { max-width: 430px; }
.dialog.badge-dialog { max-width: 640px; }
.dialog.server-settings { max-width: 680px; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.dialog-head h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: -.01em; }
.pad { padding: 14px; }

.settings-grid { display: grid; grid-template-columns: 138px minmax(0, 1fr); min-height: 0; flex: 1; }
.tabs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
}
.tab {
  padding: 5px 8px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  font-size: 11.5px;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: var(--text); color: var(--bg); border-left-color: var(--text); }
.panels { padding: 2px 14px 12px; overflow-y: auto; min-height: 0; }

.field { display: flex; flex-direction: column; gap: 7px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }

.seg { display: flex; border: 1px solid var(--line-2); width: fit-content; }
.seg button {
  padding: 4px 12px;
  border: 0;
  border-right: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); background: var(--panel-2); }
.seg button.active { background: var(--text); color: var(--bg); }

input[type="range"] { width: 100%; height: 14px; margin: 0; accent-color: var(--text); background: transparent; }

.toggle { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; color: var(--text-2); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .box {
  width: 14px;
  height: 14px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  color: var(--bg);
  font-size: 10px;
  line-height: 1;
}
.toggle input:checked + .box { background: var(--text); border-color: var(--text); }
.toggle input:checked + .box::after { content: "x"; font-weight: 700; }
.toggle input:focus-visible + .box { outline: 1px solid var(--text); outline-offset: 2px; }
.toggle:hover { color: var(--text); }

.keys { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.keys li { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); }
.keys li span { margin-left: auto; color: var(--muted); font-size: 10.5px; }
kbd, code {
  padding: 0 4px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 10.5px;
  font-family: var(--mono);
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.kv:last-child { border-bottom: 0; }
.kv span:last-child { color: var(--text-2); text-align: right; overflow-wrap: anywhere; }

.about-text { margin: 0 0 4px; font-size: 11.5px; color: var(--text-2); line-height: 1.55; }
.hint { font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.hint code { font-size: 9.5px; }

.btn {
  padding: 5px 11px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--text);
  font-size: 11.5px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
a.btn, a.rail-btn { text-decoration: none; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { opacity: .85; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .4; cursor: default; }

.dialog-actions { display: flex; gap: 6px; padding-top: 10px; flex-wrap: wrap; }

.inline-form { display: flex; gap: 6px; }
.inline-form input, .stack-form input, .stack-form textarea, .stack-form select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}
.inline-form input:focus, .stack-form input:focus, .stack-form textarea:focus, .stack-form select:focus { border-color: var(--text); }
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.stack-form textarea { resize: vertical; min-height: 70px; }
.stack-form .field-label { margin: 2px 0 -2px; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 24px !important;
}

.account-card { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.account-name { font-size: 13px; font-weight: 650; }
.account-handle { font-size: 10.5px; color: var(--muted); }
.account-card .btn { margin-left: auto; }

/* ------------------------------------------------------------------ share */

.share-body { padding: 2px 14px 14px; overflow-y: auto; }
.link-box { display: flex; align-items: stretch; }
.link-box code {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line-2);
  border-right: 0;
  background: var(--bg);
  color: var(--text-2);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-box .btn { border-left: 0; }
.working {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  font-size: 11.5px;
  color: var(--text-2);
}
.spinner { width: 6px; height: 6px; flex: none; background: var(--text); animation: pulse 1s steps(1, end) infinite; }
@keyframes pulse { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .2; } }
.error-text {
  margin: 0 0 6px;
  padding-left: 8px;
  border-left: 2px solid var(--bad);
  color: var(--bad);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--text); }

/* ---------------------------------------------------------------- profile */

.profile-banner {
  height: var(--profile-banner-h, 132px);
  flex: none;
  border-bottom: 1px solid var(--line-2);
  background-color: var(--panel-3);
  background-image:
    repeating-linear-gradient(135deg, transparent 0 10px, var(--line) 10px 11px),
    linear-gradient(120deg, var(--panel-2), var(--panel-3));
  background-size: 100% 100%, 100% 100%;
}
.profile-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-close { position: absolute; top: 10px; right: 10px; z-index: 3; background: var(--panel); }
.profile-dialog { position: relative; --profile-banner-h: 132px; }
.profile-body { padding: 56px 20px 20px; overflow-y: auto; min-height: 0; }
.profile-avatar-wrap { margin-top: 0; display: inline-block; padding: 4px; background: var(--panel); border: 1px solid var(--line-2); }
.profile-avatar-wrap .avatar { width: 82px; height: 82px; font-size: 26px; }
.profile-name { margin-top: 10px; font-size: 19px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.profile-handle { margin-top: 1px; font-size: 11.5px; color: var(--muted); }
.profile-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.profile-badges .badge { font-size: 10px; padding: 2px 6px; }
.profile-bio { margin: 12px 0 0; font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--muted); }
.profile-links { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.profile-links a { font-size: 11.5px; color: var(--text-2); text-decoration: none; border-left: 2px solid var(--line-2); padding-left: 7px; overflow-wrap: anywhere; }
.profile-links a:hover { border-left-color: var(--text); color: var(--text); }
.profile-links .link-label { color: var(--dim); font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; margin-right: 5px; }
.profile-actions { display: flex; gap: 6px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

.profile-form { padding: 0 16px 16px; overflow-y: auto; min-height: 0; }
.banner-editor { position: relative; margin: 0 -16px 0; }
.banner-preview {
  height: 108px;
  overflow: hidden;
  border-bottom: 1px solid var(--line-2);
  background-color: var(--panel-3);
  background-image:
    repeating-linear-gradient(135deg, transparent 0 10px, var(--line) 10px 11px),
    linear-gradient(120deg, var(--panel-2), var(--panel-3));
}
.banner-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-actions { display: flex; gap: 8px; align-items: center; padding: 8px 16px 0; }
.avatar-editor { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.avatar-editor .avatar { width: 68px; height: 68px; font-size: 22px; background: var(--panel); }
.avatar-actions { display: flex; gap: 8px; align-items: center; padding-bottom: 4px; }
.profile-fields { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.profile-fields .field-label { margin-top: 4px; }
.links-editor { display: flex; flex-direction: column; gap: 5px; }
.link-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 5px; }
.link-row input { width: 100%; padding: 5px 7px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 11.5px; outline: none; }
.link-row input:focus { border-color: var(--text); }
.link-row button { padding: 0 7px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); }
.link-row button:hover { color: var(--bad); border-color: var(--bad); }

/* ----------------------------------------------------------------- admin */

.admin-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); padding: 0 12px; flex: none; }
.admin-tabs .tab { border-left: 0; border-bottom: 2px solid transparent; padding: 8px 10px; }
.admin-tabs .tab.active { background: transparent; color: var(--text); border-bottom-color: var(--text); }

.admin-body { padding: 12px; overflow-y: auto; min-height: 0; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-bottom: 10px; background: var(--line); border: 1px solid var(--line); }
.admin-stat { padding: 8px 10px; background: var(--panel); }
.admin-stat strong { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.admin-stat span { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.admin-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.admin-row { display: grid; grid-template-columns: minmax(0, 2.1fr) 110px 90px auto; gap: 8px; align-items: center; padding: 7px 9px; background: var(--panel); }
.admin-row.server-row { grid-template-columns: minmax(0, 2fr) 120px 70px 80px auto; }
.admin-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.admin-who .avatar { width: 27px; height: 27px; font-size: 9px; }
.admin-names { min-width: 0; line-height: 1.25; }
.admin-name { font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-handle { font-size: 9.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row select { width: 100%; padding: 3px 18px 3px 5px !important; border: 1px solid var(--line-2); background-color: var(--bg); color: var(--text-2); font-size: 10.5px; }
.admin-cell { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-actions { display: flex; gap: 4px; justify-content: flex-end; }
.admin-actions .btn { padding: 3px 7px; font-size: 9.5px; }
.admin-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 11.5px; background: var(--panel); }

.badge-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; padding: 12px; overflow-y: auto; background: var(--line); }
.badge-option { display: flex; align-items: center; gap: 7px; padding: 6px 8px; background: var(--panel); cursor: pointer; font-size: 11px; }
.badge-option:hover { background: var(--panel-2); }
.badge-option input { accent-color: var(--text); }
.badge-option .glyph { width: 16px; text-align: center; color: var(--text); }
.badge-option small { display: block; font-size: 8.5px; color: var(--dim); }

.invite-preview { padding: 8px 10px; border: 1px solid var(--line-2); background: var(--bg); font-size: 11.5px; color: var(--text-2); }
.invite-preview strong { color: var(--text); }
.invite-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.invite-server { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text-2); }

.member-admin-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.member-admin {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  gap: 6px;
  align-items: center;
  padding: 5px 7px;
  background: var(--panel);
}
.member-admin .who { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11.5px; }
.member-admin .who .avatar { width: 23px; height: 23px; font-size: 8px; }
.member-admin .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-admin select { padding: 2px 18px 2px 4px !important; border: 1px solid var(--line-2); background-color: var(--bg); font-size: 10px; }
.member-admin .row-actions { display: flex; gap: 3px; }
.member-admin .row-actions button { padding: 2px 5px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); font-size: 9px; }
.member-admin .row-actions button:hover { color: var(--text); border-color: var(--text); }
.member-admin .row-actions button.danger:hover { color: var(--bad); border-color: var(--bad); }
.member-admin .who-text { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.member-admin .who-roles { display: flex; gap: 6px; color: var(--muted); font-size: 9px; line-height: 1.35; overflow: hidden; }
.member-admin .who-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- server roles */

.role-list { display: flex; flex-direction: column; gap: 6px; }
.role-empty { padding: 14px; border: 1px dashed var(--line-2); border-radius: 7px; color: var(--muted); font-size: 11.5px; text-align: center; }
.role-card { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.role-card-head { display: flex; align-items: center; gap: 5px; }
.role-swatch { width: 10px; height: 10px; flex: none; border-radius: 50%; }
.role-name-input {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  outline: none;
}
.role-name-input:hover, .role-name-input:focus { border-color: var(--line-2); background: var(--bg); }
.role-name-input[readonly] { cursor: default; }
.role-color-input {
  width: 23px;
  height: 23px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}
.role-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.role-color-input::-webkit-color-swatch { border: 0; border-radius: 3px; }
.role-total { min-width: 19px; padding: 0 5px; border-radius: 9px; background: var(--panel-3); color: var(--muted); font-size: 9.5px; line-height: 17px; text-align: center; }
.role-save, .role-delete {
  padding: 3px 5px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
}
.role-save:hover { border-color: var(--text); color: var(--text); }
.role-delete:hover { border-color: var(--bad); color: var(--bad); }
.role-members { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.role-member-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 3px 2px 6px; border-radius: 4px; background: var(--panel-3); color: var(--text-2); font-size: 10px; }
.role-member-chip button { padding: 0 2px; border: 0; background: none; color: var(--muted); font-size: 11px; line-height: 1; }
.role-member-chip button:hover { color: var(--bad); }
.role-empty-members { color: var(--muted); font-size: 10px; }
.role-member-add {
  width: auto !important;
  max-width: 140px;
  padding: 2px 18px 2px 5px !important;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background-color: var(--bg) !important;
  color: var(--muted);
  font-size: 10px !important;
}
.role-form { padding-top: 12px; }
.role-create { display: flex; align-items: center; gap: 6px; }
.role-create input:not([type="color"]) { flex: 1; min-width: 0; }
.role-create input[type="color"] { width: 38px; height: 34px; flex: none; padding: 2px; cursor: pointer; }
.role-create .btn { flex: none; }

/* ---------------------------------------------------------------- popover */

.popover {
  position: fixed;
  left: 50%;
  bottom: 104px;
  z-index: 55;
  width: min(420px, calc(100vw - 20px));
  transform: translateX(-50%);
  border: 1px solid var(--line-2);
  background: var(--panel);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
}

.picker-head { display: flex; gap: 6px; align-items: center; padding: 7px; border-bottom: 1px solid var(--line); }
.picker-head input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.picker-head input:focus { border-color: var(--text); }

.emoji-cats { display: flex; gap: 1px; padding: 5px 6px 0; overflow-x: auto; }
.emoji-cat { flex: none; width: 27px; height: 25px; display: grid; place-items: center; border: 1px solid transparent; background: transparent; font-size: 15px; }
.emoji-cat:hover { border-color: var(--line-2); }
.emoji-cat.active { background: var(--text); }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  height: 248px;
  overflow-y: auto;
  padding: 6px;
}
.emoji-cell { height: 32px; display: grid; place-items: center; padding: 0; border: 1px solid transparent; background: transparent; font-size: 20px; line-height: 1; }
.emoji-cell:hover { background: var(--panel-2); border-color: var(--line-2); }
.emoji-empty { grid-column: 1 / -1; padding: 20px; text-align: center; color: var(--muted); font-size: 11.5px; }

.gif-tabs { display: flex; gap: 3px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.gif-tab { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted); font-size: 10px; text-transform: lowercase; }
.gif-tab:hover { color: var(--text); }
.gif-tab.is-active { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.gif-tab-count { padding: 0 4px; background: var(--panel-2); border: 1px solid var(--line); font-size: 8.5px; line-height: 1.5; color: var(--text); }
.gif-tab.is-active .gif-tab-count { background: var(--bg); }
.gif-note { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.gif-note strong { color: var(--text); }
.gif-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: min-content;
  align-content: start;
  gap: 3px;
  height: 260px;
  overflow-y: auto;
  padding: 6px;
}
.gif-cell { position: relative; padding: 0; border: 1px solid var(--line); background: var(--panel-2); overflow: hidden; aspect-ratio: 1 / .78; display: block; width: 100%; }
.gif-cell:hover { border-color: var(--text); }
.gif-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-cell .gif-label { position: absolute; left: 3px; bottom: 3px; max-width: calc(100% - 6px); padding: 1px 4px; background: rgba(0, 0, 0, .7); color: #fff; font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gif-fav { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; line-height: 1; opacity: .4; cursor: pointer; }
.gif-cell:hover .gif-fav { opacity: 1; }
.gif-fav.is-on { opacity: 1; color: #ffd75e; }
.gif-fav:hover { background: rgba(0, 0, 0, .8); }
.gif-empty { grid-column: 1 / -1; padding: 24px 12px; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.gif-url-row { display: flex; gap: 5px; padding: 7px; border-top: 1px solid var(--line); }
.gif-url-row input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 11.5px; outline: none; }
.gif-url-row input:focus { border-color: var(--text); }
.gif-foot { padding: 4px 8px 6px; color: var(--dim); font-size: 8.5px; text-align: right; }

/* --------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0, 0, 0, .92);
}
.lightbox img { max-width: 94vw; max-height: 90vh; object-fit: contain; border: 1px solid #333; }
.lightbox-close { position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border: 1px solid #444; background: #000; color: #fff; font-size: 18px; }

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 110;
  transform: translate(-50%, 6px);
  max-width: min(90vw, 520px);
  padding: 7px 12px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 11.5px;
  opacity: 0;
  pointer-events: none;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- mobile */

.only-mobile { display: none; }

@media (max-width: 1100px) {
  :root { --side-w: 218px; --member-w: 198px; }
  .admin-row { grid-template-columns: minmax(0, 2fr) 96px 80px auto; }
}

@media (max-width: 900px) {
  :root { --rail-w: 56px; --side-w: 250px; }
  .app, .app.has-members { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--rail-w);
    width: min(300px, calc(100vw - var(--rail-w)));
    z-index: 40;
    visibility: hidden;
    transform: translateX(-105%);
    border-right: 1px solid var(--line-2);
  }
  .app.drawer-open .sidebar { visibility: visible; transform: none; }

  .members {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(280px, 82vw);
    z-index: 40;
    transform: translateX(102%);
    border-left: 1px solid var(--line-2);
  }
  .app.has-members .members { display: flex; }
  .app.members-open .members { transform: none; }

  .backdrop.visible { display: block; }
  .only-mobile { display: inline-block; }

  .format-bar { opacity: .8; }
  .format-hint { display: none; }
  .composer-hint span:first-child { overflow: hidden; text-overflow: ellipsis; }

  .boot { padding: 14px; }
  .boot-grid { grid-template-columns: 1fr; min-height: 0; max-width: 460px; }
  .boot-art { display: none; }
  .boot-card { padding: 28px 24px; }

  .settings-grid { grid-template-columns: 1fr; }
  .tabs { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .tab { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .tab.active { border-bottom-color: var(--text); }
  .admin-row, .admin-row.server-row { grid-template-columns: minmax(0, 1fr) 90px auto; }
  .admin-row .admin-cell:nth-of-type(2) { display: none; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .link-row { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .hide-small { display: none; }
  .chan-topic { display: none; }
  .conn span:last-child { display: none; }
  .line { grid-template-columns: 36px minmax(0, 1fr); padding-right: 12px; column-gap: 7px; }
  .line-gutter .avatar { width: 30px; height: 30px; }
  .member-count-wrap { display: none; }
  .topbar { padding: 0 9px; gap: 7px; }
  .top-actions { gap: 4px; }
  .composer-wrap { padding: 0 8px 7px; }
  .composer { min-height: 46px; gap: 5px; padding: 5px 7px 5px 9px; }
  .composer-plus, .composer-icon, .composer-icon.tool-gif, .send { width: 36px; height: 36px; }
  .composer-actions { gap: 2px; }
  .composer-icon.tool-gif { border: 0; font-size: 10px; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); height: 210px; }
  .gif-grid { height: 220px; }
  .popover { bottom: 92px; }
  .dialog { max-height: 92dvh; }
  .profile-dialog { --profile-banner-h: 100px; }
  .profile-banner { height: 100px; }
  .admin-tabs .tab { padding: 7px 6px; font-size: 10.5px; }
  .admin-body { padding: 7px; }
  .admin-row, .admin-row.server-row { grid-template-columns: minmax(0, 1fr) auto; }
  .admin-row select, .admin-row .admin-cell { display: none; }
  .admin-actions .btn { font-size: 9px; }
  .member-admin { grid-template-columns: minmax(0, 1fr) auto; }
  .member-admin select { display: none; }
  .boot-card { padding: 24px 18px; }
  .boot-links { font-size: 9.5px; }
  .line-actions { right: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; }
  .toast { transform: translate(-50%, 0); }
  .format-bar { transition: none; }
}

/* ============================================================================
   v4 — pieces the supabase build adds: site banner, presence, statuses,
   the message context menu, slash-command help, direct messages, and the
   setup card shown before config.js is filled in.
   ============================================================================ */

.is-hidden { display: none !important; }

/* ------------------------------------------------------------ setup card */

.setup-steps { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.setup-steps li { font-size: 11.5px; color: var(--text-2); line-height: 1.55; }
.setup-steps code { font-size: 10.5px; }

/* ----------------------------------------------------------- site banner */

.site-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 11.5px;
  color: var(--text-2);
}
.site-banner-mark {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: none;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
}
.site-banner-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-banner-close { padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; }
.site-banner-close:hover { color: var(--text); }

/* -------------------------------------------------------------- presence */

.presence { display: inline-block; width: 7px; height: 7px; flex: none; background: var(--line-2); }
.presence.online { background: var(--good); }
.presence.idle { background: #c8a02a; }
.presence.dnd { background: var(--bad); }
.presence.invisible, .presence.offline { background: var(--line-2); }

.avatar-wrap { position: relative; display: inline-block; line-height: 0; }
.avatar-wrap .presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  border: 1px solid var(--bg);
}
.line.own .avatar-wrap .presence { border-color: var(--own); }
.member .presence { margin-left: auto; }
.member .presence + .me-tag, .member .badge-glyph + .presence { margin-left: 6px; }

.me-custom { font-size: 9.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-custom .me-custom-emoji { margin-right: 3px; }
.rail-dm { position: relative; color: var(--muted); font-size: 14px; }
.rail-dm:hover { color: var(--text); }
.rail-dm.active { background: var(--text); color: var(--bg); }
.rail-dm-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 14px;
  padding: 0 3px;
  background: var(--text);
  color: var(--bg);
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}
.rail-dm.active .rail-dm-badge { background: var(--bg); color: var(--text); }

/* --------------------------------------------------------- status picker */

.popover.status-picker {
  left: 8px;
  bottom: 96px;
  transform: none;
  width: 300px;
  padding: 6px;
  background: var(--panel-2);
}
.status-picker-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px; }
.status-picker-title { font-size: 10px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.status-options { display: flex; flex-direction: column; }
.status-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.status-choice:hover,
.status-choice.active,
.status-option-wrap:hover > .status-choice,
.status-option-wrap:focus-within > .status-choice,
.status-option-wrap.open > .status-choice { background: var(--panel-3); }
.status-choice-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.status-choice-text strong { font-size: 13px; font-weight: 600; }
.status-choice-text small { color: var(--muted); font-size: 11px; line-height: 1.25; }
.status-chevron { color: var(--muted); font-size: 17px; line-height: 1; }
.status-mark { display: grid; place-items: center; width: 16px; height: 16px; flex: none; }
.status-mark.online { width: 10px; height: 10px; margin: 3px; border-radius: 50%; background: var(--good); }
.status-mark.idle { color: #f0b232; font-size: 14px; line-height: 1; }
.status-mark.dnd { position: relative; width: 10px; height: 10px; margin: 3px; border-radius: 50%; background: var(--bad); }
.status-mark.dnd::after {
  content: "";
  position: absolute;
  left: 2.5px;
  right: 2.5px;
  top: 4.5px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--panel-2);
}
.status-mark.invisible { width: 10px; height: 10px; margin: 3px; border: 2px solid var(--muted); border-radius: 50%; box-sizing: border-box; }
.status-option-wrap { position: relative; }
.status-durations {
  display: none;
  position: absolute;
  left: calc(100% - 2px);
  top: -4px;
  z-index: 2;
  width: 168px;
  padding: 5px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .5);
}
.status-option-wrap:hover .status-durations,
.status-option-wrap:focus-within .status-durations,
.status-option-wrap.open .status-durations { display: block; }
.status-durations button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}
.status-durations button:hover { background: var(--panel-3); color: var(--text); }
.status-custom { display: flex; gap: 5px; padding: 8px 4px 2px; border-top: 1px solid var(--line); }
.status-custom input {
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.status-custom input:focus { border-color: var(--text); }
.status-custom input:first-child { width: 42px; text-align: center; }
.status-custom input:last-child { flex: 1; }
.status-actions { display: flex; gap: 5px; padding: 6px 10px 10px; }
.status-actions .btn { flex: 1; }

/* ---------------------------------------------------------- context menu */

.context-menu {
  position: fixed;
  z-index: 90;
  min-width: 168px;
  padding: 4px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
}
.context-head {
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.context-item {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  text-align: left;
}
.context-item:hover { background: var(--panel-2); color: var(--text); }
.context-item.danger:hover { color: var(--bad); }
.context-sep { height: 1px; margin: 4px 0; background: var(--line); }

/* -------------------------------------------------------------- commands */

.dialog.commands-dialog { max-width: 520px; }
.command-list { padding: 10px 12px 14px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 1px; }
.command-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 5px 6px; background: var(--panel); }
.command-row:hover { background: var(--panel-2); }
.command-name { font-family: var(--mono); font-size: 11.5px; color: var(--text); }
.command-desc { font-size: 11px; color: var(--muted); }

/* --------------------------------------------------------- direct messages */

.dm-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; flex: 1; }
.dm-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 7px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  text-align: left;
}
.dm-row:hover { background: var(--hover); color: var(--text); }
.dm-row.active { background: var(--hover); color: var(--text); border-left-color: var(--text); }
.dm-row .avatar { width: 24px; height: 24px; font-size: 9px; }
.dm-body { flex: 1; min-width: 0; line-height: 1.25; }
.dm-name { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-preview { display: block; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-unread {
  margin-left: auto;
  min-width: 15px;
  padding: 0 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}
.dm-empty { padding: 6px 11px; color: var(--dim); font-size: 11px; line-height: 1.5; }
.dm-results { display: flex; flex-direction: column; gap: 1px; max-height: 264px; overflow-y: auto; margin-top: 4px; background: var(--line); border: 1px solid var(--line); }
.dm-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  background: var(--panel);
  color: var(--text-2);
  font-size: 12.5px;
  text-align: left;
}
.dm-result:hover { background: var(--panel-2); color: var(--text); }
.dm-result .avatar { width: 24px; height: 24px; font-size: 9px; }
.dm-result .dm-handle { color: var(--muted); font-size: 10.5px; }

/* ------------------------------------------------- admin search + notices */

.admin-search {
  width: 100%;
  margin-bottom: 8px;
  padding: 6px 9px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font-size: 11.5px;
  outline: none;
}
.admin-search:focus { border-color: var(--text); }

.line.system { color: var(--muted); font-size: 11.5px; font-style: italic; }
.line.system .msg-text { color: var(--muted); }
.line.system .msg-name { color: var(--text-2); font-weight: 600; }

@media (max-width: 620px) {
  .popover.status-picker { left: 8px; right: 8px; width: auto; bottom: 88px; }
  .command-row { grid-template-columns: 1fr; gap: 1px; }
}

/* ---------------------------------------------------------- profile status -- */
/* the presence line under a profile's handle: dot, word, and the person's own
   status emoji and text when they set one */
.profile-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.profile-status .presence-word { text-transform: lowercase; }

.profile-status .status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 9px;
  border: 1px solid var(--line-2);
  color: var(--text-2);
}

.profile-status .status-chip .status-emoji { font-size: 12px; line-height: 1; }

.profile-status .status-chip .status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the member list keeps the same chip in its rows */
.member .status-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; }

/* ============================================================================
   v5 — friends + the reworked shell: rail, home sidebar, friends page,
   DM profile panel and the roomier member list.
   ============================================================================ */

.avatar { border-radius: 50%; border: 0; background: var(--panel-3); }
.avatar-wrap .presence {
  width: 10px;
  height: 10px;
  right: -1px;
  bottom: -1px;
  border: 2px solid var(--bg);
  border-radius: 50%;
}
.presence { width: 9px; height: 9px; border-radius: 50%; }
.ico { width: 18px; height: 18px; display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ rail */

.rail { padding: 12px 0 10px; gap: 6px; border-right: 0; }
.rail-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--panel-3);
  color: var(--text-2);
  font-size: 16px;
}
.rail-btn:hover { background: var(--accent); color: #fff; }
.rail-btn.active { background: var(--accent); color: #fff; border: 0; }
.rail-brand { width: 48px; height: 48px; padding: 9px; background: transparent; border-radius: 16px; }
.rail-brand:hover { background: var(--panel-3); }
.rail-brand .logo { width: 30px; height: 30px; color: var(--text); }
.rail-brand.active { background: var(--accent); color: #fff; }
.rail-brand.active .logo { color: #fff; }
.rail-divider { width: 32px; background: var(--line); }
.rail-scroll { gap: 6px; }
.rail-actions { gap: 6px; }
.rail-add, .rail-join { color: var(--good); font-size: 20px; }
.rail-join { color: var(--muted); font-size: 17px; }
.rail-dm { color: var(--muted); font-size: 15px; }
.rail-dm.active { background: var(--accent); color: #fff; }
.rail-me { width: 46px; height: 46px; padding: 4px; background: var(--panel-3); border-radius: 50%; }
.rail-me .avatar { width: 38px; height: 38px; font-size: 13px; }
.rail-me-dot { right: 1px; bottom: 1px; width: 10px; height: 10px; border: 2px solid var(--panel-2); border-radius: 50%; }
.rail-btn .unread-dot { right: 2px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.rail-btn.active .unread-dot { background: #fff; }
.rail-friend-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 2px solid var(--panel-2);
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}
.rail-dm-badge { border-radius: 8px; }

/* ---------------------------------------------------------------- sidebar */

.sidebar { background: var(--panel); border-right: 0; }
.server-head { min-height: 56px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.server-title { font-size: 14px; }
.side-label { padding: 6px 12px; font-size: 10px; letter-spacing: .08em; }
.side-label .mini { border: 0; background: transparent; font-size: 16px; }
.side-section { padding-top: 4px; }
.channel-list { padding: 0 8px 8px; }
.channel { padding: 7px 9px; border-left: 0; border-radius: 5px; font-size: 13px; }
.channel.active { background: var(--panel-3); border-left: 3px solid var(--accent); padding-left: 6px; }
.channel .hash { display: inline-flex; }

.home-head {
  position: relative;
  flex: none;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.home-head input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 0;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.home-head input::placeholder { color: var(--muted); }
.home-head input:focus { background: var(--panel-3); }
.home-search-icon {
  position: absolute;
  left: 19px;
  top: 50%;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.home-search-icon .ico { width: 14px; height: 14px; }
.home-nav { flex: none; padding: 6px 8px 2px; }
.home-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.home-link:hover { background: var(--panel-3); color: var(--text); }
.home-link.active { background: var(--panel-3); color: var(--text); }
.home-link .ico { color: var(--muted); }
.home-link.active .ico { color: var(--text); }
.home-label { flex: 1; }
.home-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.dm-list { padding: 4px 8px 10px; }
.dm-row { gap: 10px; padding: 6px 8px; border-left: 0; border-radius: 6px; font-size: 13px; }
.dm-row:hover { background: var(--panel-3); }
.dm-row.active { background: var(--panel-3); border-left: 3px solid var(--accent); padding-left: 5px; }
.dm-row .avatar { width: 32px; height: 32px; font-size: 11px; }
.dm-body { line-height: 1.3; }
.dm-name { font-weight: 600; }
.dm-sub { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-unread { border-radius: 9px; background: var(--bad); color: #fff; }
.dm-empty { padding: 8px 12px; }
.dm-row .avatar-wrap .presence { border-color: var(--panel); }

.side-foot { padding: 8px; border-top: 1px solid var(--line); background: var(--panel-2); }
.brand-line { display: none; }
.me-card { gap: 10px; padding: 5px; border-radius: 6px; }
.me-card .avatar { width: 34px; height: 34px; font-size: 12px; }
.me-name { font-size: 13px; }
.me-host { font-size: 10.5px; }
.me-custom { font-size: 10px; }
.me-dot { border-radius: 50%; }
.foot-row { gap: 4px; }
.foot-btn { border: 0; border-radius: 5px; padding: 5px 0; background: var(--panel-3); color: var(--muted); }
.foot-btn:hover { background: var(--hover); }

/* ------------------------------------------------------------------- main */

.main { background: var(--bg); }
.topbar { min-height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.chan-head { align-items: center; }
.chan-avatar { display: inline-flex; flex: none; }
.chan-avatar .avatar { width: 27px; height: 27px; font-size: 10px; }
.chan-avatar .presence { width: 8px; height: 8px; border-width: 2px; border-color: var(--bg); }
.chan-title { font-size: 15px; }
.chan-title .hash { color: var(--muted); }
.chan-topic { border-left: 0; padding-left: 0; font-size: 12px; color: var(--muted); }
.top-actions { gap: 4px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; }
.icon-btn { border: 0; border-radius: 5px; padding: 5px 9px; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--panel-3); border-color: transparent; color: var(--text); }

.line { grid-template-columns: 44px minmax(0, 1fr); }
.line-gutter .avatar { width: 36px; height: 36px; }
.line:hover { background: var(--hover); }
.line.own { background: transparent; }
.line.own:hover { background: var(--hover); }
.msg-name { font-weight: 650; }
.msg-role { border-radius: 3px; }
.badge { border-radius: 3px; }
.attachment { border: 0; border-radius: 8px; background: var(--panel-3); padding: 0; overflow: hidden; }
.attachment img { border-radius: 8px 8px 0 0; }
.attachment-foot { padding: 5px 8px; }
.attachment-video { border-radius: 8px 8px 0 0; }

/* --------------------------------------------------------------- friends */

.friends-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.friends-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  min-height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.friends-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 14px;
  border-right: 1px solid var(--line-2);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.friends-title .ico { color: var(--muted); }
.friends-tabs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.friends-tabs::-webkit-scrollbar {
  height: 0;
}
.ftab {
  padding: 6px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.ftab:hover { background: var(--panel-3); color: var(--text-2); }
.ftab.active { background: var(--panel-3); color: var(--text); }
.ftab-count {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: 1px;
}
.add-friend {
  flex: none;
  margin-left: auto;
  padding: 7px 12px;
  border: 0;
  border-radius: 4px;
  background: var(--good);
  color: #fff;
  font-size: 12.5px;
  font-weight: 650;
}
.add-friend:hover { filter: brightness(1.12); }
.add-friend.active { background: var(--panel-3); color: var(--text); }

.friends-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0 36px; }
.friends-hint { padding: 14px 30px 0; color: var(--muted); font-size: 12px; }
.friend-group { padding-top: 8px; }
.friend-group-label {
  padding: 12px 30px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 7px 30px;
  border-top: 1px solid var(--line);
}
.friend-row:hover { background: var(--hover); }
.friend-row:last-child { border-bottom: 1px solid var(--line); }
.friend-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.friend-row .avatar { width: 36px; height: 36px; font-size: 13px; }
.friend-text { min-width: 0; line-height: 1.35; }
.friend-name { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text); }
.friend-handle { font-size: 11px; font-weight: 400; color: var(--muted); }
.friend-sub { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row.offline .avatar { filter: grayscale(.6); opacity: .7; }
.friend-actions { display: flex; align-items: center; gap: 6px; flex: none; opacity: 0; transition: opacity .1s linear; }
.friend-actions.always { opacity: 1; }
.friend-row:hover .friend-actions, .friend-row:focus-within .friend-actions { opacity: 1; }
.friend-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--panel-3);
  color: var(--text-2);
}
.friend-icon:hover { background: var(--hover); color: var(--text); }
.friend-icon .ico { width: 15px; height: 15px; }
.friend-action {
  padding: 5px 9px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
}
.friend-action:hover { border-color: var(--text); color: var(--text); }
.friend-action.primary { border-color: var(--good); background: var(--good); color: #fff; }
.friend-action.primary:hover { filter: brightness(1.1); }
.friend-action.accept { border-color: var(--good); background: transparent; color: var(--good); }
.friend-action.accept:hover { background: var(--good); color: #fff; }
.friend-action:disabled { opacity: .5; cursor: default; }
.friend-note { color: var(--muted); font-size: 11.5px; }
.friends-empty { padding: 38px 30px; max-width: 680px; }
.friends-empty strong { display: block; margin-bottom: 5px; font-size: 15px; font-weight: 650; }
.friends-empty span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.friends-empty code { border: 1px solid var(--line-2); padding: 0 4px; border-radius: 3px; }
.friends-empty-actions { margin-top: 14px; }
.friends-empty.setup { border-left: 2px solid var(--accent); margin: 26px 30px; padding: 18px 20px; background: var(--panel-3); border-radius: 6px; }
.add-friend-panel { max-width: 720px; padding: 26px 30px; }
.add-friend-label { font-size: 15px; font-weight: 700; }
.add-friend-copy { margin: 6px 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.add-friend-box { position: relative; }
.add-friend-box input {
  width: 100%;
  padding: 11px 38px 11px 12px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.add-friend-box input:focus { border-color: var(--accent); }
.add-friend-box input::placeholder { color: var(--dim); }
.add-friend-box-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.add-friend-box-icon .ico { width: 16px; height: 16px; }
.friend-results { margin-top: 10px; }
.friend-results .friend-row { padding: 8px 0; border-top: 1px solid var(--line); }
.friend-results .friend-row:last-child { border-bottom: 1px solid var(--line); }
.friend-search-note { padding: 18px 2px; color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------- dm profile pane */

.dm-profile {
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.app.has-profile .dm-profile { display: flex; }
.app.has-profile { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--profile-w); }
.dm-profile-empty { padding: 24px; color: var(--muted); font-size: 12px; }
.dm-profile-banner {
  position: relative;
  flex: none;
  height: 118px;
  background: linear-gradient(135deg, #3d4166, var(--accent));
  overflow: hidden;
}
.dm-profile-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dm-profile-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
}
.dm-profile-close:hover { background: rgba(0, 0, 0, .7); }
.dm-profile-close .ico { width: 14px; height: 14px; }
.dm-profile-avatar {
  position: relative;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 16px;
  padding: 6px;
  border-radius: 50%;
  background: var(--panel);
}
.dm-profile-avatar .avatar { width: 72px; height: 72px; font-size: 24px; }
.dm-profile-avatar .presence {
  position: absolute;
  right: 5px;
  bottom: 7px;
  width: 15px;
  height: 15px;
  border: 3px solid var(--panel);
}
.dm-profile-body { padding: 10px 16px 24px; }
.dm-profile-name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.02em;
  line-height: 1.2;
  text-align: left;
}
.dm-profile-name:hover { text-decoration: underline; text-underline-offset: 2px; }
.dm-profile-handle { margin-top: 2px; color: var(--muted); font-size: 12px; }
.dm-pronouns { margin-left: 6px; color: var(--dim); }
.dm-profile-status { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.dm-profile-status .status-chip,
.dm-intro .status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--text-2);
  font-size: 11.5px;
}
.dm-profile-status .status-text, .dm-intro .status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-block {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-3);
}
.profile-block-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.profile-block-text { color: var(--text-2); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-block-links { display: flex; flex-direction: column; gap: 5px; }
.profile-block-links a { color: var(--text-2); font-size: 12px; text-decoration: none; overflow-wrap: anywhere; }
.profile-block-links a:hover { text-decoration: underline; }
.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--text-2);
  font-size: 12.5px;
  text-align: left;
}
.profile-card:hover { background: var(--hover); color: var(--text); }
.profile-card .ico { color: var(--muted); }
.dm-profile-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.dm-profile-actions .btn { flex: 1 1 auto; }
.friend-note { color: var(--muted); font-size: 11.5px; }

/* -------------------------------------------------------------- dm intro */

.dm-intro { max-width: 720px; padding: 26px 30px 20px; }
.dm-intro-avatar { width: 84px; height: 84px; font-size: 28px; }
.dm-intro h2 { margin: 14px 0 0; font-size: 24px; font-weight: 750; letter-spacing: -.025em; }
.dm-intro-handle { margin-top: 2px; color: var(--muted); font-size: 13px; }
.dm-intro-text { margin: 14px 0 0; color: var(--text-2); font-size: 13.5px; line-height: 1.6; }
.dm-intro-status { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--text-2); font-size: 12.5px; }
.dm-intro-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.dm-intro-friend::before { content: "·"; margin-right: 16px; color: var(--line-2); }
.dm-intro-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.dm-intro-actions .btn { border-radius: 4px; }

/* ---------------------------------------------------------------- members */

.members { background: var(--panel); border-left: 0; }
.members-scroll { padding: 0 0 10px; }
.member-group-label { padding: 14px 16px 5px; font-size: 10px; }
.member {
  gap: 10px;
  margin: 1px 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
}
.member:hover { background: var(--panel-3); }
.member .avatar { width: 32px; height: 32px; font-size: 10px; }
.member .avatar-wrap .presence { border-color: var(--panel); }
.member .presence { margin-left: 0; }
.member-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.member-name { font-size: 13px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .role-mark { margin-left: auto; font-size: 9px; }
.member.offline { opacity: .75; }

/* --------------------------------------------------------- modal + buttons */

.dialog { border: 0; border-radius: 12px; box-shadow: 0 24px 80px rgba(0, 0, 0, .5); }
.dialog-head { padding: 13px 16px; }
.btn { border-radius: 4px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.boot-btn { border-radius: 5px; background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-tab { border-radius: 4px; }
.auth-tab.active { background: var(--accent); color: #fff; }
.mini { border-radius: 4px; }
.popover { border-radius: 10px; border: 0; box-shadow: 0 16px 60px rgba(0, 0, 0, .55); }
.context-menu { border-radius: 8px; }
.context-item { border-radius: 4px; }
.stack-form input, .stack-form textarea, .stack-form select,
.admin-search, .status-custom input, .gif-url-row input, .picker-head input, .link-box code { border-radius: 5px; }
.profile-dialog { border-radius: 12px; }
.profile-banner { border-radius: 12px 12px 0 0; }
.profile-avatar-wrap {
  position: absolute;
  top: var(--profile-banner-h, 132px);
  left: 20px;
  z-index: 2;
  margin: 0;
  transform: translateY(-50%);
  padding: 6px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
}
.profile-avatar-wrap .avatar { width: 76px; height: 76px; font-size: 24px; }
.profile-actions { flex-wrap: wrap; }
.profile-friend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.profile-friend .btn { border-radius: 4px; }
.mutual-dialog { max-width: 460px; }
.mutual-list { padding: 8px; overflow-y: auto; max-height: 60vh; }
.mutual-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  text-align: left;
}
.mutual-row:hover { background: var(--panel-3); color: var(--text); }
.mutual-ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}
.mutual-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mutual-handle { display: block; color: var(--muted); font-size: 11px; }
.mutual-empty { padding: 20px 14px; color: var(--muted); font-size: 12.5px; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  :root { --profile-w: 290px; --member-w: 220px; }
}

@media (max-width: 900px) {
  .app.has-profile { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .dm-profile {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: min(330px, 88vw);
    border-left: 1px solid var(--line-2);
    box-shadow: -24px 0 60px rgba(0, 0, 0, .45);
  }
  .app.has-profile .dm-profile { display: flex; }
  .friends-head { padding: 0 10px; }
}

@media (max-width: 700px) {
  .friends-head { flex-wrap: wrap; min-height: 0; padding: 10px; gap: 8px; }
  .friends-title { padding-right: 0; border-right: 0; }
  .friends-tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .ftab { padding: 6px 7px; }
  .friends-body { padding-top: 2px; }
  .friend-group-label { padding: 12px 14px 5px; }
  .friend-row { padding-left: 14px; padding-right: 14px; gap: 8px; }
  .friend-actions { opacity: 1; }
  .friend-handle { display: none; }
  .friends-hint, .friends-empty, .add-friend-panel { padding-left: 14px; padding-right: 14px; }
  .friends-empty.setup { margin: 16px 14px; }
  .dm-intro { padding: 22px 16px 18px; }
  .dm-intro h2 { font-size: 21px; }
  .dm-intro-friend::before { display: none; }
  .friends-empty-actions .friend-action { padding: 6px 10px; }
}

/* --------------------------------------------------------- profile popout */

.profile-pop {
  position: fixed;
  z-index: 58;
  width: min(340px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel-2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  scrollbar-width: thin;
}
.profile-pop[hidden] { display: none; }
.profile-pop.pp-self { overflow-x: hidden; }
.profile-pop.pp-self.pp-has-cover { padding-top: 0; }

.pp-cover {
  height: 92px;
  margin: 0 -14px;
  overflow: hidden;
  background: linear-gradient(135deg, #393d61, var(--accent));
}
.pp-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pp-self.pp-has-cover .pp-head { margin-top: -36px; }
.pp-self .pp-avatar {
  width: 96px;
  height: 96px;
  padding: 4px;
  border-radius: 50%;
  background: var(--panel-2);
}
.pp-self .pp-avatar .avatar { width: 88px; height: 88px; font-size: 29px; }
.pp-self.pp-has-cover .pp-head .pp-bubble { margin-top: 52px; }
.pp-self .pp-ident { margin-top: 9px; }

.pp-head { display: flex; align-items: flex-start; gap: 10px; }
.pp-avatar { position: relative; width: 88px; height: 88px; flex: none; }
.pp-avatar .avatar { width: 84px; height: 84px; font-size: 28px; }
.pp-avatar .presence {
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  border: 4px solid var(--panel-2);
}
.pp-emoji {
  position: absolute;
  right: -4px;
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--panel-2);
  border-radius: 50%;
  background: var(--panel-3);
  font-size: 12px;
  line-height: 1;
}
.pp-bubble {
  position: relative;
  max-width: 200px;
  margin-top: 16px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--panel-3);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.pp-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 14px;
  border: 6px solid transparent;
  border-left: 0;
  border-right-color: var(--panel-3);
}
a.pp-bubble:hover { color: var(--text); }

.pp-ident { margin-top: 11px; }
.pp-name { font-size: 20px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.pp-handle { margin-top: 2px; color: var(--muted); font-size: 12px; }
.pp-pronouns { color: var(--dim); }
.pp-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.pp-badges .badge { padding: 2px 6px; font-size: 9.5px; gap: 4px; }
.pp-bio { margin: 11px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.pp-links { display: flex; flex-direction: column; gap: 4px; margin-top: 9px; }
.pp-links a { color: var(--text-2); font-size: 12px; text-decoration: none; overflow-wrap: anywhere; }
.pp-links a:hover { color: var(--text); text-decoration: underline; }

.pp-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.pp-section-label { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.pp-role-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pp-role-pill { padding: 3px 9px; border-radius: 999px; background: var(--panel-3); color: var(--text-2); font-size: 11px; }
.pp-role-custom { display: inline-flex; align-items: center; gap: 5px; }
.role-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; }
.pp-role-select {
  padding: 4px 7px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 11px;
  outline: none;
}
.pp-role-select:focus { border-color: var(--text); }

.pp-friend-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.pp-friend-actions .btn { flex: 1 1 auto; border-radius: 4px; font-size: 12px; }

.pp-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 0;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
}
.pp-primary:hover { background: var(--hover); }
.pp-primary .ico { width: 15px; height: 15px; color: var(--muted); }

.pp-rows { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.pp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  text-align: left;
}
.pp-row:hover { background: var(--panel-3); color: var(--text); }
.pp-row .ico { width: 17px; height: 17px; color: var(--muted); }
.pp-row .ico:last-child { margin-left: auto; width: 14px; height: 14px; transition: transform .12s ease; }
.pp-row.open .ico:last-child { transform: rotate(90deg); }
.pp-row-label { flex: 1; min-width: 0; }
.pp-row-value { color: var(--muted); font-size: 11.5px; }
.pp-row-ico { width: 17px; text-align: center; color: var(--muted); font-weight: 700; }

.pp-badge-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  margin-top: 4px;
  padding: 8px;
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 11px;
}
.pp-badge-list span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pp-badge-list b { color: var(--text); font-weight: 600; }

.pp-full {
  width: 100%;
  margin-top: 12px;
  padding: 9px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
}
.pp-full:hover { background: var(--panel-3); color: var(--text); }

.dm-profile-full {
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}
.dm-profile-full:hover { background: var(--panel-3); }

@media (max-width: 620px) {
  .profile-pop { width: calc(100vw - 16px); left: 8px !important; right: 8px; }
  .status-durations {
    position: static;
    width: auto;
    margin: 2px 4px 6px 26px;
    padding: 3px;
    border-radius: 6px;
    background: var(--panel-3);
    box-shadow: none;
  }
  .status-option-wrap:hover .status-durations,
  .status-option-wrap:focus-within .status-durations { display: none; }
  .status-option-wrap.open .status-durations { display: block; }
}

/* ------------------------------------------------------------- voice call */

.call-bar,
.call-incoming {
  position: fixed;
  right: 22px;
  bottom: 118px;
  z-index: 105;
  display: flex;
  align-items: center;
  gap: 11px;
  width: min(360px, calc(100vw - 28px));
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .42);
}

.call-incoming { flex-wrap: wrap; border-color: var(--text-2); }

.call-avatar { width: 38px; height: 38px; font-size: 13px; }

.call-bar-body,
.call-incoming-body {
  display: flex;
  flex: 1 1 90px;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.call-bar-name,
.call-incoming-body strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-bar-state,
.call-incoming-body span {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.call-btn,
.call-action {
  flex: none;
  padding: 5px 10px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
}

.call-btn:hover,
.call-action:hover { border-color: var(--text); color: var(--text); }
.call-btn.on { background: var(--panel-3); color: var(--text); }
.call-btn.hangup:hover { border-color: var(--bad); color: var(--bad); }

.call-incoming-actions { display: flex; gap: 6px; margin-left: auto; }
.call-action.accept { border-color: var(--good); background: var(--good); color: #fff; }
.call-action.accept:hover { border-color: var(--good); color: #fff; opacity: .85; }

@media (max-width: 900px) {
  .call-bar,
  .call-incoming { right: 12px; left: 12px; bottom: 118px; width: auto; }
}

/* ============================================================= accents ---- */

html[data-accent="teal"] { --accent: #416b68; }
html[data-accent="blue"] { --accent: #3f6385; }
html[data-accent="violet"] { --accent: #5b4a86; }
html[data-accent="amber"] { --accent: #8a6a2f; }
html[data-accent="rose"] { --accent: #8a3d4d; }
html[data-accent="mono"] { --accent: #505050; }

html[data-theme="light"][data-accent="teal"] { --accent: #35635f; }
html[data-theme="light"][data-accent="blue"] { --accent: #2f5177; }
html[data-theme="light"][data-accent="violet"] { --accent: #4a3b73; }
html[data-theme="light"][data-accent="amber"] { --accent: #6f5320; }
html[data-theme="light"][data-accent="rose"] { --accent: #7a3342; }
html[data-theme="light"][data-accent="mono"] { --accent: #3a3a3a; }

html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ============================================================ settings ---- */

.settings-head { flex-wrap: wrap; }
.settings-head h2 { flex: 1 1 auto; }
.settings-search { position: relative; display: flex; align-items: center; flex: 0 1 230px; margin-left: auto; }
.settings-search .ico { position: absolute; left: 8px; width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.settings-search input { width: 100%; padding: 5px 9px 5px 27px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--bg); color: var(--text); font-size: 11.5px; outline: none; }
.settings-search input:focus { border-color: var(--text); }

.panel-head { padding: 14px 0 2px; }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.panel-head p { margin: 3px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.settings-empty { padding: 24px 4px; color: var(--muted); font-size: 12px; }
.search-hidden { display: none !important; }

.accent-row { display: flex; flex-wrap: wrap; gap: 7px; }
.accent-swatch { width: 30px; height: 30px; padding: 3px; border: 1px solid var(--line-2); border-radius: 50%; background: transparent; }
.accent-swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--swatch); }
.accent-swatch:hover { border-color: var(--text); }
.accent-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--text); }
.accent-teal { --swatch: #416b68; }
.accent-blue { --swatch: #3f6385; }
.accent-violet { --swatch: #5b4a86; }
.accent-amber { --swatch: #8a6a2f; }
.accent-rose { --swatch: #8a3d4d; }
.accent-mono { --swatch: #505050; }

/* ====================================================== quick switcher ---- */

.dialog.quick-dialog { max-width: 520px; }
.quick-body { padding: 10px 12px 12px; }
.quick-body > input { width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 13px; outline: none; }
.quick-body > input:focus { border-color: var(--text); }
.quick-results { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; max-height: 320px; overflow-y: auto; }
.quick-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border: 0; border-radius: 5px; background: transparent; color: var(--text-2); text-align: left; }
.quick-row:hover,
.quick-row.is-active { background: var(--panel-3); color: var(--text); }
.quick-mark { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 6px; background: var(--panel-3); color: var(--muted); font-size: 12px; }
.quick-row.is-active .quick-mark { background: var(--accent); color: #fff; }
.quick-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.quick-label { overflow: hidden; font-size: 12.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.quick-sub { overflow: hidden; font-size: 10.5px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.quick-kind { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.quick-empty { padding: 20px 6px; text-align: center; color: var(--muted); font-size: 12px; }
.quick-body .hint { display: block; margin: 9px 1px 0; }

/* =============================================================== admin ---- */

.dialog.admin-dialog { max-width: 1000px; }
.admin-tabs .tab { font-size: 11px; letter-spacing: 0.02em; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 9px; }
.admin-toolbar .admin-search { flex: 1 1 220px; width: auto; margin-bottom: 0; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 4px 9px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--muted); font-size: 10.5px; }
.chip:hover { color: var(--text); border-color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin-select { width: auto; padding: 4px 22px 4px 8px !important; border: 1px solid var(--line-2); background-color: var(--bg); color: var(--text-2); font-size: 10.5px; }
.admin-results-line { margin: 0 0 6px 1px; color: var(--dim); font-size: 9.5px; letter-spacing: 0.03em; text-transform: uppercase; }

.admin-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 8px; }
.admin-stat { padding: 9px 10px; }
.admin-stat strong { font-size: 18px; }
.admin-stat small { display: block; margin-top: 2px; overflow: hidden; color: var(--dim); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.admin-card { border: 1px solid var(--line); background: var(--panel); }
.admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.admin-card-head .link-btn { font-size: 9.5px; letter-spacing: 0; text-transform: none; }
.admin-mini-list { display: flex; flex-direction: column; }
.admin-mini { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text-2); text-align: left; }
.admin-mini:last-child { border-bottom: 0; }
.admin-mini:hover { background: var(--panel-2); color: var(--text); }
.admin-mini .avatar { width: 26px; height: 26px; font-size: 9px; }
.admin-mini-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.admin-mini-name { overflow: hidden; font-size: 11.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.admin-mini-sub { overflow: hidden; font-size: 10px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.admin-mini .presence { margin-left: auto; }
.admin-mini-list .admin-empty { padding: 14px 10px; text-align: left; }
.admin-health { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.admin-health-row { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; background: var(--panel); }
.admin-health-row span { color: var(--muted); font-size: 9px; letter-spacing: 0.07em; text-transform: uppercase; }
.admin-health-row strong { overflow-wrap: anywhere; color: var(--text-2); font-size: 11.5px; font-weight: 600; }
#admin-announce-count { display: block; margin: 3px 0 8px; }
#admin-announce-count.is-warning { color: var(--bad); }
.admin-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.admin-badge-glyphs { color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.admin-actions { flex-wrap: wrap; }

.admin-dialog:focus-visible,
.admin-row:focus-visible,
.quick-row:focus-visible { outline: 1px solid var(--text); outline-offset: -1px; }

@media (max-width: 900px) {
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-columns { grid-template-columns: 1fr; }
  .admin-health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-toolbar .admin-search { flex-basis: 100%; }
}

@media (max-width: 620px) {
  .settings-search { flex-basis: 100%; order: 3; margin: 6px 0 2px; }
  .settings-grid .tabs { flex-wrap: wrap; gap: 2px 12px; overflow-x: visible; padding: 6px 10px; }
  .settings-grid .tab { padding: 4px 0; }
  .admin-actions .btn { padding: 3px 6px; }
  .admin-health-row { padding: 7px 8px; }
}

/* ================================================== channel drag order ---- */

.server-head-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-3); color: var(--text-2); font-size: 13px; font-weight: 650; line-height: 1; }
.server-head-icon .server-head-img { display: block; width: 100%; height: 100%; object-fit: cover; }

.channel.channel-muted .name { color: var(--dim); }
.channel.channel-muted .hash { opacity: .5; }
.channel-hidden-note { padding: 9px 10px; color: var(--dim); font-size: 11px; line-height: 1.45; }

.chan-drag { display: grid; place-items: center; width: 14px; align-self: stretch; flex: none; margin-left: -3px; color: var(--dim); font-size: 11px; line-height: 1; letter-spacing: -1px; cursor: grab; opacity: 0; touch-action: none; }
.channel:hover .chan-drag,
.chan-drag:focus-visible { opacity: 1; }
.chan-drag:active { cursor: grabbing; }
.chan-drag:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: -1px; }
.channel.is-dragging { opacity: .32; }
.channel-list.is-reordering,
.channel-list.is-reordering .channel,
.channel-list.is-reordering .channel * { cursor: grabbing; user-select: none; }
.channel.drag-before { box-shadow: inset 0 2px 0 var(--accent); }
.channel.drag-after { box-shadow: inset 0 -2px 0 var(--accent); }
.channel-ghost { position: fixed; z-index: 330; margin: 0; pointer-events: none; border: 1px solid var(--line-2); border-radius: 5px; background: var(--panel-3); color: var(--text); box-shadow: 0 14px 34px rgba(0, 0, 0, .4); opacity: .96; }
@media (hover: none) { .chan-drag { opacity: .65; } }

/* ======================================================= server identity ---- */

.rail-btn { padding: 0; overflow: hidden; }
.rail-btn .rail-icon { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.rail-btn.active .rail-icon { box-shadow: inset 0 0 0 2px var(--text); }
.rail-btn .unread-dot { z-index: 2; }

.server-icon-editor { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 11px; }
.server-icon-preview { position: relative; display: grid; place-items: center; width: 64px; height: 64px; flex: none; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-3); color: var(--text-2); font-size: 22px; font-weight: 650; }
.server-icon-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.server-icon-controls { display: flex; flex: 1; flex-direction: column; gap: 7px; min-width: 0; }
.server-icon-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.server-icon-actions .btn { padding: 4px 9px; font-size: 10.5px; }
.server-icon-actions .btn:disabled { opacity: .45; cursor: default; }

.mutual-ico img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* -------------------------------------------------------- server menu ----- */

.server-context, .channel-context { position: fixed; z-index: 320; width: 264px; padding: 5px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); color: var(--text-2); box-shadow: 0 18px 44px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.28); font-size: 12px; }
.channel-context { width: 196px; }
.server-context.is-hidden, .channel-context.is-hidden { display: none; }
.server-menu-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 9px; border: 0; border-radius: 4px; background: transparent; color: inherit; font: inherit; text-align: left; }
.server-menu-btn:hover, .server-menu-btn:focus-visible { background: var(--panel-3); color: var(--text); outline: none; }
.server-menu-btn.danger { color: var(--bad); }
.server-menu-btn:disabled { color: var(--dim); cursor: default; }
.server-menu-btn:disabled:hover { background: transparent; color: var(--dim); }
.server-menu-btn.danger:hover { background: rgba(242, 63, 67, .1); color: var(--bad); }
.server-menu-btn.has-note { display: grid; grid-template-columns: 1fr auto; }
.server-menu-btn.has-note small { grid-column: 1 / -1; padding-top: 2px; color: var(--muted); font-size: 10px; }
.server-menu-arrow { margin-left: auto; color: var(--dim); font-size: 15px; line-height: 1; }
.server-menu-btn.has-note .server-menu-arrow { margin-left: 0; }
.server-menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.server-menu-item { position: relative; }
.server-menu-sub { position: absolute; left: 100%; top: -5px; display: none; width: 220px; max-height: min(70vh, 380px); overflow-y: auto; padding: 5px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); box-shadow: 0 18px 44px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.28); }
.server-menu-sub.flip-left { left: auto; right: 100%; }
.server-menu-sub::before { content: ""; position: absolute; top: 0; bottom: 0; left: -7px; width: 7px; }
.server-menu-sub.flip-left::before { left: auto; right: -7px; }
.server-menu-item:hover > .server-menu-sub,
.server-menu-item.open > .server-menu-sub { display: block; }
.server-menu-item.open > .server-menu-btn { background: var(--panel-3); color: var(--text); }
.server-menu-sub-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 0; border-radius: 4px; background: transparent; color: var(--text-2); font: inherit; text-align: left; }
.server-menu-sub-btn:hover, .server-menu-sub-btn:focus-visible { background: var(--panel-3); color: var(--text); outline: none; }
.server-menu-sub-btn.active { color: var(--text); }
.server-menu-check { margin-left: auto; color: var(--good); font-size: 11px; }
.server-menu-check-row { gap: 9px; }
.server-menu-checkbox { display: grid; place-items: center; width: 15px; height: 15px; flex: none; border: 1px solid var(--line-2); border-radius: 3px; color: var(--bg); font-size: 10px; font-weight: 700; line-height: 1; }
.server-menu-checkbox.checked { border-color: var(--text); background: var(--text); }

.engagement-head { display: flex; align-items: center; gap: 11px; padding: 2px 0 12px; border-bottom: 1px solid var(--line); }
.engagement-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.engagement-head strong { font-size: 13px; }
.engagement-head span:not(.server-icon-preview) { color: var(--muted); font-size: 10.5px; }
.engagement-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 12px 0; }
.engagement-stat { display: flex; flex-direction: column; gap: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.engagement-stat span { color: var(--muted); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; }
.engagement-stat strong { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1; }
.engagement-note { margin: 0; color: var(--dim); font-size: 10.5px; line-height: 1.5; }
.engagement-loading { padding: 22px 2px; color: var(--muted); font-size: 12px; }

@media (max-width: 620px) {
  .server-icon-preview { width: 54px; height: 54px; font-size: 18px; }
  .server-context { width: 240px; }
  .server-menu-sub { width: 200px; }
}

/* A submenu to the right needs roughly 470px. Below that, swap the parent
   menu for the submenu so nothing spills off a narrow window. */
@media (max-width: 560px) {
  .server-menu-sub { top: 0; left: 0; width: 100%; max-height: min(65vh, 340px); background: var(--panel-2); }
  .server-menu-sub::before { display: none; }
  .server-menu-item:hover > .server-menu-sub,
  .server-menu-item.open > .server-menu-sub { z-index: 2; }
}

/* Chattr 2: shared surfaces and a roomier settings workspace. Existing
   controls and their data bindings stay in place; these rules only change
   their presentation. */
:root {
  --rail-w: 68px;
  --side-w: 248px;
  --member-w: 226px;
  --radius: 10px;
}
html[data-theme="dark"] {
  --bg: #17191c;
  --panel: #1d2024;
  --panel-2: #141619;
  --panel-3: #292d32;
  --line: #30343a;
  --line-2: #41474f;
  --text: #f1f3f4;
  --text-2: #d5d9dc;
  --muted: #adb5bc;
  --dim: #939ca5;
  --hover: #24282d;
}
html[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f6f7f7;
  --panel-2: #eef1f1;
  --panel-3: #e3e8e7;
  --line: #dce2e0;
  --line-2: #c5cecb;
  --text: #171e1d;
  --text-2: #35403e;
  --muted: #596763;
  --dim: #697974;
  --hover: #f0f4f2;
}

.rail { border-right: 1px solid var(--line); }
.rail-btn { border-radius: 16px; }
.rail-btn .rail-icon { border-radius: inherit; }
.sidebar { border-right: 1px solid var(--line); }
.server-head, .topbar, .friends-head { min-height: 60px; }
.server-title, .chan-title, .friends-title { letter-spacing: -.015em; }
.channel, .dm-row, .home-link { border-radius: 7px; }
.channel.active, .dm-row.active { border-left-color: var(--accent); }
.side-foot { background: var(--panel); }
.foot-btn { min-height: 32px; }
.log { scrollbar-gutter: stable; }
.line { padding-top: 3px; padding-bottom: 3px; }
.composer-wrap { border-top: 0; padding: 0 16px 12px; }
.composer { border-radius: 10px; }
.friends-head { gap: 10px; }
.friend-row { min-height: 62px; }
.friend-icon:focus-visible, .friend-action:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* The sign-in page and chat details use the same surfaces as the shell. */
.boot-grid { border-radius: 14px; overflow: hidden; }
.boot-art { background-image: none; }
.boot-art::after { background: none; }
.boot-logo-wrap { border-radius: 12px; }
.boot-card { padding: 44px; }
.boot-card-head h1 { font-size: 24px; }
.boot-sub, .boot-note { font-size: 13px; }
.auth-tabs { gap: 4px; padding: 4px; border-radius: 8px; background: var(--panel-2); }
.auth-tab { min-height: 36px; border: 0; font-size: 13px; }
#auth-form input, .boot-card input { min-height: 42px; border-radius: 7px; font-size: 14px; }
.boot-btn { min-height: 42px; border-radius: 7px; }
.log-day { margin-top: 22px; font-size: 11px; letter-spacing: .03em; }
.line.group-start { margin-top: 14px; }
.msg-time { font-size: 11px; }
.line-actions { border-radius: 7px; box-shadow: 0 5px 16px rgba(0, 0, 0, .15); }
.msg-action { min-height: 26px; border-radius: 5px; }
.attach-preview { border-radius: 8px; padding: 6px; }
.attachment, .attachment img, .attachment-video { border-radius: 9px; }
.dm-profile { border-left: 1px solid var(--line); }
.profile-block { background: var(--panel-2); }
.profile-card { background: var(--panel-2); }
.profile-dialog, .profile-pop { border: 1px solid var(--line-2); }
.friend-row:focus-within { background: var(--hover); }

.dialog { border: 1px solid var(--line); border-radius: 12px; }
.dialog-head { min-height: 58px; padding: 12px 18px; }
.dialog-head h2 { font-size: 16px; }
.dialog .btn { min-height: 34px; border-radius: 7px; padding: 6px 12px; }
.dialog .btn.danger { color: var(--bad); }
.dialog .btn.danger:hover { background: var(--hover); }
.popover, .context-menu, .server-context, .channel-context {
  border: 1px solid var(--line-2);
  border-radius: 10px;
}

.dialog.settings {
  width: min(1120px, 100%);
  max-width: 1120px;
  height: min(850px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  background: var(--bg);
  overflow: hidden;
}
.settings-head { gap: 12px; padding: 14px 22px; background: var(--panel); }
.settings-head h2 { font-size: 18px; }
.settings-search { flex-basis: 260px; }
.settings-search input { min-height: 38px; font-size: 13px; border-radius: 7px; }
.settings-grid { grid-template-columns: 220px minmax(0, 1fr); }
.settings .tabs {
  gap: 4px;
  padding: 16px 12px;
  background: var(--panel);
}
.settings .tab {
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.settings .tab:hover { background: var(--hover); color: var(--text); }
.settings .tab.active { background: var(--panel-3); color: var(--text); }
.settings .panels { padding: 14px clamp(22px, 5vw, 64px) 40px; overscroll-behavior: contain; }
.settings .panel, .settings-empty { width: min(100%, 740px); margin: 0 auto; }
.settings .panel-head { padding: 14px 0 12px; }
.settings .panel-head h3 { font-size: 23px; line-height: 1.2; }
.settings .panel-head p { margin-top: 8px; font-size: 13px; }
.settings .field { gap: 10px; padding: 20px 0; }
.settings .field-label { margin: 0; font-size: 12px; letter-spacing: .04em; }
.settings .about-text, .settings .hint { font-size: 13px; line-height: 1.55; }
.settings .seg { max-width: 100%; border-radius: 8px; overflow: hidden; }
.settings .seg button { min-height: 38px; padding: 8px 18px; font-size: 13px; }
.settings .seg button.active { background: var(--accent); color: #fff; }
.settings .toggle { min-height: 38px; gap: 10px; font-size: 13px; }
.settings .toggle .box { width: 18px; height: 18px; border-radius: 4px; }
.settings .toggle input:checked + .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.settings .toggle input:checked + .box::after { content: "✓"; }
.settings .accent-swatch { width: 36px; height: 36px; }
.settings input[type="range"] { accent-color: var(--accent); min-height: 28px; }
.settings .keys li, .settings .keys li span, .settings .kv { font-size: 13px; }
.settings .account-card { padding: 12px; border-radius: 9px; background: var(--panel); }
.settings .stack-form input { min-height: 40px; font-size: 13px; }
.settings .field > .btn { align-self: flex-start; }

.admin-dialog .admin-tabs { gap: 4px; overflow-x: auto; }
.admin-dialog .admin-tabs .tab { font-size: 12px; white-space: nowrap; }
.admin-dialog .admin-tabs .tab.active { border-bottom-color: var(--accent); }
.admin-dialog .admin-body { padding: 18px; }
.admin-card, .admin-stat { border-radius: 7px; }
.admin-stats { gap: 6px; border: 0; background: transparent; }
.admin-stat { border: 1px solid var(--line); }
.admin-dialog .panel-head h3 { font-size: 18px; }
.admin-dialog .panel-head p, .admin-dialog .about-text { font-size: 12.5px; }

@media (max-width: 1100px) {
  :root { --side-w: 218px; --member-w: 198px; }
}
@media (max-width: 900px) {
  :root { --rail-w: 56px; --side-w: 250px; }
  .settings-grid { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .settings .tabs { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .settings .tab { flex: none; white-space: nowrap; }
  .settings .panels { padding: 12px 24px 32px; }
}
@media (max-width: 620px) {
  .dialog.settings { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .overlay:has(.dialog.settings:not(.is-hidden)) { padding: 0; }
  .settings-head { padding: 10px 14px; }
  .settings-search { flex-basis: 100%; order: 3; margin: 0; }
  .settings .tabs { gap: 4px; padding: 8px 10px; }
  .settings .tab { padding: 8px 12px; }
  .settings .panels { padding: 8px 18px 28px; }
  .settings .panel-head h3 { font-size: 21px; }
  .composer-wrap { padding: 0 8px 8px; }
  .boot-card { padding: 24px 18px; }
  .line-actions { box-shadow: none; }
  .admin-dialog .admin-body { padding: 12px; }
  .admin-row, .admin-row.server-row, .member-admin { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; }
  .admin-row select, .admin-row .admin-cell, .member-admin select { display: block; width: 100%; }
  .admin-row .admin-cell:nth-of-type(2) { display: block; }
  .admin-actions { justify-content: flex-start; }
  .admin-dialog .admin-actions .btn, .member-admin .row-actions button { min-height: 34px; padding: 6px 9px; font-size: 11px; }
}

/* GIF / emoji picker */
.gif-picker, .emoji-picker { width: min(620px, calc(100vw - 20px)); max-height: calc(100dvh - 115px); overflow-y: auto; }
.gif-picker:not(.is-hidden) { display: flex; flex-direction: column; overflow: hidden; }
.media-picker-tabs { display: flex; gap: 8px; align-items: center; padding: 16px 16px 4px; }
.media-picker-tabs button { min-height: 38px; padding: 8px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 650; }
.media-picker-tabs button:hover { color: var(--text); background: var(--hover); }
.media-picker-tabs button.is-active { background: var(--panel-3); color: var(--text); }
.gif-picker .picker-head, .emoji-picker .picker-head { position: relative; padding: 10px 16px 14px; gap: 8px; }
.gif-search-wrap { position: relative; display: flex; flex: 1; min-width: 0; align-items: center; }
.gif-picker .picker-head .ico { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.gif-picker .picker-head input, .emoji-picker .picker-head input { min-height: 44px; border-radius: 8px; font-size: 14px; }
.gif-picker .picker-head input { width: 100%; padding-left: 38px; }
.gif-picker .picker-head .mini, .emoji-picker .picker-head .mini { width: 30px; height: 30px; }
.gif-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 14px 0; border: 0; }
.gif-tab { position: relative; overflow: hidden; min-height: 96px; justify-content: center; gap: 7px; padding: 12px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel-3); color: var(--text); font-size: 14px; font-weight: 700; text-transform: none; }
.gif-tile-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.4); }
.gif-tab.is-active .gif-tile-image { opacity: .42; }
.gif-tile-title { position: relative; z-index: 1; }
.gif-tab:hover { border-color: var(--text-2); background: var(--hover); }
.gif-tab.is-active { border-color: var(--focus-ring); background: var(--accent); color: #fff; }
.gif-tab-count, .gif-tab.is-active .gif-tab-count { padding: 1px 6px; border: 0; border-radius: 10px; background: rgba(0,0,0,.25); color: #fff; font-size: 11px; }
.gif-scroll { flex: 0 1 min(370px, 44dvh); min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.gif-grid { position: relative; isolation: isolate; grid-auto-rows: max-content; gap: 10px; height: auto; overflow: visible; padding: 10px 14px 14px; }
.gif-back { flex: none; width: 32px; height: 38px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-size: 20px; }
.gif-back:hover { background: var(--hover); color: var(--text); }
.gif-category { position: relative; overflow: hidden; min-width: 0; aspect-ratio: 2 / 1; padding: 12px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel-3); color: var(--text); font-size: 14px; font-weight: 700; }
.gif-category img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.38); }
.gif-category span { position: relative; color: inherit; }
.gif-category:hover { background: var(--hover); border-color: var(--text-2); }
.gif-cell { min-width: 0; aspect-ratio: 2 / 1; border-radius: 7px; }
.gif-send { display: block; position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; overflow: hidden; }
.gif-cell .gif-label { left: 0; right: 0; bottom: 0; max-width: 100%; padding: 18px 10px 8px; background: linear-gradient(transparent, rgba(0,0,0,.82)); font-size: 12px; text-align: left; }
.gif-fav { top: 7px; right: 7px; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px; font-size: 17px; opacity: .85; }
.gif-fav:focus-visible { opacity: 1; outline: 2px solid white; outline-offset: -2px; }
.gif-empty { font-size: 13px; }
.gif-url-row { padding: 10px 14px; }
.gif-url-row input { min-height: 38px; font-size: 13px; }
.gif-foot { padding: 0 14px 10px; font-size: 10px; }
.emoji-grid { height: min(300px, 38dvh); }
@media (max-width: 620px) {
  .gif-picker, .emoji-picker { bottom: 92px; max-height: calc(100dvh - 100px); }
  .media-picker-tabs { padding: 10px 10px 2px; }
  .gif-picker .picker-head, .emoji-picker .picker-head { padding: 8px 10px 10px; }
  .gif-tabs { gap: 7px; padding: 10px 10px 0; }
  .gif-tab { min-height: 66px; }
  .gif-scroll { flex-basis: min(300px, 36dvh); }
  .gif-grid { gap: 7px; padding: 8px 10px; }
}
