/* swarm — the messaging of Beeons, in the Beeons "look beyond" language shared with hive: pure black and white surfaces,
   hairlines, glass pills, round icon buttons, and the brand colours (blue, violet, yellow) only as soft glows.
   Light and dark themes (html[data-theme], set before the first paint by build/theme.js).
   No inline styles anywhere (strict CSP). Overflow rule: every grid/flex child holding text gets min-width: 0;
   names truncate (with a title tooltip), message text wraps anywhere. */
@font-face { font-family: "Plus Jakarta Sans"; src: url("/fonts/plus-jakarta-sans-latin-wght-normal-7660bd9909fb097989b19471a75f1b7a.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Jost"; src: url("/fonts/jost-latin-wght-normal-928f4210aa4859fcfdb853d2c6329589.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-400-normal-79936b18df9f734fb6b0a256b20d36b4.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-500-normal-b1c8a895f5fd3fe6cbf5b4cf95c58d87.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  /* Brand palette: light only, never surfaces */
  --beeons-blue: #0A65E7; --beeons-violet: #8A2AE3; --beeons-yellow: #FFD600;
  --radius: 16px; --radius-sm: 10px;
  --sidebar-w: 312px; --rail-w: 72px; --head-h: 60px;
  --head: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --body: "Jost", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
:root, [data-theme="dark"] {
  --ink: #000; --panel: #0A0A0A; --panel-2: #111111; --panel-3: #1A1A1A;
  --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .18);
  --text: #F1F7FE; --muted: #A1A4A5; --faint: #8A8D90;
  --fg: #FFFFFF; --on-fg: #000000; --fg-hover: #E8E8E8; --tint: 255, 255, 255;
  --header-bg: rgba(0, 0, 0, .66); --tile-top: #1A1A1A; --tile-bottom: #050505; --heading-end: rgba(255, 255, 255, .58);
  /* Meaning colours (text ≥ 4.5:1 on the surfaces and on their own 13% tint) */
  --ok: #4ADE80; --ko: #FF8A7A; --warn: #FFC34D; --info: #7FB0FF;
  /* Bubbles: the others on a soft grey, mine in the colour of the primary buttons */
  --bubble: #161616; --bubble-line: rgba(255, 255, 255, .08);
  --glow-a: rgba(138, 42, 227, .20); --glow-b: rgba(10, 101, 231, .20); --glow-c: rgba(255, 214, 0, .06);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .9);
  --scrim: rgba(0, 0, 0, .6); --nav-glow: .24;
  color-scheme: dark;
}
[data-theme="light"] {
  --ink: #FFFFFF; --panel: #F7F8F9; --panel-2: #F0F1F3; --panel-3: #E7E9EC;
  --line: rgba(0, 0, 0, .09); --line-strong: rgba(0, 0, 0, .16);
  --text: #0F0B0A; --muted: #5B6168; --faint: #6B7178;
  --fg: #000000; --on-fg: #FFFFFF; --fg-hover: #222222; --tint: 0, 0, 0;
  --header-bg: rgba(255, 255, 255, .76); --tile-top: #FFFFFF; --tile-bottom: #ECEDEF; --heading-end: rgba(15, 11, 10, .62);
  --ok: #157F3D; --ko: #C2332B; --warn: #8F6200; --info: #0A58CC;
  --bubble: #F0F1F3; --bubble-line: rgba(0, 0, 0, .06);
  --glow-a: rgba(138, 42, 227, .10); --glow-b: rgba(10, 101, 231, .10); --glow-c: rgba(255, 214, 0, .12);
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, .28);
  --scrim: rgba(15, 11, 10, .35); --nav-glow: .1;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; background: var(--ink); color: var(--text); font: 400 .9375rem/1.5 var(--body); -webkit-font-smoothing: antialiased;
  isolation: isolate; overflow-x: clip; }
a { color: var(--text); text-underline-offset: 3px; text-decoration-color: rgba(var(--tint), .35); }
a:hover { color: var(--fg); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; margin: 0 0 .5em; color: var(--fg); }
h1 { font-size: clamp(1.3rem, 2.3vw, 1.7rem); font-weight: 800; letter-spacing: -.03em; padding-bottom: .06em; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: .9rem; font-weight: 600; }
p { margin: 0 0 .75em; }
img, svg { max-width: 100%; }
strong { font-weight: 600; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .8125rem; } .center { text-align: center; }
.warn { color: var(--ko); }
.stack > * + * { margin-top: 12px; }
.ico { display: block; width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="dark"] .theme-icon-moon, [data-theme="light"] .theme-icon-sun { display: none; }
.theme-icon-sun, .theme-icon-moon { display: contents; }
::selection { background: rgba(10, 101, 231, .35); }
* { scrollbar-width: thin; scrollbar-color: rgba(var(--tint), .18) transparent; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(var(--tint), .07); color: var(--text); font: 500 .875rem/1 var(--body);
  text-decoration: none; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: background .15s, box-shadow .15s, border-color .15s, color .15s; }
.btn:hover { background: rgba(var(--tint), .15); color: var(--fg); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--fg); color: var(--on-fg); border-color: var(--fg); }
.btn-primary:hover { background: var(--fg-hover); color: var(--on-fg); box-shadow: 0 0 0 4px rgba(var(--tint), .1); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { background: transparent; color: var(--ko); border-color: color-mix(in srgb, var(--ko) 45%, transparent); }
.btn-danger:hover { color: var(--ko); background: color-mix(in srgb, var(--ko) 12%, transparent); }
.btn-sm { min-height: 30px; padding: 0 12px; font-size: .8125rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; flex-shrink: 0; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(var(--tint), .06); color: var(--text); cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s, border-color .15s; }
.icon-btn:hover { background: rgba(var(--tint), .14); color: var(--fg); }
.icon-btn .ico { width: 17px; height: 17px; }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm .ico { width: 14px; height: 14px; }
.icon-btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn-ghost:hover { color: var(--fg); }
.icon-btn-primary { background: var(--fg); color: var(--on-fg); border-color: var(--fg); }
.icon-btn-primary:hover { background: var(--fg-hover); color: var(--on-fg); box-shadow: 0 0 0 4px rgba(var(--tint), .1); }
.icon-btn-danger { color: var(--muted); background: transparent; border-color: transparent; }
.icon-btn-danger:hover { color: var(--ko); border-color: color-mix(in srgb, var(--ko) 45%, transparent); background: color-mix(in srgb, var(--ko) 12%, transparent); }
.link-btn { color: var(--text); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(var(--tint), .35); }
.link-btn:hover { color: var(--fg); text-decoration-color: currentColor; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.corner-theme { position: fixed; top: 14px; right: 14px; z-index: 10; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
/* Once the conversations are on screen, the header carries the theme switch */
body:has(.layout) > .corner-theme { display: none; }

/* ---------- Forms ---------- */
label { font-weight: 500; font-size: .8125rem; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; font-size: .9rem; color: var(--text); background: rgba(var(--tint), .03);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 12px; min-height: 40px; min-width: 0; }
select { cursor: pointer; }
select option { background: var(--ink); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: rgba(var(--tint), .28); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fg); box-shadow: 0 0 0 3px rgba(var(--tint), .12); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--fg); margin: 0; flex-shrink: 0; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; box-shadow: none; }
.field { display: grid; gap: 6px; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 400; font-size: .875rem; color: var(--text); cursor: pointer; min-height: 34px; }
.check > .ico { width: 16px; height: 16px; color: var(--muted); }

/* ---------- Messages, chips ---------- */
.flash { display: flex; align-items: flex-start; gap: 10px; border-radius: 12px; padding: 9px 12px; margin: 0; font-size: .875rem;
  border: 1px solid; color: var(--text); overflow-wrap: anywhere; }
.flash::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.flash-ok { --c: var(--ok); background: color-mix(in srgb, var(--ok) 9%, transparent); border-color: color-mix(in srgb, var(--ok) 38%, transparent); }
.flash-ko { --c: var(--ko); background: color-mix(in srgb, var(--ko) 9%, transparent); border-color: color-mix(in srgb, var(--ko) 42%, transparent); }
.tag { display: inline-block; vertical-align: middle; max-width: 100%; font: 500 .62rem/1.5 var(--mono); letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: rgba(var(--tint), .06); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; min-width: 0; font-size: .8125rem; background: rgba(var(--tint), .06);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 8px; }
.chip .ico { width: 14px; height: 14px; color: var(--muted); }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; flex-shrink: 0;
  font: 600 .66rem/1 var(--mono); background: var(--fg); color: var(--on-fg); }
.code { display: flex; align-items: flex-start; gap: 6px; font: 500 .74rem/1.5 var(--mono); color: var(--muted); letter-spacing: .04em; overflow-wrap: anywhere; min-width: 0; }
.code .ico { width: 13px; height: 13px; margin-top: 2px; }
.code.big { display: block; font-size: .95rem; color: var(--fg); background: rgba(var(--tint), .05); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin: 0 0 8px; text-align: center; letter-spacing: .08em; }

/* Avatars: dark gradients with white initials (≥ 4.5:1), as in hive */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font: 700 .68rem/1 var(--head);
  letter-spacing: .02em; color: #FFF; flex-shrink: 0; user-select: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.avatar-xs { width: 22px; height: 22px; font-size: .56rem; }
.avatar-sm { width: 30px; height: 30px; font-size: .64rem; }
.avatar-c0 { background: linear-gradient(135deg, #0A65E7, #05316F); }
.avatar-c1 { background: linear-gradient(135deg, #8A2AE3, #3D1166); }
.avatar-c2 { background: linear-gradient(135deg, #3A3A3A, #000); }
.avatar-c3 { background: linear-gradient(135deg, #0E7C86, #053B40); }
.avatar-c4 { background: linear-gradient(135deg, #B5470B, #4F1E04); }
.avatar-bot { background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom)); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line-strong); }
.avatar-bot svg { width: 52%; height: 52%; }
/* Group picture: a glass tile with # (or the bug of the Bugs Dev group) */
.group-ico { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom)); border: 1px solid var(--line-strong); color: var(--fg); }
.group-ico .ico { width: 16px; height: 16px; }
.group-ico-bug { color: var(--ko); }

/* ---------- Login, key screens, errors ---------- */
.auth, body.app { background: radial-gradient(45% 50% at 85% 5%, var(--glow-a), transparent 70%), radial-gradient(40% 45% at 5% 95%, var(--glow-b), transparent 70%),
    radial-gradient(25% 25% at 50% 0%, var(--glow-c), transparent 70%), var(--ink); background-attachment: fixed; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 64px 16px 24px; }
.auth-box { width: 100%; max-width: 420px; padding: 28px 24px; border: 1px solid var(--line-strong); border-radius: 22px; display: grid; gap: 14px;
  background: color-mix(in srgb, var(--ink) 78%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); }
@media (min-width: 480px) { .auth-box { padding: 32px; } }
.auth-box h1 { margin: 0; font-size: 1.6rem; background: linear-gradient(180deg, var(--fg) 35%, var(--heading-end)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-box p { margin: 0; }
.auth-box .btn-block { min-height: 42px; font-size: .9rem; }
.auth-logo { display: flex; align-items: center; gap: 10px; color: var(--fg); font: 800 1.35rem/1 var(--head); letter-spacing: -.035em; margin: 0 0 8px !important; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: .8125rem; }
.auth-note .ico { width: 14px; height: 14px; }
.center-box { margin: max(48px, 12vh) auto 24px; width: calc(100% - 32px); }
.loading-box { justify-items: center; text-align: center; }
.loading-box .auth-logo { justify-content: center; }
.hero-tile { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 14px; color: var(--fg);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom)); border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(var(--tint), .12), 0 12px 26px -12px rgba(138, 42, 227, .55), 0 8px 20px -10px rgba(10, 101, 231, .55); }
.hero-tile .ico { width: 22px; height: 22px; }
.logo-mark { width: 24px; height: 27px; color: var(--fg); flex-shrink: 0; filter: drop-shadow(0 4px 14px rgba(10, 101, 231, .45)) drop-shadow(0 2px 10px rgba(138, 42, 227, .35)); }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--fg); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App layout: list | thread ---------- */
body.app { height: 100vh; height: 100dvh; overflow: hidden; }
#app { height: 100%; }
body.app:has(.center-box) { overflow-y: auto; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 0; }
@media (min-width: 900px) { .layout { grid-template-columns: var(--rail-w) minmax(0, 1fr); } }
@media (min-width: 1200px) { html:not(.rail) .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } }
/* Phones: the list and the thread are two screens (back button in the thread header) */
@media (max-width: 899.98px) {
  .layout.thread-open > .sidebar { display: none; }
  .layout:not(.thread-open) > .conv { display: none; }
}
@media (min-width: 900px) { .back-btn { display: none !important; } }

/* Conversation list */
.sidebar { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%;
  background: color-mix(in srgb, var(--ink) 86%, transparent); border-right: 1px solid var(--line); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--head-h); padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--fg); text-decoration: none; font: 800 1.3rem/1 var(--head); letter-spacing: -.035em; border-radius: 10px; }
.logo:hover { color: var(--fg); }
.conv-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.side-title { display: flex; align-items: center; margin: 14px 0 4px; padding: 0 10px; font: 500 .66rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.side-empty { color: var(--faint); font-size: .8125rem; margin: 2px 10px 4px; }
.conv-item { position: relative; display: flex; align-items: center; gap: 11px; min-height: 54px; padding: 8px 10px; border-radius: 14px; color: var(--text);
  text-decoration: none; min-width: 0; flex-shrink: 0; transition: background .15s; }
.conv-item:hover { background: rgba(var(--tint), .05); color: var(--fg); }
/* Active conversation: hairline, glass and a faint blue / violet glow */
.conv-item.active { background: rgba(var(--tint), .07); box-shadow: inset 0 0 0 1px var(--line); }
.conv-item.active::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(90% 160% at 0% 50%, rgba(10, 101, 231, var(--nav-glow)), transparent 65%), radial-gradient(70% 140% at 100% 50%, rgba(138, 42, 227, calc(var(--nav-glow) * .6)), transparent 70%); }
.conv-pic { position: relative; display: inline-flex; flex-shrink: 0; }
.conv-pic .avatar, .conv-pic .group-ico { width: 38px; height: 38px; }
.conv-pic .avatar { font-size: .74rem; }
.conv-pic .group-ico { border-radius: 12px; }
.conv-dot { display: none; position: absolute; top: -2px; right: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 0 2px var(--ink); }
.conv-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 500; }
.conv-time { flex-shrink: 0; font: 400 .68rem/1 var(--mono); color: var(--faint); }
.conv-sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; color: var(--muted); }
.conv-muted { display: inline-flex; color: var(--faint); } .conv-muted .ico { width: 14px; height: 14px; }
.conv-item.unread .conv-name { font-weight: 700; color: var(--fg); }
.conv-item.unread .conv-sub { color: var(--text); }
.conv-item.unread .conv-time { color: var(--fg); }
.sidebar-foot { border-top: 1px solid var(--line); padding: 8px 10px 10px; display: grid; gap: 6px; }
.foot-tools { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.rail-btn { display: none; }
.me-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 4px 0 6px; border-top: 1px solid var(--line); }
.me-name { flex: 1; min-width: 0; font-size: .875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-row form { margin: 0; display: flex; }
@media (min-width: 1200px) {
  .rail-btn { display: inline-flex; }
  html.rail .rail-btn .ico { transform: scaleX(-1); }
}
/* Icon rail: 900–1199px, or reduced on large screens (html.rail). Names stay for screen readers and in the tooltips. */
@media (min-width: 900px) and (max-width: 1199.98px) {
  .sidebar-head { flex-direction: column; justify-content: center; padding: 10px 0; gap: 10px; min-height: 0; }
  .logo-word, .side-label, .side-empty, .me-name { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .conv-list { padding: 6px 8px 12px; align-items: stretch; }
  .side-title { margin: 8px 6px; padding: 0; border-top: 1px solid var(--line); height: 1px; }
  .conv-item { justify-content: center; padding: 7px 0; min-height: 52px; }
  .conv-main { display: none; }
  .conv-dot { display: block; }
  .foot-tools, .me-row { flex-direction: column; justify-content: center; padding: 0; }
  .me-row { padding-top: 8px; }
  .sidebar-foot { padding: 8px 0 10px; justify-items: center; }
}
@media (min-width: 1200px) {
  html.rail .sidebar-head { flex-direction: column; justify-content: center; padding: 10px 0; gap: 10px; min-height: 0; }
  html.rail .logo-word, html.rail .side-label, html.rail .side-empty, html.rail .me-name { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html.rail .conv-list { padding: 6px 8px 12px; align-items: stretch; }
  html.rail .side-title { margin: 8px 6px; padding: 0; border-top: 1px solid var(--line); height: 1px; }
  html.rail .conv-item { justify-content: center; padding: 7px 0; min-height: 52px; }
  html.rail .conv-main { display: none; }
  html.rail .conv-dot { display: block; }
  html.rail .foot-tools, html.rail .me-row { flex-direction: column; justify-content: center; padding: 0; }
  html.rail .me-row { padding-top: 8px; }
  html.rail .sidebar-foot { padding: 8px 0 10px; justify-items: center; }
}
/* Short screens: the tools scroll with the list rather than squeeze it */
@media (min-width: 900px) and (max-height: 640px) { .sidebar { overflow-y: auto; } .conv-list { flex: none; overflow: visible; } }

/* ---------- A conversation ---------- */
.conv { display: flex; flex-direction: column; height: 100%; min-width: 0; min-height: 0; position: relative; }
.conv-head { position: relative; z-index: 5; display: flex; align-items: center; gap: 10px; min-height: var(--head-h); padding: 10px 12px 10px 16px; flex: none;
  background: var(--header-bg); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line); }
@media (max-width: 899.98px) { .conv-head { padding-left: 6px; gap: 8px; } }
.head-pic.avatar, .head-pic.group-ico { width: 36px; height: 36px; }
.conv-title { flex: 1; min-width: 0; }
.conv-title h1 { font-size: 1.02rem; font-weight: 700; letter-spacing: -.015em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-head-sub { margin: 1px 0 0; font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lock-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px 0 8px; border-radius: 999px; white-space: nowrap;
  font: 500 .66rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ok);
  background: color-mix(in srgb, var(--ok) 10%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent); }
.lock-chip .ico { width: 13px; height: 13px; stroke-width: 2; }
.members-btn { padding: 0 12px 0 10px; min-height: 36px; font-family: var(--mono); font-size: .78rem; }
@media (max-width: 599.98px) {
  .lock-chip { width: 26px; padding: 0; justify-content: center; }
  .lock-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .conv-tools { gap: 4px; }
  .conv-tools .icon-btn, .members-btn { width: 34px; height: 34px; min-height: 34px; }
  .members-btn { padding: 0; }
  .members-count { display: none; }
}
.banner { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 9px 16px; flex: none; font-size: .875rem; color: var(--text); overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--warn) 10%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.banner .ico { color: var(--warn); margin-top: 2px; }
.banner span { min-width: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 14px 16px 10px; }
@media (min-width: 900px) { .messages { padding: 18px 28px 12px; } }
.start { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px auto 18px; width: fit-content; max-width: 100%; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .8125rem; text-align: center; background: rgba(var(--tint), .03); }
.start .ico { width: 14px; height: 14px; color: var(--ok); }
.day { display: flex; align-items: center; gap: 12px; color: var(--faint); font: 500 .66rem/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; margin: 20px 0 10px; }
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.day span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--ink); white-space: nowrap; }

/* One message: avatar | body. Mine sit on the right, without avatar. */
.msg { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; margin-top: 12px; padding: 0 4px; }
.msg.grouped { margin-top: 3px; }
.msg.mine { grid-template-columns: minmax(0, 1fr); }
.msg-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 4px; min-width: 0; max-width: 100%; padding: 0 4px; }
.msg-author { font-family: var(--head); font-size: .84rem; font-weight: 600; color: var(--fg); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font: 400 .68rem/1 var(--mono); color: var(--faint); }
.msg-edited { font-size: .72rem; color: var(--faint); padding: 0 4px; }
.msg-time-side { align-self: center; font: .62rem/1 var(--mono); color: var(--faint); opacity: 0; text-align: center; transition: opacity .15s; }
.msg:hover .msg-time-side, .msg:focus-within .msg-time-side { opacity: 1; }
.bubble { max-width: min(680px, 100%); min-width: 0; padding: 8px 13px; border-radius: 18px; background: var(--bubble); border: 1px solid var(--bubble-line);
  color: var(--text); display: grid; gap: 6px; }
@media (min-width: 900px) { .bubble { max-width: min(680px, 82%); } }
.msg:not(.grouped):not(.mine) .bubble { border-top-left-radius: 6px; }
.msg.mine:not(.grouped) .bubble { border-top-right-radius: 6px; }
.msg.mine .bubble { background: var(--fg); color: var(--on-fg); border-color: var(--fg); }
.msg.mine .bubble a { color: inherit; text-decoration-color: currentColor; }
.msg.mine .bubble .muted { color: color-mix(in srgb, var(--on-fg) 70%, var(--fg)); }
.msg.mine .bubble .warn { color: inherit; }
.msg.mentioned .bubble { border-color: color-mix(in srgb, var(--warn) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 14%, transparent), 0 10px 30px -14px rgba(255, 214, 0, .45); }
.bubble-card { padding: 0; background: none; border: 0; max-width: min(560px, 100%); }
@media (min-width: 900px) { .bubble-card { max-width: min(560px, 82%); } }
.text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.text.state { display: flex; align-items: flex-start; gap: 7px; font-size: .875rem; }
.text.state .ico { width: 15px; height: 15px; margin-top: 3px; }
.mention { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); border-radius: 6px; padding: 0 4px; font-weight: 500; }
.mention.me { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.msg.mine .mention { color: inherit; background: color-mix(in srgb, var(--on-fg) 14%, transparent); font-weight: 600; }
/* Hover toolbar of my messages (edit, delete): above the bubble, above everything around it */
.msg-actions { position: absolute; top: -16px; right: 8px; z-index: 3; display: none; gap: 2px; padding: 2px; background: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 999px; box-shadow: var(--shadow); }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
/* Touch screens: no hover, so the toolbar stays visible, small, under the bubble */
@media (hover: none) { .msg-actions { position: static; display: flex; justify-self: end; margin-top: 2px; padding: 0; border: 0; background: none; box-shadow: none; } }

/* Bug cards posted by the robot in Bugs Dev */
.bug-card { min-width: 0; border: 1px solid var(--line-strong); border-radius: 16px; padding: 12px 14px 14px; color: var(--text);
  background: linear-gradient(180deg, rgba(var(--tint), .045), rgba(var(--tint), .015)), var(--ink); box-shadow: 0 16px 40px -28px rgba(0, 0, 0, .7); }
.bug-head { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 10px; min-width: 0; }
.bug-ico { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0; color: var(--ko);
  background: color-mix(in srgb, var(--ko) 13%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ko) 28%, transparent); }
.bug-ico .ico { width: 18px; height: 18px; }
.bug-title { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bug-title strong { font-family: var(--head); font-size: .92rem; line-height: 1.35; color: var(--fg); overflow-wrap: anywhere; }
.bug-key { font: 500 .7rem/1 var(--mono); letter-spacing: .04em; color: var(--muted); }
.bug-card dl { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px 9px; margin: 0 0 12px; font-size: .84rem; align-items: center; }
.bug-card dt { color: var(--faint); display: flex; }
.bug-card dt .ico { width: 15px; height: 15px; }
.bug-card dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bug-open .ico { width: 14px; height: 14px; }

/* Files */
.file { display: grid; gap: 6px; justify-items: start; min-width: 0; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; padding: 7px 12px 7px 10px; border-radius: 12px; cursor: pointer;
  font: inherit; font-size: .84rem; color: inherit; background: rgba(var(--tint), .05); border: 1px solid var(--line-strong); }
.file-chip:hover { background: rgba(var(--tint), .1); }
.file-chip .ico { width: 16px; height: 16px; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font: .7rem/1 var(--mono); opacity: .75; flex-shrink: 0; }
.msg.mine .file-chip { background: color-mix(in srgb, var(--on-fg) 8%, transparent); border-color: color-mix(in srgb, var(--on-fg) 22%, transparent); }
.file-image { max-width: min(420px, 100%); max-height: 320px; border-radius: 12px; display: block; }

/* Writing */
.typing { min-height: 1.5em; margin: 0; padding: 0 22px; flex: none; font-size: .78rem; color: var(--muted); }
@media (min-width: 900px) { .typing { padding: 0 34px; } }
.composer { flex: none; padding: 4px 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .composer { padding: 4px 28px 16px; } }
.composer-row { display: flex; gap: 6px; align-items: flex-end; padding: 6px; border-radius: 24px; border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .15s, box-shadow .15s; }
.composer-row:focus-within { border-color: rgba(var(--tint), .4); box-shadow: 0 0 0 4px rgba(var(--tint), .06), 0 16px 40px -24px rgba(10, 101, 231, .45); }
.composer-row textarea { flex: 1; border: 0; resize: none; background: transparent; min-height: 36px; max-height: 220px; padding: 7px 6px; line-height: 1.45; }
.composer-row textarea:focus { box-shadow: none; }
.attach-btn { cursor: pointer; }
.attach-input:focus-visible + .attach-btn { outline: 2px solid var(--fg); outline-offset: 2px; }
.send-btn .ico { width: 16px; height: 16px; transform: translateX(-1px); }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pending-files:empty { display: none; }
.composer-hint { display: flex; align-items: center; gap: 6px; margin: 6px 6px 0; font-size: .72rem; color: var(--faint); min-width: 0; }
.composer-hint .ico { width: 12px; height: 12px; color: var(--ok); }
.composer-hint span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 599.98px) { .composer-hint { display: none; } }
.empty-state { margin: auto; padding: 24px; display: grid; justify-items: center; gap: 14px; text-align: center; color: var(--muted); }
.empty-state p { margin: 0; }

/* ---------- Dialogs: above everything (top layer) ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dialog { background: var(--ink); border: 1px solid var(--line-strong); border-radius: 22px; width: min(560px, calc(100vw - 24px)); padding: 20px 22px 22px;
  max-height: min(88vh, 88dvh); overflow-y: auto; box-shadow: var(--shadow); }
.dialog > p { margin: 0 0 10px; }
.dialog-head { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; min-width: 0; }
.dialog-head h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-ico { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0; color: var(--fg);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bottom)); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 22px -12px rgba(138, 42, 227, .5), 0 8px 18px -10px rgba(10, 101, 231, .5); }
.dialog-ico .ico { width: 18px; height: 18px; }
@media (max-width: 599.98px) { .dialog { width: calc(100vw - 16px); padding: 16px; } }
.dialog .field { margin-top: 10px; }
.people-list { display: grid; gap: 2px; max-height: min(300px, 40vh); overflow-y: auto; margin: 10px 0; padding: 4px; border: 1px solid var(--line); border-radius: 14px; }
.person-check { display: flex; gap: 10px; padding: 6px 8px; border-radius: 10px; min-width: 0; }
.person-check:hover { background: rgba(var(--tint), .05); }
.person-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.person-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-user { font: .7rem/1.3 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-keys { display: inline-flex; color: var(--warn); } .no-keys .ico { width: 15px; height: 15px; }
.member-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 4px; }
.member-list li { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); min-width: 0; }
.member-name { flex: 1; min-width: 0; display: grid; gap: 3px; }
.member-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.member-line strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { display: flex; gap: 9px; align-items: flex-start; font-size: .8125rem; color: var(--muted); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(var(--tint), .03); }
.note .ico { width: 16px; height: 16px; color: var(--ko); margin-top: 1px; }
.share-add { display: flex; gap: 8px; margin: 12px 0; min-width: 0; }
.share-add select { flex: 1; }
.mute-check { margin-top: 4px; }
.set-block { padding: 14px 0; border-top: 1px solid var(--line); }
.set-block:first-of-type { border-top: 0; padding-top: 4px; }
.set-block h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; }
.set-ico { display: inline-flex; color: var(--muted); } .set-ico .ico { width: 16px; height: 16px; }
.set-block p:last-child { margin-bottom: 0; }

/* Toasts */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { margin: 0; background: var(--ink); color: var(--text); border: 1px solid var(--line-strong); border-radius: 999px; padding: 9px 16px; font-size: .875rem;
  box-shadow: var(--shadow); overflow-wrap: anywhere; }
.toast-ko { border-color: color-mix(in srgb, var(--ko) 55%, transparent); color: var(--ko); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .spinner { border-top-color: var(--line-strong); }
}
