/* ═══════════════════════════════════════════════════════════════════════════
   Cove — a quiet place to talk.

   One file, no build step. The app is a row of frosted panels floating over
   three drifting colour fields; every accent is the one blue, and every
   avatar takes its own two-colour gradient.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Typeface ────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --font: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --blue: #0071e3;
  --blue-deep: #0060c9;
  --blue-ink: #004a94;
  --blue-ghost: rgba(0, 113, 227, 0.15);

  --ink: #1d1d1f;
  --muted: #63636a;
  --faint: #6f6f76;

  --glass: rgba(255, 255, 255, 0.28);
  --glass-strong: rgba(255, 255, 255, 0.55);
  --glass-soft: rgba(255, 255, 255, 0.45);
  --edge: rgba(255, 255, 255, 0.7);
  --edge-soft: rgba(255, 255, 255, 0.55);

  --field: rgba(255, 255, 255, 0.8);
  --raised: rgba(255, 255, 255, 0.9);

  --bubble-in: rgba(255, 255, 255, 0.85);
  --bubble-out: linear-gradient(180deg, #2b8cff, #0071e3);

  --green: #30d158;
  --green-ghost: rgba(48, 209, 88, 0.18);

  --danger: #ff3b30;

  --r-card: 26px;
  --r-panel: 18px;
  --r-row: 14px;
  --r-pill: 999px;

  --gap: 12px;
  --rail-w: 68px;
  --side-w: 250px;
  --people-w: 230px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 180ms;
  --med: 320ms;

  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 6px 24px rgba(40, 60, 120, 0.09);
  --shadow-row: 0 4px 14px rgba(40, 60, 120, 0.08);
  --shadow-bubble: 0 2px 10px rgba(40, 60, 120, 0.06);
  --shadow-out: 0 4px 10px rgba(0, 113, 227, 0.22);
  --shadow-pop: 0 5px 22px rgba(40, 60, 120, 0.1);
}

:root[data-theme='dark'] {
  --ink: #f5f5f7;
  --muted: #b4b4ba;
  --faint: #8e8e94;

  --glass: rgba(32, 32, 36, 0.42);
  --glass-strong: rgba(52, 52, 58, 0.62);
  --glass-soft: rgba(44, 44, 50, 0.55);
  --edge: rgba(255, 255, 255, 0.12);
  --edge-soft: rgba(255, 255, 255, 0.08);

  --field: rgba(58, 58, 64, 0.72);
  --raised: rgba(66, 66, 72, 0.85);

  --bubble-in: rgba(255, 255, 255, 0.12);
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-row: 0 4px 14px rgba(0, 0, 0, 0.22);
  --shadow-bubble: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.32);
}

/* Night: the drifting fields go deep instead of staying daylight-bright. */
:root[data-theme='dark'] .bgx {
  filter: blur(90px) saturate(120%);
  opacity: 0.8;
}

:root[data-theme='dark'] .bgx i:nth-child(1) {
  background: #12305f;
}

:root[data-theme='dark'] .bgx i:nth-child(2) {
  background: #2a1545;
}

:root[data-theme='dark'] .bgx i:nth-child(3) {
  background: #0d3a32;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* `hidden` must win over the layout rules below it. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: #dfe6f5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

:root[data-theme='dark'] body {
  background: #14141a;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

button {
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

button:active {
  transform: scale(0.96);
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

svg {
  display: block;
  flex: none;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: var(--r-row);
}

::selection {
  background: var(--blue-ghost);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── The colour fields ───────────────────────────────────────────────────── */
.bgx {
  position: fixed;
  inset: -10%;
  z-index: 0;
  filter: blur(60px);
  pointer-events: none;
}

.bgx i {
  position: absolute;
  border-radius: 50%;
  opacity: 1;
  animation: drift 22s var(--ease) infinite alternate;
}

.bgx i:nth-child(1) {
  width: 46vw;
  height: 46vw;
  left: 5%;
  top: 5%;
  background: #7fb0ff;
}

.bgx i:nth-child(2) {
  width: 40vw;
  height: 40vw;
  right: 5%;
  top: 15%;
  background: #d3a8ff;
  animation-delay: -6s;
}

.bgx i:nth-child(3) {
  width: 38vw;
  height: 38vw;
  left: 35%;
  bottom: 0;
  background: #8fe8d6;
  animation-delay: -12s;
}

@keyframes drift {
  to {
    transform: translate(6vw, 4vh) scale(1.12);
  }
}

/* ── The frosted panel ───────────────────────────────────────────────────── */
.panel {
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-panel);
  border-radius: var(--r-card);
}

/* ═══ Sign in ═════════════════════════════════════════════════════════════ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.gate__panel {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  text-align: center;
  border-radius: var(--r-card);
  background: var(--glass);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-panel);
  animation: up 0.5s var(--ease) both;
}

@keyframes up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.gate__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-out);
}

.gate__title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.gate__lede {
  margin: 8px auto 26px;
  max-width: 32ch;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.gate__form {
  text-align: left;
}

.gate__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.gate__input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--field);
  border: 1px solid var(--edge);
  font-size: 16px;
  font-weight: 600;
  transition: box-shadow var(--fast) var(--ease);
}

.gate__input::placeholder {
  color: var(--faint);
}

.gate__input:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--blue-ghost);
}

.gate__error {
  min-height: 18px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
}

.gate__form .btn {
  margin-top: 14px;
}

.gate__note {
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

/* Sign in with Logfare: the divider and the device-code flow. */
.gate__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}

.gate__divider::before,
.gate__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--edge);
}

.gate__device {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--r-row);
  background: var(--field);
  border: 1px solid var(--edge);
  text-align: center;
}

.gate__deviceCode {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
}

.gate__deviceHint {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.gate__deviceHint a {
  color: var(--blue-ink);
  font-weight: 700;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--r-row);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.btn:active {
  transform: scale(0.95);
}

.btn--primary {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-out);
}

.btn--primary:hover {
  background: var(--blue-deep);
}

.btn--secondary {
  background: var(--glass-strong);
  color: var(--ink);
  border: 1px solid var(--edge);
}

.btn--secondary:hover {
  background: var(--raised);
}

.btn--ghost {
  color: var(--muted);
  padding: 0 12px;
}

.btn--ghost:hover {
  color: var(--ink);
  background: var(--glass-strong);
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  background: #e5e5ea;
  color: #aeaeb2;
  box-shadow: none;
  cursor: default;
  transform: none;
}

:root[data-theme='dark'] .btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--muted);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.iconbtn:hover {
  background: var(--glass-strong);
  color: var(--ink);
}

.iconbtn[aria-pressed='true'] {
  color: var(--blue);
}

/* ═══ Shell ═══════════════════════════════════════════════════════════════ */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--people-w);
  gap: var(--gap);
  height: 100dvh;
  padding: var(--gap);
}

/* ── Server rail ─────────────────────────────────────────────────────────── */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  overflow-y: auto;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.rail__scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rail__item {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--glass-strong);
  color: #515154;
  font-size: 13px;
  font-weight: 800;
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.rail__item:hover {
  background: var(--raised);
  color: var(--ink);
}

.rail__item[aria-current='true'] {
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-out);
}

.rail__badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  border: 2px solid #fff;
  box-sizing: content-box;
  pointer-events: none;
}

:root[data-theme='dark'] .rail__badge {
  border-color: #2c2c32;
}

.rail__pip {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

:root[data-theme='dark'] .rail__badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  border: 2px solid #fff;
  box-sizing: content-box;
  pointer-events: none;
}

:root[data-theme='dark'] .rail__badge {
  border-color: #2c2c32;
}

.rail__pip {
  border-color: #2c2c32;
}

.rail__add {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  border: 1.5px dashed rgba(0, 0, 0, 0.15);
  color: var(--muted);
  font-size: 22px;
  font-weight: 400;
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.rail__add:hover {
  background: var(--glass-strong);
  color: var(--ink);
}

:root[data-theme='dark'] .rail__add {
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar__head {
  display: flex;
  align-items: center;
  padding: 22px 22px 8px;
  flex: none;
}

.sidebar__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  text-align: left;
}

.sidebar__chev {
  color: var(--muted);
  transition: transform var(--fast) var(--ease);
}

.sidebar__title:hover .sidebar__chev {
  transform: translateY(1px);
}

.sidebar__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

.roomgroup + .roomgroup {
  margin-top: 4px;
}

.roomgroup__label {
  margin: 0;
  padding: 18px 12px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.roomlist {
  display: flex;
  flex-direction: column;
}

.room {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-row);
  font-size: 15px;
  font-weight: 600;
  color: #515154;
  text-align: left;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.room:hover {
  background: var(--glass-soft);
  color: var(--ink);
}

.room[aria-current='true'] {
  background: var(--raised);
  color: var(--ink);
  box-shadow: var(--shadow-row);
}

.room__hash {
  width: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.room[aria-current='true'] .room__hash {
  color: var(--blue);
}

.room__name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.room__pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  flex: none;
}

/* A message that names you: warm wash and a left rule, like Discord. */
.msg__item--ping {
  background: rgba(240, 170, 0, 0.13);
  box-shadow: inset 3px 0 0 #e5a50a;
  border-radius: 8px;
}

.bubble--ping {
  box-shadow: 0 0 0 1.5px rgba(229, 165, 10, 0.65);
}

.room__presence {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: #c7c7cc;
  margin: 0 3px;
}

.room__presence--on {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-ghost);
}

.roomlist__add {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--blue-ink);
  text-align: left;
  border-radius: var(--r-row);
}

.roomlist__add:hover {
  background: var(--glass-soft);
}

.roomlist__empty {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Me ──────────────────────────────────────────────────────────────────── */
.sidebar__foot {
  flex: none;
  padding: 8px 12px;
}

.me {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-panel);
  background: var(--glass-strong);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  transition: background-color var(--fast) var(--ease);
}

.me:hover {
  background: var(--raised);
}

.me__avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.me__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.me__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me__status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.me__gear {
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.me:hover .me__gear {
  opacity: 1;
}

/* ── Conversation ────────────────────────────────────────────────────────── */
.conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.36);
}

:root[data-theme='dark'] .conversation {
  background: rgba(255, 255, 255, 0.05);
}

.room__head {
  flex: none;
  border-bottom: 1px solid var(--edge-soft);
}

.room__headInner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 74px;
  max-width: 740px;
  margin: 0 auto;
  padding: 0 28px;
}

.room__back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: -6px;
  border-radius: 12px;
  color: var(--muted);
}

.room__back:hover {
  background: var(--glass-strong);
  color: var(--ink);
}

.room__heading {
  flex: 1;
  min-width: 0;
}

.room__title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room__topic {
  margin-top: 1px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room__topic:empty {
  display: none;
}

.room__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

/* ── Thread ──────────────────────────────────────────────────────────────── */
.thread {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

/* A short conversation sits on the composer, not floating at the top. */
.thread::before {
  content: '';
  margin-top: auto;
}

.thread__inner {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  padding: 24px 28px 8px;
}

/* The opening of an empty room. */
.thread__welcome {
  padding: 40px 0;
  animation: up 0.5s var(--ease) both;
}

.thread__welcomeMark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border-radius: 18px;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-out);
}

.thread__welcomeTitle {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.8px;
  margin-bottom: 10px;
}

.thread__welcomeText {
  max-width: 46ch;
  font-size: 17px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--muted);
}

.thread__loading,
.thread__empty {
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.thread__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--edge);
  border-top-color: var(--blue);
  animation: spin 700ms linear infinite;
}

.thread__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* A day marker. */
.daybreak {
  align-self: center;
  width: max-content;
  margin: 16px auto 14px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

/* ── Channel messages ────────────────────────────────────────────────────── */
.msg {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  margin: 0 -14px;
  border-radius: 18px;
  animation: up 0.45s var(--ease) both;
}

.msg__item {
  position: relative;
  margin: 0 -8px;
  padding: 1px 8px;
  border-radius: 10px;
}

.msg__item:hover {
  background: var(--glass-soft);
}

.msg__gutter {
  width: 36px;
  height: 36px;
  flex: none;
}

.msg__gutter .avatar {
  width: 36px;
  height: 36px;
  font-size: 12px;
}

.msg__body {
  min-width: 0;
  padding-top: 1px;
}

.msg__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.msg__author {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.msg__meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.msg__text {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* ── Direct message bubbles ──────────────────────────────────────────────── */
.bubblegroup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 8px 0;
  animation: up 0.4s var(--ease) both;
}

.bubblegroup--mine {
  align-items: flex-end;
}

.bubblegroup__stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  max-width: 70%;
}

.bubblegroup--mine .bubblegroup__stack {
  align-items: flex-end;
}

.bubble__body {
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--bubble-in);
  box-shadow: var(--shadow-bubble);
  font-size: 16px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bubblegroup--mine .bubble__body {
  background: var(--bubble-out);
  color: #fff;
  box-shadow: var(--shadow-out);
}

.bubblegroup__time {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.bubblegroup:hover .bubblegroup__time {
  opacity: 1;
}

.msg--pending {
  opacity: 0.6;
}

/* ── Mentions and reactions ──────────────────────────────────────────────── */
.mention--everyone {
  background: var(--danger-soft, rgba(200, 40, 40, 0.14));
  color: var(--danger);
  font-weight: 800;
}

.mention {
  border-radius: 6px;
  background: var(--blue-ghost);
  padding: 0 3px;
  font-weight: 800;
}

.mention--bot {
  outline: 1px solid var(--blue-ghost);
}

.reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.react {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--glass-soft);
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.4;
  transition: background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}

.react:hover {
  background: var(--glass-strong);
}

.react--mine {
  border-color: var(--blue);
  background: var(--blue-ghost);
}

.react__count {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}



.reaction-picker {
  position: absolute;
  z-index: 5;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--glass-strong);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-pop);
  animation: up 0.2s var(--ease) both;
}

.reaction-picker__opt {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.reaction-picker__opt:hover {
  background: var(--glass-strong);
}

.msg,
.bubble {
  position: relative;
}

.msg__bot {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--blue-ghost);
  color: var(--blue-ink);
  align-self: center;
}

/* ── Own-message actions: kebab, menu, inline editor ───────────────────── */
.msg__line {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.msg__line .msg__text {
  flex: 1;
  min-width: 0;
}

.msg__actions {
  flex: none;
  align-self: center;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.msg:hover .msg__actions,
.bubble:hover .msg__actions {
  opacity: 1;
}

/* Touch has no hover, so the kebab stays faintly visible on coarse pointers. */
@media (pointer: coarse) {
  .msg__actions,
  .bubble .msg__actions {
    opacity: 0.45;
  }
}

.msg__kebab {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  color: var(--muted);
}

.msg__kebab:hover {
  background: var(--glass-strong);
  color: var(--ink);
}

.msg-menu {
  position: fixed;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  padding: 5px;
  border-radius: 13px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-pop);
  animation: up 0.18s var(--ease) both;
}

.msg-menu__item {
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  color: var(--ink);
}

.msg-menu__item:hover {
  background: var(--glass-soft);
}

.msg-menu__item--danger {
  color: var(--danger);
}

.msg-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.msg-editor__input {
  width: 100%;
  min-height: 38px;
  max-height: 180px;
  padding: 9px 12px;
  border-radius: var(--r-row);
  background: var(--field);
  border: 1px solid var(--edge);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.msg-editor__input:focus {
  box-shadow: 0 0 0 4px var(--blue-ghost);
}

.msg-editor__row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn--small {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}

/* ── Edited badge and tombstones ────────────────────────────────────────── */
.msg__edited {
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  white-space: nowrap;
  align-self: center;
}

.msg__edited--bubble {
  float: right;
  margin-left: 8px;
  line-height: 1.2;
}

.msg__text--gone {
  color: var(--faint);
  font-style: italic;
}

.bubble--gone .bubble__body {
  background: var(--glass-soft);
  box-shadow: none;
  color: var(--faint);
  font-style: italic;
}

.bubblegroup--mine .bubble--gone .bubble__body {
  background: var(--glass-soft);
  color: var(--faint);
  box-shadow: none;
}

/* ── Channel member strip ───────────────────────────────────────────────── */
.memberstrip {
  display: none;
  align-items: center;
  gap: 10px;
  /* Full column width, capped for wide screens; margin centers the cap.
     min-width 0 lets a narrow panel shrink it instead of overflowing. */
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  min-width: 0;
  /* 40px keeps the count clear of the panel edge (12px gate rule). */
  padding: 6px 40px 2px;
}
.memberstrip:not(:empty) {
  display: flex;
}

@media (min-width: 1101px) {
  /* The people column already answers "who is here" on wide screens; the
     strip is a narrow-layout affordance. */
  .memberstrip:not(:empty) {
    display: none;
  }
}

.memberstrip__avatars {
  display: flex;
  /* On narrow screens the avatar row yields space to the count instead
     of pushing it against the panel edge. */
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}

.memberstrip__avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
  border: 2px solid var(--glass);
  opacity: 0.5;
}

.memberstrip__avatar + .memberstrip__avatar {
  margin-left: -7px;
}

.memberstrip__avatar--on {
  opacity: 1;
}

.memberstrip__count {
  font-size: 12px;
  font-weight: 700;
  /* --faint fails 4.5:1 on the panel background; --muted reads and clears. */
  color: var(--muted);
  white-space: nowrap;
}

/* ── Reports sheet ─────────────────────────────────────────────────────── */
.reports {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.report {
  padding: 12px 14px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
}

.report__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.report__kind {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--blue-ghost);
  color: var(--blue-ink);
}

.report__kind--bug {
  background: rgba(255, 59, 48, 0.14);
  color: #c53030;
}

:root[data-theme='dark'] .report__kind--bug {
  color: #ff8177;
}

.report__kind--idea {
  background: rgba(48, 209, 88, 0.16);
  color: #1f9e46;
}

:root[data-theme='dark'] .report__kind--idea {
  color: #6ee787;
}

.report__when {
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.report__title {
  font-size: 15px;
  font-weight: 800;
}

.report__body {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.report__by {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
}

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer {
  flex: none;
  padding: 8px 20px max(18px, env(safe-area-inset-bottom));
}

.composer__form {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
}

.composer__box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 20px;
  border-radius: var(--r-card);
  background: var(--field);
  border: 1px solid #fff;
  box-shadow: var(--shadow-pop);
  transition: box-shadow var(--fast) var(--ease);
}

:root[data-theme='dark'] .composer__box {
  border-color: var(--edge);
}

.composer__box:focus-within {
  box-shadow: 0 0 0 4px var(--blue-ghost), var(--shadow-pop);
}

.composer__input {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  padding: 9px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  resize: none;
  outline: none;
  background: none;
}

.composer__input::placeholder {
  color: var(--faint);
}

.composer__send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-out);
  transition: transform var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.composer__send:hover:not(:disabled) {
  background: var(--blue-deep);
}

.composer__send:disabled {
  background: #e5e5ea;
  color: #aeaeb2;
  box-shadow: none;
  cursor: default;
  transform: scale(0.9);
}

:root[data-theme='dark'] .composer__send:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.35);
}

.composer__hint {
  max-width: 700px;
  height: 14px;
  margin: 6px auto 0;
  padding-left: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.composer__hint--on {
  opacity: 1;
}

/* ── People ──────────────────────────────────────────────────────────────── */
.people {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.people__title {
  flex: none;
  padding: 24px 22px 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.people__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--r-row);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  transition: background-color var(--fast) var(--ease);
}

.person:hover {
  background: var(--glass-soft);
}

.person__avatar {
  position: relative;
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.person__dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
}

:root[data-theme='dark'] .person__dot {
  border-color: #2c2c32;
}

.person__name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person__role {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.person__role--bot {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--blue-ghost);
  color: var(--blue-ink);
}

.people__group {
  padding: 16px 12px 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.people__empty {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Avatars ─────────────────────────────────────────────────────────────── */
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  flex: none;
  user-select: none;
  overflow: hidden;
}

.avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* ═══ Dialogs ═════════════════════════════════════════════════════════════ */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(30, 40, 60, 0.22);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in 180ms var(--ease) both;
}

.scrim--nav {
  z-index: 44;
  background: rgba(30, 40, 60, 0.16);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  width: min(440px, calc(100vw - 32px));
  max-height: min(620px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  transform: translate(-50%, -50%);
  border-radius: var(--r-card);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-pop);
  animation: sheet-in 260ms var(--ease) both;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px)) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 12px 12px 24px;
  flex: none;
}

.sheet__title {
  flex: 1;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 24px;
}

.sheet__lede {
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.field__input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--r-row);
  background: var(--field);
  border: 1px solid var(--edge);
  font-size: 15px;
  font-weight: 600;
  transition: box-shadow var(--fast) var(--ease);
}

.field__input--select {
  cursor: pointer;
}

.field__input:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--blue-ghost);
}

.sheet__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.sheet__error {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
}

.picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.picker__row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: var(--r-row);
  text-align: left;
  transition: background-color var(--fast) var(--ease);
}

.picker__row:hover {
  background: var(--glass-soft);
}

.picker__name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.picker__status {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.picker__empty {
  padding: 18px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.serverpick {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.serverpick__row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
}

.serverpick__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 12px;
  background: var(--glass-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.serverpick__body {
  flex: 1;
  min-width: 0;
}

.serverpick__name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.serverpick__meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sheet__signout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}

.sheet__signout:hover {
  background: var(--glass-strong);
}

.sheet__signout small {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sheet__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
  font-size: 15px;
  font-weight: 700;
}

.sheet__rowBody {
  flex: 1;
}

.sheet__rowTitle {
  font-weight: 800;
}

.sheet__rowHint {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.segment {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
}

.segment__opt {
  padding: 6px 14px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.segment__opt[aria-pressed='true'] {
  background: var(--raised);
  color: var(--ink);
  box-shadow: var(--shadow-row);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 60;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--r-panel);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  animation: toast-in 260ms var(--ease) both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

/* ═══ Narrow screens ══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: var(--rail-w) 240px minmax(0, 1fr);
  }
  .people {
    position: fixed;
    top: var(--gap);
    right: var(--gap);
    bottom: var(--gap);
    width: var(--people-w);
    z-index: 30;
    transform: translateX(calc(100% + var(--gap) * 2));
    visibility: hidden;
    transition: transform var(--med) var(--ease), visibility var(--med);
  }
  .people--open {
    transform: none;
    visibility: visible;
  }
  .room__headInner {
    max-width: 740px;
    padding: 0 20px;
  }
  .memberstrip {
    padding: 6px 40px 2px;
  }
  .thread__inner {
    padding: 20px 20px 8px;
  }
  .composer {
    padding: 8px 14px max(16px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 720px) {
  :root {
    --gap: 8px;
    --rail-w: 60px;
  }
  .app {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    top: var(--gap);
    left: var(--gap);
    bottom: var(--gap);
    width: min(290px, 84vw);
    z-index: 45;
    transform: translateX(calc(-100% - var(--gap) * 2));
    visibility: hidden;
    transition: transform var(--med) var(--ease), visibility var(--med);
  }
  .sidebar--open {
    transform: none;
    visibility: visible;
  }
  .room__back {
    display: inline-flex;
  }
  .room__headInner {
    height: 62px;
    padding: 0 12px;
  }
  .memberstrip {
    padding: 4px 40px 2px;
  }
  .memberstrip__count {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .thread__welcomeTitle {
    font-size: 32px;
  }
  .thread__welcomeText {
    font-size: 16px;
  }
  .rail__item,
  .rail__add {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }
  .msg {
    padding: 9px 10px;
    margin: 0 -10px;
  }
  .msg__gutter,
  .msg__gutter .avatar {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }
  .bubblegroup__stack {
    max-width: 84%;
  }
  .composer {
    padding: 6px 10px max(12px, env(safe-area-inset-bottom));
  }
  .composer__box {
    padding: 5px 5px 5px 16px;
  }
  .people {
    width: min(290px, 84vw);
  }
  .toast {
    bottom: 120px;
  }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
/* ── Message tools, replies, profiles ───────────────────────────────────── */
.msg,
.bubblegroup,
.msg__line,
.bubble {
  position: relative;
}

.msg__tools {
  position: absolute;
  top: -10px;
  right: 8px;
  transform: translateY(-100%);
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  border-radius: 10px;
  background: var(--raised);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-row);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease);
  z-index: 6;
}

.msg__item:hover .msg__tools,
.bubble:hover .msg__tools,
.msg__tools:hover,
.msg__tools:focus-within {
  opacity: 1;
  pointer-events: auto;
}

/* The tools float above the message, leaving a gap the cursor would cross
   on its way there; this invisible bridge keeps the hover alive. */
.msg__tools::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 16px;
}

.msg__tool {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
}

.msg__tool:hover {
  background: var(--glass-soft);
  color: var(--ink);
}

.msg__tool--danger:hover {
  color: var(--danger);
}

.msg-menu--emoji {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px;
  width: 240px;
}

.msg-menu__emoji {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 19px;
}

.msg-menu__emoji:hover {
  background: var(--glass-soft);
}

.msg__reply {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  margin: 0 0 3px;
  padding-left: 8px;
  border-left: 2px solid var(--edge);
  font-size: 12.5px;
  color: var(--muted);
  text-align: left;
}

.bubble .msg__reply {
  margin-bottom: 6px;
  border-left-color: rgba(255, 255, 255, 0.4);
}

.bubblegroup--mine .bubble .msg__reply {
  border-left-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.8);
}

.msg__replyWho {
  flex: none;
  font-weight: 800;
  color: var(--ink);
}

.bubble .msg__replyWho {
  color: inherit;
}

.msg__replyText {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg__author--link,
.avatar--link {
  cursor: pointer;
}

.msg--flash {
  animation: flash 1.1s var(--ease);
}

@keyframes flash {
  from {
    background: var(--blue-ghost);
  }
  to {
    background: transparent;
  }
}

.composer__reply {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 740px;
  margin: 0 auto 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--glass-soft);
  border: 1px solid var(--edge-soft);
  font-size: 13px;
  color: var(--muted);
}

.composer__replyText {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 4px;
  text-align: center;
}

.profile__avatar {
  width: 96px;
  height: 96px;
  font-size: 30px;
  margin-bottom: 8px;
}

.profile__name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.profile__handle {
  font-size: 14px;
  color: var(--muted);
}

.profile__status {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 700;
}

.profile__bio {
  max-width: 46ch;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.profile__since {
  margin-top: 6px;
  font-size: 12px;
  color: var(--faint);
}

.profile__actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── Jump to new messages ───────────────────────────────────────────────── */
.jumpnew {
  position: absolute;
  right: 26px;
  bottom: 98px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-out);
}

.jumpnew:hover {
  background: var(--blue-deep);
}

.conversation {
  position: relative;
}

/* ── Mention autocomplete ───────────────────────────────────────────────── */
.mentions {
  position: absolute;
  left: 20px;
  bottom: calc(100% + 8px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(320px, calc(100vw - 48px));
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 14px;
  background: var(--raised);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-pop);
}

.mentions__row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 10px;
  text-align: left;
}

.mentions__row[aria-selected='true'],
.mentions__row:hover {
  background: var(--glass-soft);
}

.mentions__avatar {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.mentions__name {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mentions__handle {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Home, bots, server management ──────────────────────────────────────── */
.rail__home {
  margin-bottom: 4px;
}

/* Home opens at the top of the panel, not bottom-anchored like a chat. */
.thread--home::before {
  margin-top: 0;
}

.sidebar__search {
  padding: 12px 12px 2px;
}

.sidebar__searchInput {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-row);
  background: var(--field);
  border: 1px solid var(--edge);
  font-size: 13px;
}

.sidebar__searchInput:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--blue-ghost);
}

.home {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 820px;
  margin: 0 auto;
  padding: 26px 24px 40px;
}

.home__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.home__title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.home__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.home__sectionBlock {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.home__section {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.home__rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px;
}

.home__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
  text-align: left;
  transition: background-color var(--fast) var(--ease);
}

.home__row:hover {
  background: var(--raised);
}

.home__avatar {
  position: relative;
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.home__dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success, #2e9e5b);
  border: 2px solid var(--glass);
}

.home__rowBody {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.home__rowName {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home__rowMeta {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home__rowChev {
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
}

.home__feed {
  display: flex;
  flex-direction: column;
}

.home__previewRow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--edge);
}

.home__previewRow:last-child {
  border-bottom: none;
}

.home__previewWho {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.home__previewText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.home__empty {
  padding: 6px 2px;
  font-size: 13px;
  color: var(--muted);
}

.room__avatar {
  position: relative;
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.room__avatarDot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success, #2e9e5b);
  border: 2px solid var(--glass);
}

.room__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.room__meta {
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invites,
.settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}

.invites__row,
.settings__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-row);
  background: var(--glass-soft);
}

.invites__code {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
}

.settings__who {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.settings__name {
  font-size: 14px;
  font-weight: 700;
}

.settings__meta {
  font-size: 12px;
  color: var(--muted);
}

.token {
  display: block;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--r-row);
  background: var(--field);
  font-size: 13px;
  word-break: break-all;
}

.field--check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.field--check input {
  margin-top: 2px;
}

.field__input--area {
  height: auto;
  min-height: 110px;
  padding: 10px 14px;
  resize: vertical;
  font: inherit;
  line-height: 1.45;
}

.btn--danger {
  background: var(--danger-soft, rgba(200, 40, 40, 0.12));
  color: var(--danger);
}

.btn--danger:hover {
  background: rgba(200, 40, 40, 0.18);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

