/* QuickChat — layout and components */

.hidden { display: none !important; }
/* !important because component rules like .iconbtn set their own display and,
   at equal specificity, win on source order — which left the mobile drawer
   toggle visible (and inert) on desktop. The matching rule in the ≤820px
   media query is !important for the same reason. */
.mobile-only { display: none !important; }

/* ================= App frame ================= */

#app {
  display: grid;
  grid-template-columns: var(--nav-w) var(--side-w) 1fr auto;
  height: 100dvh;
  overflow: hidden;
}

/* ================= Far-left nav rail ================= */

.rail-nav {
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail-nav::-webkit-scrollbar { display: none; }

.rail-nav__logo {
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-lg);
  border: none;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 700;
  font-size: var(--t-lg);
  transition: border-radius .15s, background .15s;
}
.rail-nav__logo:hover { border-radius: var(--r); background: var(--accent); }
/* When Main has an icon the logo becomes the image, so it must clip to the
   rounded corners and drop the accent fill that would frame a transparent PNG. */
.rail-nav__logo { overflow: hidden; padding: 0; }
.rail-nav__logo.has-icon { background: var(--bg-raise); }

.rail-nav__sep {
  width: 2rem;
  height: 2px;
  background: var(--line);
  border-radius: var(--r-full);
  margin: var(--s1) 0;
}

.rail-nav__spacer { flex: 1; }

.rail-nav__btn {
  position: relative;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--r-lg);
  background: var(--bg-side);
  color: var(--ink-soft);
  transition: border-radius .15s, background .15s, color .15s;
}
.rail-nav__btn:hover { border-radius: var(--r); background: var(--accent-strong); color: #fff; }
.rail-nav__btn.is-active { border-radius: var(--r); background: var(--positive); color: #fff; }
.rail-nav__btn--alert:hover { background: var(--danger); }

.rail-nav__badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 .25rem;
  border-radius: var(--r-full);
  background: var(--danger);
  border: 3px solid var(--bg-deep);
  color: #fff;
  font-size: var(--t-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
  box-sizing: content-box;
}

/* ================= Sidebar ================= */

.sidebar {
  background: var(--bg-side);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar__head {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--bg-deep);
  box-shadow: var(--shadow-sm);
  color: var(--ink-soft);
  flex: none;
}
.sidebar__title {
  flex: 1;
  font-weight: 600;
  font-size: var(--t-md);
  color: var(--ink);
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Server banner, above the channel list. Height and hidden-state are the
   whole story: hidden collapses to nothing, so clearing it gives back
   exactly the old layout rather than leaving a gap. */
.sidebar__banner {
  height: 6.5rem;
  flex: none;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--bg-deep);
}

.sidebar__scroll { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2); min-height: 0; }

.sidebar__group { margin-bottom: var(--s4); }
.sidebar__label {
  padding: 0 var(--s2) var(--s1);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Server code card */
.servercard {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s2) var(--s3);
  margin-bottom: var(--s4);
}
.servercard__label {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  font-weight: 700;
}
.servercard__row { display: flex; align-items: center; gap: var(--s1); margin-top: 2px; }
.servercard__value {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--t-lg);
  font-weight: 700;
  color: var(--accent-bright);
  letter-spacing: .03em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.servercard__value.is-empty { color: var(--ink-dim); font-weight: 400; font-size: var(--t-sm); }
.servercard__meta { font-size: var(--t-xs); color: var(--ink-faint); }

/* Channels */
.channel {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: .4rem var(--s2);
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink-faint);
  font-size: var(--t-md);
  font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
}
.channel:hover { background: var(--bg-hover); color: var(--ink-soft); }
.channel.is-active { background: var(--bg-active); color: var(--ink); }
.channel.is-muted { opacity: .45; }
.channel.is-muted:hover { opacity: .7; }
.channel span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Emoji channel icon, standing in for the hash/volume glyph. Sized and
   centred to roughly match the 18px stroke icon it replaces. */
.channel__emoji { flex: none; font-size: 1.05rem; line-height: 1; width: 18px; text-align: center; }
.channel__count {
  flex: none !important;
  font-size: var(--t-xs);
  font-weight: 700;
  color: var(--positive);
}

/* Unread badges — a small pill per channel row, and one on each server tile */
.channel__unread {
  flex: none !important;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 .3rem;
  border-radius: var(--r-full);
  background: var(--danger);
  color: #fff;
  font-size: var(--t-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
  box-sizing: content-box;
}
.serverbtn__badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 .25rem;
  border-radius: var(--r-full);
  background: var(--danger);
  border: 3px solid var(--bg-deep);
  color: #fff;
  font-size: var(--t-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
  box-sizing: content-box;
}

/* Voice participants under the voice channel */
.voicelist { padding-left: var(--s4); }
.voiceuser {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .2rem var(--s2);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--ink-soft);
}
.voiceuser__main { display: flex; align-items: center; gap: var(--s2); }
.voiceuser:hover { background: var(--bg-hover); }
.voiceuser__avatar {
  width: 1.5rem; height: 1.5rem;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--bg-raise);
  border: 2px solid transparent;
  transition: border-color .12s;
}
.voiceuser.is-speaking .voiceuser__avatar { border-color: var(--positive); }
.voiceuser__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voiceuser__state { color: var(--ink-dim); font-size: var(--t-xs); }
.voiceuser.is-failed .voiceuser__state { color: var(--danger); }
.voiceuser__mute { color: var(--danger); display: flex; }

/* Per-person listening volume. Indented to line up under the name, not the avatar. */
.voiceuser__vol {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding-left: calc(1.5rem + var(--s2));
}
.voiceuser__volbtn {
  display: flex;
  border: none;
  background: none;
  padding: 0;
  color: var(--ink-faint);
  cursor: pointer;
  flex: none;
}
.voiceuser__volbtn:hover { color: var(--ink-soft); }
/* A tick at the midpoint, which is normal volume: left quietens, right boosts.
   Drawn on the wrapper rather than the input so it survives the browser's
   native slider rendering. */
.voiceuser__slidewrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}
.voiceuser__slidewrap::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: .5rem;
  margin-top: -.25rem;
  background: var(--ink-faint);
  opacity: .5;
  pointer-events: none;
}
.voiceuser__slider {
  flex: 1;
  min-width: 0;
  height: 1rem;
  cursor: pointer;
  /* Native slider, themed. Avoids the cross-browser thumb/track rewrite,
     which needs three vendor-specific rule sets to look consistent. */
  accent-color: var(--accent-bright);
}
/* Above normal is worth flagging — it is the setting most likely to distort. */
.voiceuser__vol.is-boosted .voiceuser__slider { accent-color: var(--positive); }
.voiceuser__vol.is-boosted .voiceuser__volbtn { color: var(--positive); }

/* Voice control dock */
.voicedock {
  margin-top: var(--s2);
  padding: var(--s2);
  background: var(--bg-input);
  border-radius: var(--r);
  border: 1px solid var(--line);
}
.voicedock__status {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--positive);
  margin-bottom: var(--s2);
}
.voicedock__actions { display: flex; gap: var(--s1); }
.voicedock__actions .btn { flex: 1; }

/* Pinned list */
.pinitem {
  display: flex;
  align-items: flex-start;
  gap: var(--s1);
  padding: var(--s1) var(--s2);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--ink-soft);
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}
.pinitem:hover { background: var(--bg-hover); color: var(--ink); }
.pinitem__text {
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pinitem__who { font-weight: 600; color: var(--ink); }

/* Bottom user bar */
.userbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2);
  background: var(--bg-deep);
}
.userbar__avatar-wrap { position: relative; flex: none; }
.userbar__avatar {
  width: 2rem; height: 2rem;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--bg-raise);
  display: block;
}
.userbar__info { flex: 1; min-width: 0; line-height: 1.2; display: flex; flex-direction: column; }
.userbar__name {
  font-size: var(--t-sm);
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.userbar__sub {
  font-size: var(--t-xs);
  color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ================= Main column ================= */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-main); }

.topbar {
  height: var(--top-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--bg-deep);
  box-shadow: var(--shadow-sm);
  z-index: 2;
}
.topbar__server { color: var(--ink-faint); font-weight: 600; font-size: var(--t-sm); }
.topbar__server:empty { display: none; }
.topbar__hash { color: var(--ink-faint); }
.topbar__emoji { font-size: 1.1rem; line-height: 1; }
.topbar__name { font-weight: 600; letter-spacing: -.01em; }
.topbar__divider { width: 1px; height: 1.4rem; background: var(--line); margin: 0 var(--s1); }
.topbar__topic {
  flex: 1;
  min-width: 0;
  font-size: var(--t-sm);
  color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__actions { display: flex; gap: var(--s1); flex: none; margin-left: auto; }

.content { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ================= Buttons ================= */

.iconbtn {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink-faint);
  transition: background .12s, color .12s;
}
.iconbtn:hover { background: var(--bg-hover); color: var(--ink); }
.iconbtn.is-active { color: var(--accent-bright); }
.iconbtn--sm { width: 1.5rem; height: 1.5rem; }
.iconbtn--danger:hover { background: var(--danger-wash); color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  padding: .5rem .9rem;
  border: none;
  border-radius: var(--r-sm);
  background: var(--bg-raise);
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 600;
  transition: background .12s, opacity .12s;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--accent { background: var(--accent-strong); color: #fff; }
.btn--accent:hover { background: var(--accent); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #c0403c; }
.btn--ghost { background: none; color: var(--ink-soft); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn--sm { padding: .3rem .6rem; font-size: var(--t-xs); }
.btn--block { width: 100%; }

/* ================= Messages ================= */

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s4) 0 var(--s2);
  display: flex;
  flex-direction: column;
}
/* Growing spacer that pins a short conversation to the bottom of the column and
   collapses to nothing once the messages overflow. Doing it this way rather than
   with justify-content:flex-end keeps the scroll container scrollable to the top. */
.messages::before { content: ""; flex: 1 1 auto; min-height: 0; }

.msg {
  position: relative;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  column-gap: var(--s3);
  padding: .1rem var(--s4) .1rem var(--s3);
}
.msg:hover { background: rgba(255, 255, 255, .022); }
.msg.is-mention { background: rgba(126, 168, 212, .09); box-shadow: inset 2px 0 0 var(--accent); }
.msg.is-mention:hover { background: rgba(126, 168, 212, .14); }
.msg--lead { margin-top: var(--s3); padding-top: .15rem; }

.msg__avatar {
  grid-column: 1;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--bg-raise);
  margin-top: .15rem;
  cursor: pointer;
}
.msg__gutter {
  grid-column: 1;
  align-self: start;
  font-size: var(--t-xs);
  font-family: var(--font-mono);
  color: var(--ink-dim);
  text-align: right;
  padding-top: .22rem;
  visibility: hidden;
}
.msg:hover .msg__gutter { visibility: visible; }

.msg__body { grid-column: 2; min-width: 0; }

.msg__head { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; margin-bottom: 1px; }
.msg__name { font-weight: 600; color: var(--ink); font-size: var(--t-md); cursor: pointer; }
.msg__name--accent { color: var(--accent-bright); }
.msg__badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 1px .3rem;
  border-radius: var(--r-sm);
  background: var(--accent-strong);
  color: #fff;
}
.msg__badge--admin { background: var(--danger); }
.msg__time { font-size: var(--t-xs); color: var(--ink-dim); font-weight: 500; }

.msg__reply-ref {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-size: var(--t-sm);
  color: var(--ink-faint);
  margin-bottom: 2px;
  cursor: pointer;
  min-width: 0;
  padding-left: 1.2rem;
  position: relative;
}
.msg__reply-ref::before {
  content: "";
  position: absolute;
  left: 0; top: 50%; bottom: -2px;
  width: .9rem;
  border-left: 2px solid var(--line);
  border-top: 2px solid var(--line);
  border-top-left-radius: 6px;
}
.msg__reply-ref:hover { color: var(--ink-soft); }
.msg__reply-ref:hover::before { border-color: var(--ink-dim); }
.msg__reply-who { font-weight: 600; color: var(--accent-bright); flex: none; }
.msg__reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg__text { color: var(--ink-soft); word-wrap: break-word; overflow-wrap: anywhere; }
.msg__text a { color: var(--accent-bright); text-decoration: none; }
.msg__text a:hover { text-decoration: underline; }
.msg__text code {
  font-family: var(--font-mono);
  font-size: .87em;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .1em .3em;
}
.msg__text pre {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s3);
  margin: var(--s1) 0;
  overflow-x: auto;
  color: var(--ink-soft);
}
.msg__text pre code { background: none; border: none; padding: 0; }
.msg__text blockquote {
  margin: 2px 0;
  padding-left: var(--s3);
  border-left: 4px solid var(--line);
  color: var(--ink-soft);
}
.msg__mention {
  background: rgba(126, 168, 212, .15);
  color: var(--accent-bright);
  border-radius: var(--r-sm);
  padding: 0 2px;
  font-weight: 500;
}
.msg__spoiler {
  background: var(--bg-active);
  color: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.msg__spoiler.is-revealed { background: var(--bg-raise); color: var(--ink-soft); }
.msg__edited { font-size: var(--t-xs); color: var(--ink-dim); margin-left: 3px; }

.msg__image {
  display: block;
  max-width: min(440px, 100%);
  max-height: 340px;
  margin-top: var(--s1);
  border-radius: var(--r);
  cursor: zoom-in;
  background: var(--bg-input);
}

.tok-kw  { color: #c191d6; }
.tok-str { color: #93c88a; }
.tok-num { color: #dbab5e; }
.tok-com { color: var(--ink-dim); font-style: italic; }
.tok-fn  { color: var(--accent-bright); }

/* Hover toolbar */
.msg__actions {
  position: absolute;
  top: -1rem;
  right: var(--s4);
  display: none;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  z-index: 3;
}
.msg:hover .msg__actions { display: flex; }
.msg__action {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 1.9rem;
  border: none;
  background: none;
  color: var(--ink-faint);
}
.msg__action:hover { background: var(--bg-hover); color: var(--ink); }
.msg__action--danger:hover { background: var(--danger-wash); color: var(--danger); }

/* Reactions */
.msg__reactions { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s1); }
.reaction {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding: 1px .4rem;
  min-height: 1.4rem;
  background: var(--bg-raise);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  line-height: 1.3;
}
.reaction:hover { border-color: var(--ink-dim); }
.reaction.is-mine { background: rgba(126, 168, 212, .16); border-color: var(--accent-strong); }
.reaction__count { font-size: var(--t-xs); font-weight: 600; color: var(--ink-soft); }
.reaction.is-mine .reaction__count { color: var(--accent-bright); }

/* Day divider */
.daydivider {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s4) var(--s4) var(--s2) var(--s3);
  font-size: var(--t-xs);
  font-weight: 700;
  color: var(--ink-faint);
}
.daydivider::before, .daydivider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Empty state */
.empty {
  margin: auto;
  text-align: center;
  padding: var(--s6);
  max-width: 30rem;
}
.empty__icon {
  width: 4.5rem; height: 4.5rem;
  border-radius: var(--r-full);
  background: var(--bg-raise);
  color: var(--ink-faint);
  display: grid; place-items: center;
  margin: 0 auto var(--s3);
}
.empty h2 { font-size: var(--t-xl); margin: 0 0 var(--s1); letter-spacing: -.02em; }
.empty p { margin: 0; color: var(--ink-faint); font-size: var(--t-sm); }

/* ================= Poll ================= */

.poll {
  margin-top: var(--s2);
  padding: var(--s3);
  background: var(--bg-raise);
  border-left: 3px solid var(--accent-strong);
  border-radius: var(--r-sm);
  max-width: 27rem;
}
.poll__q { font-weight: 600; color: var(--ink); }
.poll__meta { font-size: var(--t-xs); color: var(--ink-faint); margin-bottom: var(--s2); }
.poll__opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: .4rem var(--s2);
  margin-bottom: var(--s1);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-align: left;
  overflow: hidden;
  color: var(--ink-soft);
}
.poll__opt:not(:disabled):hover { border-color: var(--accent-strong); color: var(--ink); }
.poll__opt.is-mine { border-color: var(--accent); }
.poll__opt:disabled { cursor: default; }
.poll__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(126, 168, 212, .18);
  transition: width .35s ease;
}
.poll__opt-label, .poll__opt-count { position: relative; font-size: var(--t-sm); }
.poll__opt-label { flex: 1; }
.poll__opt-count { color: var(--ink-faint); font-family: var(--font-mono); font-size: var(--t-xs); }
.poll__closed { color: var(--warning); font-weight: 600; }

/* ================= Typing ================= */

.typing {
  height: 1.5rem;
  padding: 0 var(--s4);
  font-size: var(--t-xs);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}
.typing__dots { display: inline-flex; gap: 2px; }
.typing__dots span {
  width: 4px; height: 4px;
  border-radius: var(--r-full);
  background: var(--ink-faint);
  animation: bounce 1.3s infinite;
}
.typing__dots span:nth-child(2) { animation-delay: .18s; }
.typing__dots span:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* ================= Composer ================= */

.composer { flex: none; padding: 0 var(--s4) var(--s3); }

.composer__banner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: .35rem var(--s3);
  background: var(--bg-raise);
  border-radius: var(--r) var(--r) 0 0;
  font-size: var(--t-sm);
  color: var(--ink-faint);
}
.composer__banner-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.composer__attachment {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  background: var(--bg-raise);
  border-radius: var(--r) var(--r) 0 0;
  border-bottom: 1px solid var(--bg-deep);
}
.composer__attachment img { height: 3.5rem; border-radius: var(--r-sm); }
.composer__attachment-meta { flex: 1; font-size: var(--t-xs); color: var(--ink-faint); }

.filechip {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--bg-raise);
  border-radius: var(--r-sm);
  max-width: min(320px, 100%);
}
.filechip__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.filechip__name {
  font-size: var(--t-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filechip__size { font-size: var(--t-xs); color: var(--ink-faint); }
.filechip__dl {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.8rem; height: 1.8rem;
  border-radius: var(--r-full);
  color: var(--ink-faint);
}
.filechip__dl:hover { background: var(--bg-input); color: var(--ink); }

.msg__body .filechip { margin-top: var(--s1); }

/* ================= Link embeds (Task B2) ================= */
/* Up to 3 per message, stacked; each is its own card so a dead thumbnail or
   favicon (hideOnError in js/embeds.js) only ever collapses its own card. */
.embeds {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-top: var(--s1);
  max-width: min(400px, 100%);
}

.embed {
  display: block;
  border-radius: var(--r-sm);
  background: var(--bg-raise);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

/* youtube / vimeo: 16:9 thumbnail with a centred play control. No <iframe>
   exists until the thumbnail is clicked — js/embeds.js only creates one
   inside the click handler, so nothing here ever autoplays unattended. */
.embed__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: var(--bg-deep);
  cursor: pointer;
}
.embed__thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.embed__placeholder {
  font-size: var(--t-sm);
  color: var(--ink-faint);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.embed__play {
  position: relative;
  z-index: 1;
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-full);
  background: color-mix(in srgb, #000 55%, transparent);
  display: grid;
  place-items: center;
}
.embed__play::after {
  content: "";
  display: block;
  margin-left: 3px;
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent #fff;
}
.embed__thumb:hover .embed__play { background: color-mix(in srgb, #000 70%, transparent); }
.embed__iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.embed--image .embed__media-img,
.embed--video .embed__media-video {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: var(--bg-deep);
  cursor: pointer;
}
.embed--video .embed__media-video { cursor: auto; }

/* generic link chip: favicon + hostname/path */
.embed--link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
}
.embed--link:hover { background: var(--bg-hover); }
.embed__favicon { width: 20px; height: 20px; border-radius: var(--r-sm); flex: none; }
.embed__link-text { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.embed__link-host { font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.embed__link-path { font-size: var(--t-xs); color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.composer__box {
  display: flex;
  align-items: flex-end;
  gap: var(--s1);
  background: var(--bg-raise);
  border-radius: var(--r);
  padding: 0 var(--s2);
}
.composer__box.is-drop { outline: 2px dashed var(--accent); outline-offset: -2px; }

.composer__attach {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.6rem; height: 1.6rem;
  margin-bottom: .65rem;
  border: none;
  border-radius: var(--r-full);
  background: var(--ink-faint);
  color: var(--bg-raise);
  transition: background .12s;
}
.composer__attach:hover { background: var(--ink); }
.composer__attach:disabled { opacity: .4; cursor: not-allowed; }

.composer__input {
  flex: 1;
  background: none;
  border: none;
  resize: none;
  outline: none;
  padding: .7rem var(--s1);
  max-height: 11rem;
  line-height: 1.4;
  font-family: inherit;
  color: var(--ink);
}
.composer__input::placeholder { color: var(--ink-dim); }

.composer__act {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  margin-bottom: .45rem;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink-faint);
}
.composer__act:hover { color: var(--ink); }
.composer__act--send { color: var(--accent); }
.composer__act--send:hover { color: var(--accent-bright); background: var(--bg-hover); }

.composer__locked {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3);
  background: var(--bg-raise);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--ink-soft);
}
.composer__locked strong { color: var(--ink); }
.composer__countdown { font-family: var(--font-mono); color: var(--danger); font-weight: 700; }

.composer__hint {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s1) var(--s1) 0;
  font-size: var(--t-xs);
  color: var(--ink-dim);
}

/* ================= Member rail ================= */

.rail {
  width: var(--rail-w);
  background: var(--bg-side);
  overflow-y: auto;
  padding: var(--s3) var(--s2);
  min-height: 0;
}

/* Toggled off from the members button on wide screens. */
.rail.is-hidden-wide { display: none; }

.rail__group { margin-bottom: var(--s4); }
.rail__label {
  padding: 0 var(--s2) var(--s1);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.member {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: .3rem var(--s2);
  border: none;
  border-radius: var(--r-sm);
  background: none;
  text-align: left;
}
.member:hover { background: var(--bg-hover); }
.member--offline { opacity: .42; }
.member__avatar-wrap { position: relative; flex: none; }
.member__avatar {
  width: 2rem; height: 2rem;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--bg-raise);
  display: block;
  cursor: pointer;
}
.member__dot {
  position: absolute;
  right: -2px; bottom: -2px;
  width: .7rem; height: .7rem;
  border-radius: var(--r-full);
  border: 3px solid var(--bg-side);
  background: var(--state-offline);
  box-sizing: content-box;
}
.member__dot--online { background: var(--state-online); }
.member__dot--away { background: var(--state-away); }
.member__info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.member__name {
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.member__name--accent { color: var(--accent-bright); }
.member__title {
  font-size: var(--t-xs);
  color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.member__flags { flex: none; display: flex; gap: 2px; color: var(--ink-dim); }

/* ================= Gate ================= */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: safe center;
  overflow-y: auto;
  background:
    radial-gradient(1100px 500px at 50% -10%, #22303d 0%, transparent 60%),
    var(--bg-deep);
  padding: var(--s4);
  z-index: 100;
}
.gate__card {
  width: min(25rem, 100%);
  background: var(--bg-main);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--s5);
  text-align: center;
}
.gate__brand { margin-bottom: var(--s3); }
.gate__logo {
  display: inline-grid;
  place-items: center;
  width: 3.25rem; height: 3.25rem;
  border-radius: var(--r-lg);
  background: var(--accent-strong);
  color: #fff;
  font-size: var(--t-xl);
  font-weight: 700;
}
.gate__title { font-size: var(--t-xl); margin: 0 0 var(--s1); letter-spacing: -.02em; }
.gate__sub { color: var(--ink-faint); font-size: var(--t-sm); margin: 0 0 var(--s4); }
.gate__form { display: flex; flex-direction: column; gap: var(--s1); text-align: left; }
.gate__form .field__label { margin-top: var(--s2); }
.gate__form .btn { margin-top: var(--s3); }
.gate__note { font-size: var(--t-sm); color: var(--ink-faint); margin: var(--s3) 0 0; }
.gate__note--warn { color: var(--warning); font-size: var(--t-xs); }
.gate__link {
  background: none; border: none; padding: 0;
  color: var(--accent); font: inherit; font-size: inherit;
}
.gate__link:hover { text-decoration: underline; }
.gate__msg {
  margin-top: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  text-align: left;
}
.gate__msg--ok { background: rgba(67, 181, 129, .12); color: #7fd3ac; }
.gate__msg--err { background: var(--danger-wash); color: #e8938f; }
#pending .btn { margin-top: var(--s4); }

/* ================= Inputs ================= */

.input {
  width: 100%;
  padding: .6rem var(--s3);
  background: var(--bg-input);
  border: 1px solid var(--bg-deep);
  border-radius: var(--r-sm);
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--accent-strong); }
.input::placeholder { color: var(--ink-dim); }

.field { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s3); }
.field__label {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field__hint { font-size: var(--t-xs); color: var(--ink-faint); }

/* ================= Modal ================= */

.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .75);
  display: grid;
  place-items: center;
  align-content: safe center;
  overflow-y: auto;
  padding: var(--s4);
  z-index: 200;
}
.modal {
  width: min(32rem, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--bg-main);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--s4);
  animation: modal-in .15s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.modal--wide { width: min(46rem, 100%); }
.modal__head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.modal__title { font-size: var(--t-lg); font-weight: 600; margin: 0; flex: 1; letter-spacing: -.01em; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }
.modal__section { border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s3); }
.modal__section-title {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: var(--s2);
}

/* Invite landing screen splash: the server's chosen image behind the "Welcome
   to X" heading, on the successful-join path only. Negative margins pull it
   flush to the modal's own padding so the image reaches the edges. */
.joinsplash {
  margin: calc(var(--s4) * -1) calc(var(--s4) * -1) 0;
  padding: var(--s4);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background-size: cover;
  background-position: center;
}
.joinsplash .modal__title { color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

.notice__kicker {
  display: flex; align-items: center; gap: var(--s1);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: var(--s1);
}
.notice--warn .notice__kicker { color: var(--warning); }
.notice--alert .notice__kicker { color: var(--danger); }
.notice__body { font-size: var(--t-lg); line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice__from { font-size: var(--t-xs); color: var(--ink-faint); margin-top: var(--s3); }

.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .9);
  display: grid; place-items: center;
  z-index: 300; cursor: zoom-out; padding: var(--s4);
}
.lightbox img { max-width: 100%; max-height: 92dvh; border-radius: var(--r); }

/* Emoji picker */
.emojipop {
  position: fixed;
  z-index: 250;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: var(--s2);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.emojipop button {
  width: 2rem; height: 2rem;
  border: none; background: none;
  border-radius: var(--r-sm);
  font-size: 1.15rem;
  line-height: 1;
}
.emojipop button:hover { background: var(--bg-hover); }

/* ================= Toasts ================= */

.toasts {
  position: fixed;
  bottom: var(--s4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  align-items: center;
  z-index: 400;
  pointer-events: none;
  max-width: min(30rem, 92vw);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--bg-raise);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  font-size: var(--t-sm);
  animation: toast-in .16s ease-out;
}
.toast--err { background: var(--danger-wash); color: #e8938f; box-shadow: var(--shadow), inset 3px 0 0 var(--danger); }
.toast--ok { box-shadow: var(--shadow), inset 3px 0 0 var(--positive); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ================= Admin ================= */

.admin-user {
  border-radius: var(--r);
  padding: var(--s3);
  margin-bottom: var(--s2);
  background: var(--bg-raise);
}
.admin-user--pending { box-shadow: inset 3px 0 0 var(--warning); }
.admin-user__head { display: flex; align-items: center; gap: var(--s2); }
.admin-user__head .member__avatar { width: 2.25rem; height: 2.25rem; }
.admin-user__name { flex: 1; min-width: 0; font-weight: 600; }
.admin-user__email { font-size: var(--t-xs); color: var(--ink-faint); font-family: var(--font-mono); }
.admin-user__actions { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 2px; margin-top: var(--s2); }
.perm {
  display: flex; align-items: center; gap: var(--s1);
  font-size: var(--t-xs); padding: .25rem var(--s1);
  border-radius: var(--r-sm); color: var(--ink-soft);
  cursor: pointer;
}
.perm:hover { background: var(--bg-hover); }
.perm input { accent-color: var(--accent-strong); margin: 0; }
.perm.is-off { color: var(--ink-dim); }

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--t-xs); font-weight: 600;
  padding: 1px .35rem; border-radius: var(--r-sm);
}
.badge--admin { background: var(--danger); color: #fff; }
.badge--owner { background: var(--warning); color: #241a05; }
.badge--timeout { background: var(--bg-active); color: var(--warning); }
.badge--banned { background: var(--bg-active); color: var(--ink-faint); }

.avatar-edit { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.avatar-edit img {
  width: 4.5rem; height: 4.5rem;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--bg-raise);
}

.scrim { display: none; }

/* ================= Responsive ================= */

@media (max-width: 1100px) {
  .rail { display: none; }
  .rail.is-open {
    display: block;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 150;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 820px) {
  .mobile-only { display: grid !important; }
  #app { grid-template-columns: 1fr; }

  .rail-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 160;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .sidebar {
    position: fixed;
    top: 0; left: var(--nav-w); bottom: 0;
    width: var(--side-w);
    z-index: 155;
    transform: translateX(calc(-100% - var(--nav-w)));
    transition: transform .18s ease;
  }
  #app.nav-open .rail-nav,
  #app.nav-open .sidebar { transform: none; }
  #app.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 140;
  }

  .msg { padding-inline: var(--s2) var(--s3); grid-template-columns: 2.25rem 1fr; column-gap: var(--s2); }
  .msg__avatar { width: 2.25rem; height: 2.25rem; }
  .composer { padding-inline: var(--s3); }
  .msg__actions { right: var(--s3); }
  .topbar__topic { display: none; }
}

/* Touch devices have no persistent :hover, so anything that only appears on
   hover is otherwise permanently unreachable — message actions (reply, react,
   edit, delete, pin) and channel rename/delete tools both used to be invisible
   on phones. Also enlarge icon-only buttons toward a comfortable ~44px tap
   target without changing their mouse-driven desktop sizing. */
@media (hover: none) {
  .msg__actions { display: flex; }
  .channel__tools { display: flex; }

  .iconbtn { width: 2.5rem; height: 2.5rem; }
  .iconbtn--sm { width: 2rem; height: 2rem; }
  .msg__action { width: 2.5rem; height: 2.4rem; }
  .sharetile__mute { padding: .4rem; }
}

/* Channel rows: rename/delete tools appear on hover for admins */
.sidebar__label { display: flex; align-items: center; justify-content: space-between; gap: var(--s1); }
.sidebar__label .iconbtn { color: var(--ink-faint); }

.channel { position: relative; }
.channel__tools { display: none; gap: 2px; flex: none; }
.channel:hover .channel__tools { display: flex; }
.channel__tools .iconbtn { color: var(--ink-faint); }
.channel__tools .iconbtn:hover { color: var(--ink); background: var(--bg-active); }

/* Inline composer error — a toast alone is too easy to miss */
.composer__error {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  margin-bottom: 2px;
  background: var(--danger-wash);
  border-radius: var(--r) var(--r) 0 0;
  color: #e8938f;
  font-size: var(--t-sm);
}

/* Screen-share dock */
.sharedock { margin-top: var(--s2); display: flex; flex-direction: column; gap: var(--s2); }
.sharedock__grid { display: flex; flex-wrap: wrap; gap: var(--s2); }
.sharetile {
  position: relative;
  width: 6.5rem;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #000;
  cursor: pointer;
  border: 1px solid var(--line);
}
.sharetile video { width: 100%; height: 3.6rem; object-fit: cover; display: block; }
.sharetile__label {
  font-size: var(--t-xs);
  color: var(--ink-soft);
  padding: .15rem .35rem;
  background: var(--bg-input);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sharetile__mute {
  position: absolute; top: .2rem; right: .2rem;
  background: rgba(0, 0, 0, .55);
  border: none;
  border-radius: var(--r-full);
  padding: .2rem;
  display: flex;
  color: #fff;
  cursor: pointer;
}
.sharetile__mute:hover { background: rgba(0, 0, 0, .8); }

/* Fullscreen screen-share viewer */
.share-fullscreen {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 300;
  display: flex;
  flex-direction: column;
}
.share-fullscreen video { flex: 1; width: 100%; min-height: 0; object-fit: contain; }
.share-fullscreen__bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); color: #fff; }
.share-fullscreen__bar span { flex: 1; font-size: var(--t-sm); }
.share-fullscreen__bar .iconbtn { color: #fff; }

/* ================= Server rail ================= */

.rail-nav__servers { display: flex; flex-direction: column; gap: var(--s1); align-items: center; }
.serverbtn {
  position: relative;
  width: 2.6rem; height: 2.6rem;
  border: none;
  border-radius: var(--r);
  background: var(--bg-raise);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: var(--t-md);
  cursor: pointer;
  overflow: hidden;
  transition: border-radius .12s, background .12s, color .12s;
}
.serverbtn:hover { border-radius: var(--r-sm); background: var(--accent); color: #fff; }
.serverbtn.is-active { background: var(--accent-strong); color: #fff; border-radius: var(--r-sm); }
.serverbtn__icon { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-nav__btn--add { font-size: 1.3rem; line-height: 1; }
/* The logo is Main's server button, so it takes the same active treatment. */
.rail-nav__logo.is-active { border-radius: var(--r); background: var(--positive); color: #fff; }

/* Colour swatches for a server with no icon */
.swatches { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s3) 0; }
.swatch {
  width: 2.4rem; height: 2.4rem;
  border: 2px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
}
.swatch:hover { border-color: var(--ink-faint); }
.swatch.is-active { border-color: var(--ink); }

/* ================= Image positioner ================= */

.cropper__stage {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--bg-deep);
  cursor: grab;
  touch-action: none;   /* let the drag handler own the gesture, not the page */
  user-select: none;
}
.cropper__stage.is-round { border-radius: var(--r-full); }
.cropper__stage:active { cursor: grabbing; }
.cropper__img {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  max-width: none;      /* beats the global img rule, which would cap the zoom */
  pointer-events: none;
}
.cropper__controls {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s3);
}
.cropper__zoom { flex: 1; min-width: 0; accent-color: var(--accent-bright); }

/* ================= Server options menu ================= */

.menupop {
  position: fixed;
  z-index: 350;
  min-width: 12rem;
  padding: var(--s1);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menupop__item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: var(--s2);
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink-soft);
  font-size: var(--t-sm);
  text-align: left;
  cursor: pointer;
}
.menupop__item:hover { background: var(--bg-hover); color: var(--ink); }
.menupop__item.is-danger { color: var(--danger); }
.menupop__item.is-danger:hover { background: var(--danger-wash); }
.menupop__item.is-active { color: var(--accent-bright); }
.menupop__item > span { flex: 1; }
.menupop__item svg { flex: none; }

/* ================= User profile card ================= */

.usercard {
  width: 17rem;
  padding: var(--s3);
  gap: var(--s3);
}
.usercard__head { display: flex; align-items: center; gap: var(--s2); }
.usercard__avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--bg-raise);
  flex: none;
}
.usercard__id { min-width: 0; }
.usercard__name {
  font-size: var(--t-lg);
  font-weight: 700;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.usercard__title { font-size: var(--t-xs); color: var(--ink-faint); margin-top: 2px; }
.usercard__roles { display: flex; flex-wrap: wrap; gap: var(--s1); }
.usercard__chip {
  padding: 2px var(--s2);
  border: 1px solid;
  border-radius: var(--r-full);
  font-size: var(--t-xs);
  font-weight: 600;
}
.usercard__about {
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
  font-size: var(--t-sm);
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.usercard__about p { margin: 0; }
.usercard__message { align-self: flex-start; }

/* ================= Channel categories ================= */

.catrow {
  display: flex;
  align-items: center;
  gap: var(--s1);
  width: 100%;
  padding: var(--s1) var(--s2);
  margin-top: var(--s2);
  border: none;
  background: none;
  color: var(--ink-faint);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}
.catrow:hover { color: var(--ink-soft); }
.catrow span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow i, .catrow svg { transition: transform .12s; flex: none; }
.catrow.is-collapsed svg { transform: rotate(-90deg); }
.catrow .channel__tools { display: none; }
.catrow:hover .channel__tools { display: flex; }
@media (hover: none) { .catrow .channel__tools { display: flex; } }

/* ================= Appearance: density ================= */
/* js/theme.js sets data-density on <html>. "Compact" drops the avatar/gutter
   column entirely (rather than shrinking it) and tightens vertical rhythm —
   this is the "everything one line taller" reading Discord's own compact
   mode gives you. */

html[data-density="compact"] .msg {
  grid-template-columns: 1fr;
  column-gap: 0;
  padding-block: 0;
}
html[data-density="compact"] .msg__avatar,
html[data-density="compact"] .msg__gutter {
  display: none;
}
/* .msg__body is explicitly placed at grid-column:2 for the cozy two-column
   layout; left unchanged here it would force an implicit second column back
   into existence (auto-sized to fit it) even though grid-template-columns
   above only declares one, pushing every message's text off to the right
   instead of collapsing into the freed-up avatar column. */
html[data-density="compact"] .msg__body {
  grid-column: 1;
}
html[data-density="compact"] .msg--lead {
  margin-top: 2px;
  padding-top: 2px;
}
html[data-density="compact"] .msg__head {
  margin-bottom: 0;
}
html[data-density="compact"] .messages {
  padding-top: var(--s2);
}

/* ================= Appearance: glass ================= */
/* js/theme.js sets data-glass on <html>. The shell (rail-nav, sidebar,
   topbar) is normally opaque and #app has no background of its own, so
   there is nothing behind those panels for backdrop-filter to blur except
   flat body colour — hence the gradient wash on body here, which is what
   actually gives the blur something with texture to pick up. .main stays
   mostly opaque so message text keeps its contrast; only the chrome
   genuinely glasses over. */

html[data-glass] body {
  background:
    radial-gradient(1100px 650px at 8% -8%, color-mix(in srgb, var(--accent) 30%, transparent) 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 100%, color-mix(in srgb, var(--accent-strong) 24%, transparent) 0%, transparent 55%),
    var(--bg-deep);
}
/* js/theme.js sets data-wallpaper (alongside --wallpaper-url) only when a
   wallpaper is stored, so this variant only wins the cascade — via the extra
   attribute selector's higher specificity — when there's actually an image to
   show; otherwise the plain gradient above stands. The base flat colour
   swaps for the user's photo, with a flat accent tint layered over it so the
   photo still reads as *this app's* colour scheme rather than a random image
   fighting the theme; the same two radial washes stay on top so glass mode
   looks like one consistent surface either way. Wallpaper is intentionally
   only visible here, under data-glass — glass mode is what gives
   backdrop-filter texture to blur in the first place, so an image with glass
   off would just sit fully hidden behind opaque panels. That's expected, not
   a bug. */
html[data-glass][data-wallpaper] body {
  background:
    radial-gradient(1100px 650px at 8% -8%, color-mix(in srgb, var(--accent) 30%, transparent) 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 100%, color-mix(in srgb, var(--accent-strong) 24%, transparent) 0%, transparent 55%),
    linear-gradient(color-mix(in srgb, var(--accent) 38%, transparent), color-mix(in srgb, var(--accent) 38%, transparent)),
    var(--wallpaper-url) center / cover no-repeat;
}
html[data-glass] #app {
  background: transparent;
}
html[data-glass] .rail-nav,
html[data-glass] .sidebar,
html[data-glass] .topbar {
  background: color-mix(in srgb, var(--bg-side) 48%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}
html[data-glass] .rail-nav {
  background: color-mix(in srgb, var(--bg-deep) 44%, transparent);
}
html[data-glass] .main {
  background: color-mix(in srgb, var(--bg-main) 90%, transparent);
}
