/* boot:start - mirrored verbatim into boot.html, which cannot link this file without putting a request on
   the boot path. boot.test.ts compares the two blocks. Everything the boot screen needs to look identical
   to the shell's first frame belongs in here: while it lived in two hand-written places the mark ended up a
   different size, a few pixels off centre, restarting its pulse, and painting a broken-image placeholder. */
:root {
  color-scheme: dark;
  --bg: #11111b;
  --bg-glow: radial-gradient(max(50vw, 34rem) 34rem at 50% -10rem, #1e1e2e, var(--bg));
  --blur-light: blur(3px);
  --blur-medium: blur(9px);
  --blur-heavy: blur(18px);
  /* Dark glass darkens what it blurs so panels sit below the content they cover; light only blurs. */
  --glass-filter: var(--blur-medium) saturate(1.2) brightness(.75);
  /* One tint for every floating glass surface: menus, popovers, tooltips, toasts, banners, pickers, sheets. */
  --glass-tint: color-mix(in srgb, var(--panel) 74%, transparent);
  /* One tint for the fixed chrome: header, docked rooms rail, members panel and composer. */
  --glass-chrome: color-mix(in srgb, var(--panel) 60%, transparent);
  /* Tab bar: one step up from the glass chrome so it reads as its own surface. */
  --nav-surface: color-mix(in srgb, var(--panel-hi) 72%, transparent);
  --panel: #181825;
  /* The fixed header's height, in one place: the chat, the members panel, the pull chip and the banner
     sticky offset all have to clear it, and while they each wrote it out the phone banners ended up
     hidden behind the header. */
  --header-h: calc(3.625rem + env(safe-area-inset-top, 0px));
  --boot-mark: 7rem;
  --z-boot-screen: 102;
  --panel-hi: #313244;
  --text: #cdd6f4;
  --muted: #7f849c;
  --line: var(--panel-hi); /* same tone as panel-hi today; change here to separate borders from surfaces */
  --brand: #a6e3a1;
  --accent: var(--brand);
  --mine: #94e2d5;
  --danger: #f38ba8;
  --brand-fill: #a6e3a1;
  --on-brand: #11111b;
  --mention-fill: color-mix(in srgb, var(--brand) 16%, transparent);
  --mention-ink: var(--brand);
  --shadow: #0008;
  --shadow-sm: 0 .3rem .9rem #0006;
  --shadow-md: 0 .5rem 1.5rem #0009;
  --shadow-lg: 0 1.5rem 5rem #000b;
  --active-fill: color-mix(in srgb, var(--brand) 13%, transparent);
  --active-ring: transparent;
  --mention-me-fill: color-mix(in srgb, var(--mine) 22%, transparent);
  --avatar-fill: var(--panel-hi);
  --secondary-fill: var(--panel-hi);
  --secondary-fill-hover: color-mix(in srgb, var(--panel-hi) 85%, var(--text));
  --disabled-opacity: .5;
  --warning: #f9e2af;
  --attention: #fab387;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius-xs: .25rem;
  --radius-sm: .4rem;
  --radius-md: .55rem;
  --radius-lg: .75rem;
  --radius-xl: 1rem;
  --radius-pill: 999px;
  --radius-round: 50%;
  /* Six type steps. Off-scale on purpose: glyphs under .65rem sized to their fixed container (avatar
     initials, badge digits, agent marks), the 1.75rem and 2rem display sizes, em sizes that follow their
     parent, and px sizes. */
  --text-2xs: .6875rem;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, monospace;
  --ease-standard: cubic-bezier(.2,.7,.2,1);
  --dur-boot-pop: .45s;
  --dur-boot-exit: .15s;
  --dur-reaction: .38s;
  /* Five motion steps. Loops (spinners, pulses, the focus flash), stagger delays and the .06s press snap
     stay literal. */
  --dur-micro: .1s;
  --dur-fast: .15s;
  --dur-base: .2s;
  --dur-entrance: .3s;
  --dur-reveal: .5s;
}
@media (max-width: 500px) { :root { --boot-mark: 5rem; } }

@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .boot-screen img { animation: none; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }
html { background: var(--bg); }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-glow);
  color: var(--text);
  font: var(--text-base)/1.45 var(--ui);
}
/* Lives outside Alpine (x-ignore) and pinned to the compositor: boot classes sit on <html>, so the
   spinner keeps its layer while Alpine walks the body and the shell paints beneath it. */
.boot-screen {
  position: fixed;
  z-index: var(--z-boot-screen);
  /* The small viewport rather than inset: 0. The layout viewport grows and shrinks with the iOS URL bar,
     and the two documents commit at different moments in that dance, which moves a centred mark. svh is
     stable across it, so the mark lands in the same place in both documents. */
  top: 0;
  left: 0;
  right: 0;
  height: 100svh;
  display: grid;
  place-items: center;
  contain: strict;
  will-change: opacity;
  background: var(--bg-glow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-reveal) ease-in-out, visibility 0s linear var(--dur-reveal);
}
/* A slow pulse, not a spin: a dropped frame in a rotation shows as a jump, in an opacity ramp it does not. */
.boot-screen img { width: var(--boot-mark); height: var(--boot-mark); will-change: opacity; animation: boot-logo 1.6s ease-in-out infinite; animation-delay: var(--boot-pulse-delay, 0s); }
/* Pull-to-refresh on the way out: the boot screen fades in over the faded list, and the reload continues it. */
html.leaving .boot-screen { opacity: 1; visibility: visible; transition-delay: 0s; }
@keyframes boot-logo { 50% { opacity: .2; } }
.auth-card .login-logo {
  filter: none;
  display: block;
  margin-inline: auto;
  will-change: transform;
}
html.booting .auth-card .login-logo { opacity: 0; transform: perspective(900px) rotateY(180deg) scale(.96); }
html.booting body > :not(.boot-screen):not(.auth-modal) { visibility: hidden; }
html.booting .boot-screen { opacity: 1; visibility: visible; transition-delay: 0s; }
/* boot:end */
/* Current shell boots directly; keep the legacy document's pulse/handoff unchanged.
   Keep the finite animation independent of .booting so readiness cannot snap it back during exit. */
body[data-client-root] > .boot-screen { transition: opacity var(--dur-boot-exit) ease-out, visibility 0s linear var(--dur-boot-exit); }
html.booting body[data-client-root] > .boot-screen { transition: none; }
body[data-client-root] > .boot-screen img { animation: none; will-change: auto; }
@media (prefers-reduced-motion: no-preference) {
  body[data-client-root] > .boot-screen img { animation: boot-pop var(--dur-boot-pop) ease-out 1; }
}
@media (prefers-reduced-motion: reduce) {
  body[data-client-root] > .boot-screen { transition: none; }
}
@keyframes boot-pop {
  0% { transform: scale(.8) rotate(-12deg); }
  65% { transform: scale(1.08) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}
/* Native <details> opens and closes smoothly instead of snapping. `interpolate-size` makes the
   `auto` keyword animatable, and transitioning `content-visibility` with `allow-discrete` keeps the
   content painted through the closing frame. Engines without `::details-content` keep today's
   instant open/close, so this is a progressive enhancement with no JS, timers or height math. */
@supports selector(details::details-content) and (interpolate-size: allow-keywords) {
  details { interpolate-size: allow-keywords; }
  details::details-content {
    content-visibility: hidden;
    block-size: 0;
    overflow: clip;
    overflow-clip-margin: .25rem;
    transition: block-size var(--dur-base) var(--ease-standard), content-visibility var(--dur-base) allow-discrete;
  }
  details[open]::details-content {
    content-visibility: visible;
    block-size: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  details::details-content { transition: none; }
}
/* Overlay ladder. Viewport menus mount outside the clipped navigation rail. */
:root {
  --z-content: 1; --z-local: 2; --z-control: 3; --z-sticky: 6; --z-message: 7; --z-bottom-panel: 15;
  --z-side-panel: 19; --z-header: 20; --z-docked-sidebar: 21; --z-docked-header: 22; --z-mobile-screen: 24;
  --z-sidebar: 25; --z-profile-control: 26; --z-pull-indicator: 27; --z-popover: 30; --z-sheet-backdrop: 40;
  --z-mobile-sheet: 45; --z-floating: 60; --z-floating-panel: 61; --z-overlay: 70; --z-toast: 80;
  --z-navigation-menu: 90; --z-navigation-submenu: 91; --z-dialog: 100; --z-boot-dialog: 101;
  --z-tooltip: 120;
}
html.booting .auth-modal { z-index: var(--z-boot-dialog); background: transparent; backdrop-filter: none; }
html.booting .auth-card { border-color: transparent; background: transparent; box-shadow: none; }
html.booting .auth-card > :not(.login-logo) { visibility: hidden; opacity: 0; pointer-events: none; }
html.boot-modal-revealing body > :not(.boot-screen):not(.auth-modal):not(script) { visibility: hidden; }
html.boot-modal-revealing .auth-modal { animation: modal-reveal var(--dur-reveal) ease-in-out both; }
html.boot-modal-revealing .auth-card { animation: card-reveal var(--dur-reveal) ease-in-out both; }
html.boot-modal-revealing .auth-card > :not(.login-logo) { animation: page-reveal var(--dur-reveal) ease-in-out both; }
html.boot-page-revealing body > :not(.boot-screen):not(.auth-modal):not(script) { animation: page-reveal var(--dur-reveal) ease-in-out both; }
/* Signed-in load: the shell is painted under the boot screen for a couple of frames first, so the
   reveal is one composited fade of that screen rather than the app's cold first paint. */
html.boot-warming body > :not(.boot-screen):not(.auth-modal):not(script) { visibility: visible; }
html.boot-page-revealing.boot-warming body > :not(.boot-screen):not(.auth-modal):not(script) { animation: none; }
html.boot-page-revealing .boot-screen { opacity: 0; visibility: hidden; }
@keyframes page-reveal { from { opacity: 0; } }
/* Boot as a view transition: the logo snapshot crossfades into the finished shell over .5s. Entrance
   animations stay off while it runs, so nothing moves under the fade. */
html[data-transition="boot"]::view-transition-old(root), html[data-transition="boot"]::view-transition-new(root) { animation-duration: var(--dur-reveal); animation-timing-function: ease-in-out; }
html.boot-vt .history-settled .channel-intro, html.boot-vt .history-settled .msg, html.boot-vt .history-settled .date-divider, html.boot-vt .history-settled .public-channel-intro, html.boot-vt .history-settled .history-event, html.boot-vt .mobile-screen .mobile-row { animation: none; }
@keyframes modal-reveal { from { background: transparent; backdrop-filter: blur(0); } }
@keyframes card-reveal { from { border-color: transparent; background: transparent; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) {
  html.boot-modal-revealing *, html.boot-page-revealing * { animation: none !important; }
}

header {
  position: fixed;
  z-index: var(--z-header);
  inset: 0 0 auto;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  /* Blur only, on every shell: messages scroll under it, and a tint would show as a band over the page. */
  background: transparent;
  backdrop-filter: var(--blur-medium);
  -webkit-backdrop-filter: var(--blur-medium);
}
header .brand {
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}
header .brand { min-width: 2.75rem; min-height: 2.75rem; display: grid; place-items: center; }
header .brand svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.header-logo { display: inline-flex; align-items: center; gap: .3rem; color: var(--text); text-decoration: none; }
.header-logo .header-mark { width: 1.25rem; height: 1.25rem; }
.header-logo .header-wordmark { width: auto; height: .85rem; }
.room-heading { min-width: 0; margin-left: auto; display: grid; justify-items: end; }
.room-heading-main { min-width: 0; display: flex; align-items: center; gap: .65rem; }
.room-title { display: inline-flex; align-items: center; gap: .45rem; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
/* A two-line agent title starts level with its avatar; one-line headers keep the old centring. */
header .room-title:has(.room-subtitle:not(:empty)) > .room-mark { align-self: flex-start; }
.room-title.direct { color: var(--muted); }
.room-title:disabled { opacity: 1; cursor: default; }
.rooms-toggle { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: 0 0 auto; padding: 0; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.rooms-toggle:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.rooms-toggle:focus-visible { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); outline: 2px solid var(--brand); outline-offset: 2px; }
/* The workspace mark: which workspace this is, at the top of the docked sidebar, left of its
   toggle. It opens the workspace dialog (workspace-dialog.html). */
.workspace-mark { position: absolute; top: 50%; left: .6rem; translate: 0 -50%; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: var(--radius-md); background: transparent; cursor: pointer; opacity: .5; transition: opacity var(--dur-fast) ease, background-color var(--dur-fast) ease; }
/* Quiet until wanted: full strength on hover, keyboard focus, and while the dialog is open. */
.workspace-mark:hover, .workspace-mark:focus-visible, .workspace-mark[aria-expanded="true"] { opacity: 1; }
.workspace-mark:hover, .workspace-mark:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); }
.workspace-mark:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.workspace-badge { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: 6px; color: #11111b; font: 750 .72rem/1 var(--ui); }
.workspace-badge.logo { background: transparent; }
:root[data-theme="light"] .workspace-badge:not(.logo) { box-shadow: inset 0 0 0 1px rgb(17 17 27 / .12); }
.workspace-badge img { width: 100%; height: 100%; object-fit: contain; }
.workspace-badge.icon img { object-fit: cover; border-radius: inherit; }
/* The workspace dialog: rows like the iOS picker's cards, then a field for any other address. */
.notice-card.workspace-card { text-align: left; }
.workspace-card h2 { margin-top: 0; }
.workspace-list { display: grid; gap: .25rem; margin: 1rem 0; }
.workspace-row { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 3.15rem; padding: .55rem .65rem; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--text); text-align: left; font: var(--text-base)/1.15 var(--ui); cursor: pointer; }
.workspace-row:hover, .workspace-row:focus-visible, .workspace-row[aria-current="true"] { background: color-mix(in srgb, var(--text) 7%, transparent); }
/* Lime marks keyboard focus only. The current row has the Current pill and no outline. .kb-focus: see installWorkspaceKeys. */
.workspace-row.kb-focus:focus { background: color-mix(in srgb, var(--text) 7%, transparent); }
.workspace-row:focus-visible, .workspace-row.kb-focus:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.workspace-row .workspace-badge, .workspace-row-more .workspace-badge { width: 1.75rem; height: 1.75rem; border-radius: 8px; font-size: .9rem; }
.workspace-row-main { display: grid; gap: .15rem; min-width: 0; flex: 1; }
.workspace-row-main strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-row-main small { color: var(--muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-row-end { width: 1rem; height: 1rem; flex: 0 0 auto; color: var(--muted); }
/* The iOS picker's "Current" tag (native/www/index.html .tag): a brand pill. */
.workspace-current { flex: none; padding: .15rem .45rem; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand); font: 600 .6875rem/1.2 var(--ui); }
.workspace-row-end svg { width: 100%; height: 100%; }
.workspace-form label { display: block; color: var(--muted); font-size: var(--text-sm); }
.workspace-form-row { display: flex; align-items: center; gap: .5rem; }
.workspace-form-row .agent-rename-input { flex: 1; min-width: 0; }
.workspace-form-row .btn-primary { flex: 0 0 auto; min-height: 2.75rem; }
/* Mac app (desktop/ sets the class): the window controls float over the header's left end, as in
   Slack. The header takes the 52px height of the title bar they sit in, the logo gives them its place,
   and with the sidebar collapsed the toggle and title start after them. */
html.mac-shell { --header-h: 3.25rem; }
html.mac-shell .header-logo { display: none; }
/* The badge starts .75rem after the green window button, which ends at 78px. */
html.mac-shell .workspace-mark { left: 5.125rem; }
html.mac-shell body.rooms-docked .rooms-toggle { left: calc(15rem - 2.35rem); width: 2rem; }
html.mac-shell body:not(.rooms-docked) .rooms-toggle { left: 5rem; }
html.mac-shell body:not(.rooms-docked) header { padding-left: max(8rem, calc((100vw - 860px) / 2)); }
/* A sign-in link opens in the default browser and signs in the browser, not the app, so inside the
   app the email's code is the only way the sign-in screen offers. */
html.mac-shell .email-link-hint { display: none; }
/* The Mac window's corners have a 26pt radius (macOS 26, a window with a unified toolbar). Inside
   the app the composer and the bottom-left profile card sit 8px from the window's edges with an
   18px radius (26 - 8), so each corner shares the window corner's centre and keeps a thin, even gap
   along the curve. A 10px curve 16px in read as a sharp box. The send button, a 40px circle 9px
   inside the composer, stays clear of the curve. */
html.mac-shell .composer, html.mac-shell .composer.tall { bottom: 8px; border-radius: 18px; }
html.mac-shell body.rooms-docked:not(.members-docked) .composer { right: 8px; }
html.mac-shell .panel-footer { left: 8px; bottom: 8px; width: calc(min(300px, 100vw - 28px) - 22px); }
html.mac-shell body.rooms-docked .panel-footer { left: 8px; bottom: 8px; width: calc(15rem - 22px); }
html.mac-shell .profile-card { border-radius: 18px; }
.room-mark { position: relative; width: 1.5rem; height: 1.5rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--radius-round); background: var(--panel-hi); color: var(--muted); font: 750 var(--text-sm)/1 var(--ui); transition: opacity var(--dur-fast) ease; }
/* A muted channel keeps its name legible and dims the mark: quieter, not gone. */
.muted-room .room-mark { opacity: .4; }
.room-mark img { width: 100%; height: 100%; border-radius: var(--radius-round); object-fit: cover; }
::view-transition-group(root), ::view-transition-group(mobile-nav) { animation-duration: var(--dur-base); }
/* Phone: the chat header and the tab heads share one name, so a tab <-> chat move morphs the bar
   instead of sliding it with the page. Only one of them is displayed at a time (x-show), which the
   API requires. */
@media (pointer: coarse) {
  header, .mobile-screen-head { view-transition-name: header; }
  ::view-transition-group(header) { animation-duration: var(--dur-base); animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
  html[data-transition="forward"]::view-transition-old(header), html[data-transition="back"]::view-transition-old(header) { animation: var(--dur-fast) ease both vt-fade-out; }
  html[data-transition="forward"]::view-transition-new(header), html[data-transition="back"]::view-transition-new(header) { animation: var(--dur-fast) ease both vt-fade-in; }
}
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
html[data-transition="forward"]::view-transition-old(root) { animation: var(--dur-base) ease both vt-forward-out; }
html[data-transition="forward"]::view-transition-new(root) { animation: var(--dur-base) ease both vt-forward-in; }
html[data-transition="back"]::view-transition-old(root) { animation: var(--dur-base) ease both vt-back-out; }
html[data-transition="back"]::view-transition-new(root) { animation: var(--dur-base) ease both vt-back-in; }
html[data-transition="tab"]::view-transition-old(root) { animation: var(--dur-fast) ease both vt-tab-out; }
html[data-transition="tab"]::view-transition-new(root) { animation: var(--dur-base) ease both vt-tab-in; }
html[data-transition="tab"]::view-transition-old(mobile-nav), html[data-transition="tab"]::view-transition-new(mobile-nav) { animation: none; }
@keyframes vt-forward-out { to { opacity: .55; transform: translateX(-12%); } }
@keyframes vt-forward-in { from { transform: translateX(100%); } }
@keyframes vt-back-out { to { transform: translateX(100%); } }
@keyframes vt-back-in { from { opacity: .55; transform: translateX(-12%); } }
@keyframes vt-tab-out { to { opacity: 0; transform: translateY(3px); } }
@keyframes vt-tab-in { from { opacity: 0; transform: translateY(3px); } }
.room-title-text { display: grid; min-width: 0; }
.thread-title-rich { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title-seg { display: inline; }
.thread-title-rich code { padding: .08em .25em; border-radius: var(--radius-xs); background: color-mix(in srgb, var(--panel-hi) 72%, transparent); font: .9em/1 var(--mono); }
.thread-title-quote { margin-right: .25rem; padding-left: .35rem; border-left: 2px solid color-mix(in srgb, var(--brand) 70%, transparent); color: var(--muted); font-style: italic; }
.thread-title-rich a { color: inherit; text-decoration: underline; }
.room-subtitle { display: none; }
.thread-parent-link { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .25rem; padding: .15rem 0; border: 0; background: none; color: var(--muted); font: 500 var(--text-xs)/1.2 var(--ui); cursor: pointer; }
.thread-parent-link:hover, .thread-parent-link:focus-visible { color: var(--text); }
.thread-parent-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-xs); }
.thread-parent-link .menu-icon { width: .8rem; height: .8rem; }
.room-title-chevron { display: none; }
.system-table { width: 100%; border-collapse: collapse; margin-top: .25rem; font: var(--text-sm)/1.35 var(--ui); }
.system-table th { text-align: left; padding: .2rem .5rem; color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line); }
.system-table td { padding: .35rem .5rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); vertical-align: top; }
.system-table td:first-child { color: var(--brand); white-space: nowrap; }
.system-table td:nth-child(2) { color: var(--muted); text-align: right; }
.system-table tbody tr { cursor: pointer; }
.system-table tbody tr:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.recent-contacts { display: flex; gap: .25rem; padding: .25rem .25rem .5rem; overflow-x: auto; scrollbar-width: none; }
.recent-contacts::-webkit-scrollbar { display: none; }
.recent-contact { display: grid; justify-items: center; gap: .3rem; min-width: 3.9rem; padding: .35rem .25rem; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--muted); font: 600 var(--text-2xs)/1 var(--ui); }
.recent-contact .room-mark { width: 2.75rem; height: 2.75rem; }
.recent-contact small { max-width: 3.6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-2xs); }
.mobile-collapsible > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .35rem; min-height: 2.75rem; margin: .5rem .65rem 0; }
.mobile-collapsible > summary::-webkit-details-marker { display: none; }
/* Chevron on the right, like the Home section toggles. Open points down, closed points right. */
.mobile-collapsible > summary::after { content: ""; width: .45rem; height: .45rem; margin-left: auto; margin-right: .3rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: -45deg; transition: rotate var(--dur-fast) ease; }
.mobile-collapsible[open] > summary::after { rotate: 45deg; }
.room-topic { max-width: min(46vw, 32rem); overflow: hidden; padding: 0; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: var(--text-2xs); line-height: 1.15; text-align: right; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.room-topic.expanded { white-space: normal; overflow-wrap: anywhere; }
.channel-menu-topic { display: none; }
/* Quiet connection line in the header (instant.md: connection is background state, never a
   blocking screen). Only rendered at all while disconnected (app.js's x-show on #status). */
header .status { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: var(--text-xs); }
/* Connecting stays at full strength in the brand green while connecting-dim fades the chat behind it. */
header .status:not(.err) { color: var(--brand); font-weight: 600; }
header .status:not(.err) .status-spinner { opacity: 1; }
header .status.err { color: var(--danger, #d33); }
.status-spinner { width: .65rem; height: .65rem; border-radius: var(--radius-round); border: 1.5px solid currentColor; border-top-color: transparent; opacity: .7; animation: status-spin .8s linear infinite; }
@keyframes status-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status-spinner { animation: none; } }
/* Connecting dim (connecting-dim.ts): chat surfaces fade to half while the socket connects. The
   header and its status line stay full strength. Input stays live; the outbox queues it. */
body.connecting-dim :is(#chat, #composer, #rooms, #members-panel, #links-view, [data-phone-screen="home"], [data-phone-screen="dms"]) { opacity: .5; animation: connecting-dim-in var(--dur-base) var(--ease-standard); }
@keyframes connecting-dim-in { from { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { body.connecting-dim :is(#chat, #composer, #rooms, #members-panel, #links-view, [data-phone-screen="home"], [data-phone-screen="dms"]) { animation: none; } }
.login .status { display: block; color: var(--muted); font-size: var(--text-sm); }
header select, header button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-hi);
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
}
header button { cursor: pointer; }
header > .header-icon, .notification-control {
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  padding: 0;
}
.notification-control { position: relative; }
/* Ghost toggle on every layout, like .mobile-back; without this phones get the filled header button. */
header > .members-toggle { border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); }
header > .members-toggle.active { color: var(--text); }
header .room-title { border: 0; background: none; padding: 0; }
/* Offer, not a permanent fixture: one slim row above the conversation, dismissible. */

/* Pull-to-refresh chip: rides under the header on any phone screen, follows the finger.
   Same glass as the notify banner (blur + brightness). No shadow, no keyframe animation: the arrow
   turns with the pull and flips fully up at the threshold. */
.pull-indicator { position: fixed; z-index: var(--z-pull-indicator); top: var(--header-h); left: 50%; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: var(--radius-round); background: var(--glass-tint); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); color: var(--muted); translate: -50% -2.75rem; opacity: 0; pointer-events: none; will-change: transform, opacity; transition: opacity var(--dur-base) var(--ease-standard); }
.pull-indicator.pulling { opacity: .85; }
.pull-indicator.ready { opacity: 1; color: var(--brand); }
.pull-arrow { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; will-change: transform; }
/* Past the threshold the chevron flips over its horizontal axis to point up: release here reloads. */
.pull-indicator.ready .pull-arrow { transform: rotateX(180deg) !important; transition: transform var(--dur-base) var(--ease-standard); }
@media (prefers-reduced-motion: reduce) { .pull-indicator.ready .pull-arrow { transition: none; } }
/* Released: the list fades under the spinner while the page reloads. Opacity only. */
body.refreshing #messages, body.refreshing .mobile-screen-body { opacity: 0; transition: opacity var(--dur-base) ease; }
body.refreshing .pull-indicator { opacity: 1; }
/* Safari turns a downward drag at the top into its own page reload; we handle the gesture. */
@media (pointer: coarse) { html, body { overscroll-behavior: none; } .chat { overscroll-behavior-y: contain; } }
/* top 0 is the chat's content edge, which sits below the header (see .chat), so the banner pins
   where it rests instead of behind the header. */
.notify-banner { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: .55rem; margin: 0 0 .35rem; padding: .5rem .55rem .5rem .7rem; border: 0; border-radius: var(--radius-md); background: var(--glass-tint); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); color: var(--text); font: var(--text-sm)/1.35 var(--ui); }
.notify-banner p { flex: 1; min-width: 0; margin: 0; }
.notify-banner-close { flex: 0 0 auto; width: 1.75rem; height: 1.75rem; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.notify-banner-close:hover, .notify-banner-close:focus-visible { background: var(--panel-hi); color: var(--text); }
.notify-banner-close svg { width: .95rem; height: .95rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.install-banner span { flex: 1; min-width: 0; }
.install-banner a { color: var(--brand); font-weight: 600; text-decoration: none; }
/* Verification reminder: a banner rather than a dialog, so the code field sits inline and the whole
   thing can be dismissed without losing the header button that brings it back. */
.verify-banner { align-items: flex-start; }
.verify-body { flex: 1; min-width: 0; display: grid; gap: .3rem; }
.verify-body p { margin: 0; }
.verify-code { display: flex; align-items: center; gap: .4rem; }
.verify-code input { min-width: 0; flex: 1; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: inherit; font-size: var(--text-sm); }
.verify-code input:focus { border-color: var(--brand); outline: none; }
.verify-resend { flex: 0 0 auto; padding: .3rem .1rem; border: 0; background: none; color: var(--muted); font: inherit; font-size: var(--text-sm); text-decoration: underline; cursor: pointer; }
.verify-resend:hover, .verify-resend:focus-visible { color: var(--text); }
.verify-note { color: var(--brand); font-size: var(--text-xs); }
.verify-error { color: var(--danger); font-size: var(--text-xs); }
.header-dms { position: relative; display: flex; align-items: center; min-height: 2.75rem; padding: 0 .35rem; }
.header-dm { position: relative; width: 1.9rem; height: 1.9rem; margin-left: -.55rem; padding: 0; border: 0; border-radius: var(--radius-round); background: var(--panel-hi); color: var(--text); font: 700 var(--text-2xs)/1 var(--ui); cursor: pointer; }
.header-dm:first-child { margin-left: 0; }
.header-dm img { width: 100%; height: 100%; border-radius: var(--radius-round); object-fit: cover; }
.header-dm { box-shadow: 0 0 0 .18rem var(--panel); }
.header-dm-more { display: grid; place-items: center; }
.header-dm-count { position: absolute; top: -.2rem; right: -.2rem; min-width: .95rem; height: .95rem; padding: 0 .2rem; border: 2px solid var(--panel); border-radius: var(--radius-pill); background: var(--brand); color: var(--bg); font: 750 .55rem/.75rem var(--ui); text-align: center; }
.header-dm-list { position: absolute; z-index: var(--z-popover); top: calc(100% + .35rem); left: 0; min-width: 12rem; display: grid; padding: .35rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--glass-tint); box-shadow: var(--shadow-md); }
.header-dm-list button { display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; padding: 0 .6rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font: var(--text-sm)/1 var(--ui); text-align: left; cursor: pointer; }
.header-dm-list button:hover { background: var(--panel-hi); }
.header-dm-list img { width: 1.5rem; height: 1.5rem; border-radius: var(--radius-round); object-fit: cover; }
.header-dm-list small { margin-left: auto; color: var(--muted); }
header button svg, .message-add svg { display: block; width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.settings-toggle.busy::after { border-top-color: var(--brand); }
.header-tooltip {
  position: fixed;
  z-index: var(--z-floating);
  width: max-content;
  max-width: min(18rem, calc(100vw - 2rem));
  padding: .55rem .7rem;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--panel-hi) 82%, transparent);
  color: var(--text);
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--blur-light) saturate(1.2);
  font: var(--text-xs)/1.3 var(--ui);
  pointer-events: none;
}
header select { max-width: 10.5rem; }

.rooms {
  position: fixed;
  z-index: var(--z-sidebar);
  inset: 0;
  background: #0006;
  backdrop-filter: var(--blur-light);
}
.rooms-enter, .rooms-leave { transition: opacity var(--dur-base) var(--ease-standard); }
.rooms-enter .rooms-sheet, .rooms-leave .rooms-sheet { transition: translate var(--dur-base) var(--ease-standard); }
.rooms-hidden { opacity: 0; }
.rooms-hidden .rooms-sheet { translate: -100% 0; }
.rooms-visible { opacity: 1; }
.rooms-visible .rooms-sheet { translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .rooms-enter, .rooms-leave, .rooms-enter .rooms-sheet, .rooms-leave .rooms-sheet { transition: none; } }
/* Desktop: the sidebar docks as a fixed rail and the chat leans right of it. */
/* ponytail: rail is 15rem (240px); keep the rail width in one place if it ever varies. */
@media (not (pointer: coarse)) {
  .composer-plus { order: -1; }
  body.rooms-docked .rooms { background: transparent; backdrop-filter: none; z-index: var(--z-docked-sidebar); pointer-events: none; }
  body.rooms-docked .rooms-sheet { translate: none !important; box-shadow: none; opacity: 1 !important; width: 15rem; background: var(--glass-chrome); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); pointer-events: auto; }
  body.rooms-docked header { z-index: var(--z-docked-header); padding-inline: calc(15rem + 1rem) 1rem; }
  /* Desktop header: channel name and topic lead on the left, bell and unread DMs sit on the right. */
  .room-heading { order: -1; margin-left: 0; margin-right: auto; justify-items: start; }
  .room-title { color: var(--text); }
  .room-title-text { justify-items: start; text-align: left; line-height: 1.2; }
  .room-title-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .room-subtitle { display: block; overflow: hidden; max-width: min(46vw, 34rem); color: var(--muted); font-size: var(--text-xs); font-weight: 400; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
  /* 8. Send button fades on desktop; Enter sends. */
  .composer .composer-send { opacity: .2; transition: opacity var(--dur-fast) ease, transform var(--dur-micro) ease; }
  .composer .composer-send:disabled { opacity: .12; }
  .composer:focus-within .composer-send:not(:disabled), .composer .composer-send:not(:disabled):hover, .composer .composer-send:focus-visible { opacity: 1; }
  /* 3. Nick in the UI sans, body stays mono. */
  .chat .msg .nick { font-family: var(--ui); font-size: .92em; font-weight: 500; letter-spacing: .01em; }
  /* 4. Lighter mention chips. */
  /* Mentions read as coloured text on desktop and brighten on hover. Opacity carries the cue because the
     mention of your own nick already has a background, which a hover background alone cannot override. */
  .chat .msg .body .mention { padding: .1rem .35rem; background: transparent; font-weight: 500; opacity: .72; transition: opacity var(--dur-micro) ease, background-color var(--dur-micro) ease; }
  .chat .msg .body .mention:hover, .chat .msg .body .mention:focus-visible { background: color-mix(in srgb, var(--brand) 20%, transparent); opacity: 1; }
  .chat .msg .body .mention.me { background: color-mix(in srgb, var(--mine) 14%, transparent); }
  /* 5. Room list scrolls fully clear of the fixed footer. */
  body.rooms-docked .rooms-sheet { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  .header-logo { position: absolute; left: 1rem; top: 50%; display: inline-flex; align-items: center; gap: .4rem; padding: 0; translate: 0 -50%; }
  .header-logo .header-mark { width: 1.5rem; height: 1.5rem; }
  .header-logo .header-wordmark { width: auto; height: 1rem; }
  /* Dedicated sidebar toggle: on the header row beside the mark, right-aligned inside the 15rem
     rail when open; it stays in the header (not the sidebar) so it is reachable while collapsed. */
  .rooms-toggle { position: absolute; top: 50%; left: 4.75rem; translate: 0 -50%; }
  body.rooms-docked .rooms-toggle { left: calc(15rem - 2.65rem); }
  /* Public read-only: header content sits on the 860px chat column edges, title on the right. */
  body.rooms-docked header.public { padding-inline: max(1rem, calc((100% - 860px) / 2 + 1rem)); }
  header.public .header-logo { position: static; translate: none; }
  header.public .room-heading { order: 0; margin-left: auto; margin-right: 0; justify-items: end; }
  header.public .room-title-text { justify-items: end; text-align: right; }
  body.rooms-docked .chat { left: calc(15rem + 1rem); right: 1rem; width: auto; margin-inline: 0; }
  body.rooms-docked .composer, body.rooms-docked .composer.tall, body.rooms-docked .archived-channel { left: calc(15rem + 1rem); right: 1rem; width: auto; translate: none; }
  /* Members panel: a 15rem right rail; chat and composer give way. The toggle runs inside a view
     transition (see toggleMembers): the rail's own group slides, the root crossfades the re-wrapped
     text. No CSS transition on the chat's edge, that re-laid out every line per frame. */
  .members-panel { view-transition-name: members; }
  ::view-transition-group(members) { animation-duration: var(--dur-entrance); animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
  html[data-transition="members"]::view-transition-old(root), html[data-transition="members"]::view-transition-new(root) { animation-duration: var(--dur-base); }
  /* The pill centres over the composer, which spans 16rem to 1rem with the sidebar docked. */
  body.rooms-docked .new-below { left: calc(50% + 7.5rem); }
  /* Members rail gives way on both left-sidebar states; narrow screens overlay instead (below). */
  @media (min-width: 1100px) {
    body.rooms-docked.members-docked .chat, body.rooms-docked.members-docked .composer, body.rooms-docked.members-docked .composer.tall, body.rooms-docked.members-docked .archived-channel { right: calc(15rem + 1rem); }
    body.members-docked:not(.rooms-docked) .chat, body.members-docked:not(.rooms-docked) .composer, body.members-docked:not(.rooms-docked) .composer.tall, body.members-docked:not(.rooms-docked) .archived-channel { left: 1rem; right: calc(15rem + 1rem); width: auto; margin-inline: 0; translate: none; }
    body.rooms-docked.members-docked .new-below { left: 50%; }
    body.members-docked:not(.rooms-docked) .new-below { left: calc(50% - 7.5rem); }
  }
  .members-panel { position: fixed; z-index: var(--z-side-panel); top: var(--header-h); right: 0; bottom: 0; width: 15rem; overflow-y: auto; padding: .75rem .6rem 1.5rem; translate: 100% 0; pointer-events: none; background: var(--glass-chrome); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); scrollbar-width: none; }
  .members-panel.open { translate: 0 0; pointer-events: auto; }
  .members-panel::-webkit-scrollbar { display: none; }
  /* Right cluster order: unread DMs, bell, members. */
  .header-dms { order: 1; }
  .notification-control { order: 2; }
  header > .members-toggle { order: 3; }
  header > .members-toggle { flex: 0 0 2.25rem; width: 2.25rem; height: 2.25rem; }
  header > .members-toggle:hover, header > .members-toggle:focus-visible { background: var(--panel-hi); color: var(--text); outline: none; }
  header > .members-toggle .members-icon { width: 1.2rem; height: 1.2rem; }
  header > .members-toggle.active { color: var(--text); background: transparent; }
  /* Narrow desktop: the members rail overlays instead of squeezing the message column. */
  @media (max-width: 1099px) {
    .members-panel.open { box-shadow: var(--shadow-md); }
  }
}
@media (not (pointer: coarse)) {
  .channel-row { border-radius: 6px; }
  .channel-row > .room { background: transparent; }
  .channel-row > .room:hover, .channel-row > .room.active { background: transparent; }
  .channel-row:hover { background: color-mix(in srgb, var(--panel-hi) 55%, transparent); }
  .channel-row:has(.room.active) { background: var(--bg); }
  .channel-row:has(.room.active):hover { background: color-mix(in srgb, var(--bg) 90%, #000); }
  .channel-row:has(.room.active) .room { color: var(--text); }
  .channel-row:has(.room.active) .room small { color: var(--muted); }
  /* The ring marks the room you are in. Bot glyphs keep their own shape, so it draws as a square box on them. */
  .room.active .room-mark:not(:has(img[src^="data:image/svg+xml"])):not(:has(img[src^="/icons/agents/"])) { box-shadow: 0 0 0 2px var(--brand); }
  .room.active.draft-room, .room.active.thread-room { background: var(--bg); color: var(--text); }
  .room.active.draft-room:hover, .room.active.thread-room:hover { background: color-mix(in srgb, var(--bg) 90%, #000); }
  /* The kebab floats over the row's right edge, so unread badges line up with the section +. On
     hover the kebab takes the badge's place and the name makes room for it. */
  .channel-kebab { position: absolute; right: 4px; top: 50%; translate: 0 -50%; opacity: 0; transition: opacity var(--dur-micro) var(--ease-standard); }
  .channel-row:hover .channel-kebab, .channel-row:focus-within .channel-kebab { opacity: 1; }
  .channel-row:has(.channel-kebab):hover > .room, .channel-row:has(.channel-kebab):focus-within > .room { padding-right: calc(2rem + 8px); }
  .channel-row .unread-badge { margin-right: -2px; } /* rows pad 10px, the section + sits 8px in */
  .channel-row:has(.channel-kebab):hover .unread-badge, .channel-row:has(.channel-kebab):focus-within .unread-badge { visibility: hidden; }
}
.rooms-sheet {
  width: min(300px, calc(100vw - 28px));
  height: 100%;
  min-height: 100%;
  display: flex;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-direction: column;
  padding: calc(4rem + env(safe-area-inset-top, 0px)) 14px calc(5rem + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--panel) 72%, var(--panel-hi));
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--blur-medium) saturate(1.1);
}
.rooms-sheet::-webkit-scrollbar { display: none; }
.section-title { position: relative; display: flex; align-items: center; gap: .25rem; width: 100%; margin: 16px 0 7px; padding: 0 10px 0 1.55rem; border: 0; background: transparent; color: var(--muted); font: 650 var(--text-xs)/1 var(--ui); text-align: left; text-transform: uppercase; letter-spacing: .09em; cursor: pointer; }
.section-title svg { position: absolute; left: .5rem; top: 50%; translate: 0 -50%; width: .8rem; height: .8rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transition: transform var(--dur-micro) var(--ease-standard); }
.section-title.collapsed svg { transform: none; }
.section-title:focus-visible { outline: none; color: var(--text); }
/* The Channels header carries a + that opens the channel panel; the row owns the section spacing. */
.section-row { display: flex; align-items: center; margin: 14px 0 5px; }
.section-row .section-title { flex: 1; min-width: 0; margin: 0; }
.section-add { flex: 0 0 auto; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; margin-right: 8px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; }
.section-add img { width: 1rem; aspect-ratio: 1; opacity: .5; }
.section-add:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.section-add:active { transform: scale(.92); }
.section-add:hover img { opacity: .9; }
.section-add:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.section-more { width: 100%; padding: .4rem .6rem; border: 0; background: transparent; color: var(--muted); font: var(--text-xs)/1 var(--ui); text-align: left; cursor: pointer; }
.section-more:focus-visible { color: var(--brand); outline: none; }
@media (hover: hover) { .section-more:hover { color: var(--brand); outline: none; } }
.room { width: 100%; display: flex; align-items: center; gap: .5rem; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.room:hover { background: color-mix(in srgb, var(--panel-hi) 55%, transparent); }
.room.active { background: var(--active-fill); color: var(--brand); }
.room small { color: var(--muted); }
/* A room row stays one line: the name clips, the sub-line clips after it. The full
   name comes back in the row tooltip (showRowTooltip), never in a wrapped row. */
.room > span:not(.room-mark):not(.room-name):not(.thread-name):not(.unread-badge):not(.available-action) { display: flex; align-items: baseline; gap: .3rem; flex: 1; min-width: 0; overflow: hidden; }
.room-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room > span:not(.room-mark) > small { flex: 0 1 auto; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-room .room-mark svg { width: .9rem; height: .9rem; }
.lock-icon { display: block; width: .6rem; height: .85rem; background: currentColor; -webkit-mask: url(/icons/ui/lock.svg?v=1) center / contain no-repeat; mask: url(/icons/ui/lock.svg?v=1) center / contain no-repeat; }
.draft-room > span:last-child { min-width: 0; display: grid; }
.draft-room small { overflow: hidden; font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.draft-section { display: grid; grid-template-rows: 1fr; }
.draft-section-inner { min-height: 0; overflow: hidden; }
.draft-enter, .draft-leave { transition: grid-template-rows var(--dur-base) var(--ease-standard), opacity var(--dur-base) var(--ease-standard); }
.draft-enter-start, .draft-leave-end { grid-template-rows: 0fr; opacity: 0; }
.draft-enter-end, .draft-leave-start { grid-template-rows: 1fr; opacity: 1; }
@media (prefers-reduced-motion: reduce) { .draft-enter, .draft-leave { transition: none; } }
.draft-delete { display: grid; place-items: center; flex: 0 0 auto; width: 2rem; height: 2rem; margin-right: .25rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); opacity: .65; cursor: pointer; }
.draft-delete svg { width: 1rem; height: 1rem; }
.draft-delete:hover, .draft-delete:focus-visible { background: var(--panel-hi); color: var(--danger); opacity: 1; outline: none; }
@media (hover: hover) { .draft-row .draft-delete { opacity: 0; } .draft-row:hover .draft-delete, .draft-row:focus-within .draft-delete { opacity: 1; } }
@media (pointer: coarse) { .draft-delete { width: 2.75rem; height: 2.75rem; } }
.draft-mobile-row { display: flex; align-items: center; }
.draft-mobile-row .mobile-row { width: auto; flex: 1; min-width: 0; }
.draft-mobile-row .draft-delete { margin-right: .35rem; }
.thread-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-tooltip { position: fixed; z-index: var(--z-floating); width: max-content; max-width: min(18rem, calc(100vw - 1rem)); padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--glass-tint); box-shadow: var(--shadow-md); color: var(--text); font: var(--text-xs)/1.35 var(--ui); pointer-events: none; }
.thread-tooltip.above { translate: 0 -100%; }
.rooms-sheet { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.channel-row { position: relative; display: flex; align-items: center; }
.channel-row > .room { flex: 1; min-width: 0; }
.rooms-sheet .room { gap: 1.05rem; padding-top: 10px; padding-bottom: 10px; }
.rooms-sheet .room-mark { translate: .6rem 0; }
.channel-kebab { width: 2rem; height: 2rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: 700 var(--text-base)/1 var(--ui); cursor: pointer; }
@media (hover: hover) { .channel-kebab:hover { background: var(--panel-hi); color: var(--text); } }
.channel-kebab:active { transform: scale(.92); }
.channel-menu { position: fixed; z-index: var(--z-navigation-menu); width: max-content; min-width: 9rem; max-width: min(14rem, calc(100vw - 1rem)); padding: .3rem; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg); background: var(--glass-tint); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); box-shadow: var(--shadow-md); }
.nav-menu { right: auto; top: auto; }
.nav-menu button { min-height: 2.5rem; font-size: var(--text-sm); }
.channel-menu button, .message-menu button { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.menu-icon { display: block; width: .95rem; height: .95rem; flex: 0 0 auto; }
.menu-icon svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .channel-menu button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); } }
.channel-menu button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.channel-menu button.danger { color: var(--danger); }
@media (hover: hover) { .channel-menu button.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); } }
.channel-menu .menu-caret { margin-left: auto; display: inline-flex; color: var(--muted); }
.channel-menu .menu-caret svg { width: .95rem; height: .95rem; }
.channel-flyout { position: fixed; z-index: var(--z-navigation-submenu); min-width: 11rem; padding: .3rem; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg); background: var(--glass-tint); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); box-shadow: var(--shadow-md); }
.channel-flyout button { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
@media (hover: hover) { .channel-flyout button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); } }
.channel-flyout button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.channel-flyout .menu-icon { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .channel-menu, .channel-flyout { transition: none !important; } }
.menu-divider { height: 1px; margin: .25rem .35rem; background: color-mix(in srgb, var(--text) 12%, transparent); }
.available-room { align-items: center; color: var(--muted); }
.room.available-room > .available-action { display: flex; flex: 0 0 auto; align-items: center; margin-left: auto; color: var(--brand); font-size: var(--text-xs); font-weight: 700; }
.unread-badge { display: inline-grid; place-items: center; box-sizing: border-box; min-width: 1.5rem; height: 1.25rem; margin-left: auto; padding: 0 .38rem; border-radius: var(--radius-pill); background: var(--brand); color: var(--bg); font: 750 var(--text-2xs)/1 var(--ui); font-variant-numeric: tabular-nums; }
.panel-footer { position: absolute; z-index: var(--z-local); left: 14px; bottom: max(1rem, env(safe-area-inset-bottom)); width: calc(min(300px, 100vw - 28px) - 28px); padding: 0; }
body.rooms-docked .panel-footer { left: 14px; right: auto; width: calc(15rem - 28px); pointer-events: auto; }
.profile-card { min-width: 0; display: flex; align-items: center; border: 0; border-radius: var(--radius-lg); background: transparent; backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); }
.profile-main { min-width: 0; flex: 1; display: flex; align-items: center; gap: .65rem; padding: .45rem .55rem; border: 0; border-radius: inherit; background: transparent; color: inherit; text-align: left; cursor: pointer; }
@media (hover: hover) { .profile-card:hover { background: color-mix(in srgb, var(--panel-hi) 72%, transparent); } }
.profile-card:active { background: color-mix(in srgb, var(--panel-hi) 72%, transparent); }
.profile-main:focus-visible { outline: none; }
.profile-avatar { position: relative; width: 2rem; height: 2rem; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius-round); background: var(--avatar-fill); color: var(--bg); font: 750 var(--text-xs)/1 var(--ui); }
.profile-copy small { display: block; }
.profile-avatar > span, .message-avatar > span, .profile-modal-avatar > span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: var(--radius-round); }
/* A bot glyph, an agent icon, or the app's own logo stands on its own: no circle behind it and no initial underneath. */
.message-avatar:has(img[src^="data:image/svg+xml"]), .profile-avatar:has(img[src^="data:image/svg+xml"]), .profile-modal-avatar:has(img[src^="data:image/svg+xml"]), .room-mark:has(img[src^="data:image/svg+xml"]), .mention-avatar:has(img[src^="data:image/svg+xml"]),
.message-avatar:has(img[src^="/icons/agents/"]), .profile-avatar:has(img[src^="/icons/agents/"]), .profile-modal-avatar:has(img[src^="/icons/agents/"]), .room-mark:has(img[src^="/icons/agents/"]), .mention-avatar:has(img[src^="/icons/agents/"]) { background: transparent; border-radius: 0; }
.message-avatar:has(img[src^="/icons/slirc.svg"]), .profile-avatar:has(img[src^="/icons/slirc.svg"]), .profile-modal-avatar:has(img[src^="/icons/slirc.svg"]), .room-mark:has(img[src^="/icons/slirc.svg"]), .mention-avatar:has(img[src^="/icons/slirc.svg"]) { background: transparent; border-radius: 0; }
.message-avatar:has(img[src^="data:image/svg+xml"]) > span, .profile-modal-avatar:has(img[src^="data:image/svg+xml"]) > span:not(.avatar-upload-hint), .mention-avatar:has(img[src^="data:image/svg+xml"]) > span,
.message-avatar:has(img[src^="/icons/agents/"]) > span, .profile-modal-avatar:has(img[src^="/icons/agents/"]) > span:not(.avatar-upload-hint), .mention-avatar:has(img[src^="/icons/agents/"]) > span { display: none; }
.message-avatar:has(img[src^="/icons/slirc.svg"]) > span, .profile-modal-avatar:has(img[src^="/icons/slirc.svg"]) > span:not(.avatar-upload-hint), .mention-avatar:has(img[src^="/icons/slirc.svg"]) > span { display: none; }
.peer-avatar:has(img[src^="data:image/svg+xml"]) > span, .peer-avatar:has(img[src^="/icons/agents/"]) > span, .peer-avatar:has(img[src^="/icons/slirc.svg"]) > span { display: none; }
img[src^="/icons/slirc.svg"] { object-fit: contain !important; border-radius: 0 !important; }
img[src^="/icons/agents/"] { object-fit: contain !important; border-radius: 0 !important; }
.profile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-round); background: var(--panel-hi); }
/* Current presence, never inferred from messages or channel membership. */
.avatar-status-host { position: relative; }
.profile-avatar.avatar-status-host, .message-avatar.avatar-status-host { overflow: visible; }
.peer-avatar img { position: absolute; inset: 0; }
.avatar-status-host::after { content: ""; position: absolute; z-index: 3; right: -1px; bottom: -1px; width: 8px; height: 8px; border-radius: var(--radius-round); background: var(--brand); box-shadow: 0 0 0 2px var(--avatar-status-ring, var(--bg)); opacity: 0; transform: scale(.75); transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease, background-color var(--dur-fast) ease; pointer-events: none; }
.avatar-status-host:is([data-status="online"], [data-status="offline"], [data-status="away"], [data-status="busy"], [data-status="focus"], [data-status="break"], [data-status="resting"], [data-status="vacation"])::after { opacity: 1; transform: scale(1); }
@starting-style { .avatar-status-host[data-status]::after { opacity: 0; transform: scale(.75); } }
.avatar-status-host:is([data-status="offline"], [data-status="away"])::after { background: var(--muted); }
.avatar-status-host[data-status="busy"]::after { background: var(--danger); }
.avatar-status-host:is([data-status="focus"], [data-status="break"], [data-status="resting"], [data-status="vacation"])::after { width: 12px; height: 12px; display: grid; place-items: center; background: var(--avatar-status-ring, var(--bg)); font: 12px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.avatar-status-host[data-status="focus"]::after { content: "🎯"; }
.avatar-status-host[data-status="break"]::after { content: "☕"; }
.avatar-status-host[data-status="resting"]::after { content: "💤"; }
.avatar-status-host[data-status="vacation"]::after { content: "🌴"; }
.room-mark.avatar-status-host, .profile-avatar.avatar-status-host { --avatar-status-ring: var(--panel); }
.message-avatar.avatar-status-host { padding: 0; border: 0; cursor: pointer; }
.message-avatar.avatar-status-host img { border-radius: inherit; }
.message-avatar.avatar-status-host:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .avatar-status-host[data-status]::after { transition: none; } }
img[src^="data:image/svg+xml"] { scale: .9; object-fit: contain !important; border-radius: 0 !important; background: transparent !important; }
.profile-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.profile-copy strong, .profile-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy strong { display: flex; align-items: center; gap: .35rem; color: var(--text); font-size: var(--text-sm); }
.profile-copy strong > span { overflow: hidden; text-overflow: ellipsis; }
.profile-copy .admin-badge { width: .9rem; height: .9rem; }
.profile-copy small { color: var(--muted); font-size: var(--text-2xs); }
.admin-badge { width: 1rem; height: 1rem; flex: 0 0 auto; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.profile-admin { width: 1.15rem; height: 1.15rem; }
.verify-email { color: var(--warning); }
.history-loading { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: 1.25rem 0; color: var(--muted); font: var(--text-sm)/1 var(--ui); }
/* Fade only: a live arrival already slides up with #messages, and a rise on top of that doubles the motion. */
@keyframes msg-in { from { opacity: 0; } to { opacity: 1; } }
.history-pending .msg, .history-pending .date-divider, .history-pending .public-channel-intro, .history-pending .channel-intro, .history-pending .history-event { opacity: 0; pointer-events: none; }
.history-settled .channel-intro { animation: intro-in var(--dur-reveal) cubic-bezier(.2, .7, .2, 1) both; animation-delay: .04s; }
@keyframes intro-in { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .history-settled .channel-intro, .history-settled .msg, .history-settled .date-divider, .history-settled .public-channel-intro, .history-settled .history-event { animation: none; } }
.history-settled .msg, .history-settled .date-divider, .history-settled .public-channel-intro, .history-settled .history-event { animation: msg-in var(--dur-entrance) cubic-bezier(.2, .7, .2, 1) both; }
.history-settled .msg { animation-delay: .12s; }
.chat #messages { padding-bottom: calc(var(--composer-space, calc(5rem + env(safe-area-inset-bottom))) + .5rem); }

/* The list runs under the header and the translucent composer, so messages scroll behind their
   blur. The top padding keeps the first message and the banners clear of the header (1rem chat
   padding plus a .5rem gap); the bottom padding keeps the newest line clear of the composer.
   Phones size the bottom padding in their own block below. */
.chat {
  position: fixed;
  font-family: var(--mono);
  inset: 0;
  width: min(100%, 860px);
  margin-inline: auto;
  overflow-y: auto;
  padding: calc(var(--header-h) + 1.5rem) max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chat::-webkit-scrollbar, .giphy-results::-webkit-scrollbar { display: none; }
/* Conversation hugs the composer like a phone messenger; older messages scroll up. */
#messages { min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
/* Smooth arrivals (scrollToBottom in app.js): the list is held where it was and eases up to rest. */
#messages.sliding { transition: translate var(--dur-base) cubic-bezier(.2, .7, .2, 1); }
@media (prefers-reduced-motion: reduce) { #messages.sliding { transition: none; } }
.message-entry { display: contents; }
/* Inline Add / Ignore note under a message or after /invite. Only this tab ever sees it. */
/* Inline Add / Dismiss note: one quiet local-only line under the names, marked by a thin bar; the
   eye-off mark says only you see it. Wraps on narrow screens. */
.add-prompt { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; margin: .2rem 0 .55rem calc(.25rem + 2rem + 9px); padding: .2rem 0 .2rem .7rem; border-left: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); color: var(--text); font: var(--text-sm)/1.45 var(--ui); }
.add-prompt-text { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.add-prompt-who { display: inline-flex; align-items: center; gap: .3rem; padding: 0 .4rem 0 .15rem; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); font-weight: 600; vertical-align: middle; }
.add-prompt-who .mention-avatar { width: 1.15rem; height: 1.15rem; font-size: .6rem; }
.add-prompt-private { display: inline-grid; place-items: center; margin-left: .3rem; color: var(--muted); vertical-align: -.15em; border-radius: var(--radius-xs); }
.add-prompt-private svg { width: .95rem; height: .95rem; }
.add-prompt-private:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.add-prompt-actions { display: inline-flex; align-items: center; gap: .35rem; }
.add-prompt-add, .add-prompt-dismiss { min-height: 1.65rem; padding: 0 .7rem; border: 0; border-radius: var(--radius-pill); font: 650 var(--text-sm)/1 var(--ui); cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.add-prompt-add { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--brand); }
.add-prompt-add:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 32%, transparent); }
.add-prompt-dismiss { background: transparent; color: var(--muted); }
.add-prompt-dismiss:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.add-prompt-add:disabled, .add-prompt-dismiss:disabled { opacity: var(--disabled-opacity); cursor: default; }
.add-prompt-add:focus-visible, .add-prompt-dismiss:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 500px) { .add-prompt { margin-left: .35rem; } }
.date-divider { display: flex; align-items: center; gap: .75rem; margin: 1.15rem 0 .65rem; color: var(--muted); font: 650 var(--text-xs)/1 var(--ui); }
.date-divider::before, .date-divider::after { content: ""; height: 1px; flex: 1; background: color-mix(in srgb, var(--muted) 18%, transparent); }
.new-divider { color: var(--brand); }
.new-divider::before, .new-divider::after { background: color-mix(in srgb, var(--brand) 35%, transparent); }
.msg {
  position: relative;
  display: grid;
  grid-template-columns: 2rem 3.25rem minmax(5.25rem, auto) minmax(0, 1fr);
  column-gap: 9px;
  align-items: start;
  line-height: 1.6;
  padding: 2px .25rem;
  border-radius: var(--radius-xs);
  outline: none;
  scroll-margin-top: calc(var(--header-h) + .75rem);
}
/* .kb-focus: rows reached with the arrow keys. WebKit leaves :focus-visible off a row that script
   focuses after a mouse click (into the composer, say), so the class carries the highlight there. */
.msg:focus-visible, .msg.kb-focus:focus { background: color-mix(in srgb, var(--panel-hi) 38%, transparent); }
/* Deep link / thread parent link: hold a single row below the fixed header, then fade out at 1s. */
.msg.focus-flash { background: color-mix(in srgb, var(--brand) 20%, transparent); }
@keyframes focus-flash { from { background: color-mix(in srgb, var(--brand) 30%, transparent); } to { background: color-mix(in srgb, var(--brand) 20%, transparent); } }
@media (prefers-reduced-motion: no-preference) { .msg.focus-flash { animation: focus-flash 1s ease-out; } }
/* The finished entrance animation would otherwise cap the menu's backdrop blur at this row. */
.msg.menu-open { z-index: var(--z-message); animation: none; }
.msg:focus-visible .message-add, .msg.kb-focus:focus .message-add { opacity: .7; }
.message-add {
  grid-column: 1;
  align-self: start;
  justify-self: end;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--dur-micro) var(--ease-standard), color var(--dur-micro) var(--ease-standard);
}
.msg:hover .message-add, .message-add:focus-visible { opacity: .7; }
/* No transform on these triggers: the picker/menu anchor to the button's box, so a hover/active
   scale would drag the open popup a few pixels. Color and opacity carry the feedback instead. */
.message-add:hover { color: var(--brand); opacity: 1; }
.message-add:active { color: var(--brand); opacity: .75; }
.message-add.stamp { animation: stamp var(--dur-reaction) cubic-bezier(.12,.8,.25,1); }
.message-add svg { width: .875rem; height: .875rem; }
.msg .time {
  grid-column: 2;
  color: color-mix(in srgb, var(--muted) 52%, transparent);
  font-size: var(--text-base);
  font-weight: 200;
  text-align: right;
  white-space: nowrap;
  user-select: none;
}
.msg .nick {
  grid-column: 3;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  justify-self: end;
  text-align: right;
  white-space: nowrap;
  cursor: pointer;
}
.msg .nick > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.msg .nick > small { flex: 0 0 auto; padding: .15rem .3rem; border: 1px solid color-mix(in srgb, var(--muted) 55%, transparent); border-radius: var(--radius-pill); color: var(--muted); font: 700 .58rem/1 var(--ui); letter-spacing: .04em; text-transform: uppercase; }
.mobile-time { display: none; color: var(--muted); font-size: var(--text-2xs); white-space: nowrap; user-select: none; }
.message-avatar { display: none; position: relative; place-items: center; overflow: hidden; border-radius: var(--radius-round); background: var(--avatar-fill); color: var(--bg); font: 750 var(--text-sm)/1 var(--ui); }
.message-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thread-root { margin-bottom: .45rem; padding-bottom: .55rem; border-bottom: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); }
.thread-root .nick, .thread-root .time { display: none; }
.thread-root-origin { grid-column: 4; grid-row: 1; justify-self: start; display: inline-flex; align-items: center; gap: .25rem; padding: 0; border: 0; background: none; color: var(--muted); font: 600 var(--text-xs)/1.4 var(--ui); cursor: pointer; }
.thread-root-origin:hover, .thread-root-origin:focus-visible { color: var(--text); }
.thread-root-origin .menu-icon { width: .75rem; height: .75rem; }
.msg .body { grid-column: 4; min-width: 0; overflow-wrap: anywhere; container-type: inline-size; }
.message-copy { display: block; }
.msg .body .body-seg > span { white-space: pre-wrap; }
.message-edited { margin-left: .35rem; color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.msg .body .list-item { display: flex; gap: var(--space-2); }
.msg .body .list-marker { flex: none; min-width: 2ch; color: var(--muted); text-align: right; }
.msg .body .list-text { min-width: 0; }
.msg .body blockquote { display: block; margin: .15rem 0 .3rem; padding: .1rem .6rem; border-left: 2px solid color-mix(in srgb, var(--brand) 70%, transparent); color: var(--muted); font-style: italic; }
.reaction-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0 0; }
.reaction-chip { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 1.75rem; padding: .15rem .35rem; border: 0; border-radius: 0; background: transparent; color: var(--text); font: var(--text-sm)/1 var(--mono); white-space: nowrap; cursor: pointer; animation: reaction-in var(--dur-fast) ease-out; }
/* One fixed column above the composer; a sticky toast sits above the timed one when both show.
   The timed toast lasts 5s plus 1s per 30 characters, capped at 9s, via --toast-ms from toasts.html. */
.toast-region { position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(var(--composer-space, 5rem) + .75rem); display: flex; flex-direction: column; align-items: center; gap: .5rem; width: max-content; max-width: min(34rem, calc(100vw - 2rem)); translate: -50% 0; pointer-events: none; }
.glass-toast { position: relative; display: flex; align-items: center; gap: .5rem; max-width: 100%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-xl); background: var(--glass-tint); box-shadow: var(--shadow-md); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); color: var(--text); font: 650 var(--text-sm)/1.4 var(--ui); pointer-events: auto; }
.glass-toast > span { min-width: 0; overflow-wrap: anywhere; }
.glass-toast .notify-banner-close { width: 1.75rem; height: 1.75rem; border-radius: var(--radius-pill); }
/* Notices dismiss themselves: a slightly lighter layer drains toward the dismiss button, and its animationend
   clears the note. Hover or focus pauses it; reduced motion keeps the layer still but still times out. */
.glass-toast { gap: .75rem; padding: .45rem .45rem .45rem 1rem; border-radius: 1.4rem; overflow: hidden; isolation: isolate; }
.glass-toast::before { content: ""; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, var(--text) 8%, transparent); transform-origin: right; animation: toast-progress var(--toast-ms, 5s) linear forwards; }
.glass-toast:hover::before, .glass-toast:focus-within::before { animation-play-state: paused; }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-hold { from { opacity: 1; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .glass-toast::before { animation-name: toast-hold; } }
/* Every toast fades in rising from below, since the column is anchored at the bottom; a replaced timed
   toast is a new element, so it rises again. Sticky toasts wait for an action: no drain, a still mint tint and a bell. */
.glass-toast { animation: toast-in var(--dur-base) cubic-bezier(.2, .8, .2, 1); }
.glass-toast.sticky { gap: .5rem; }
.toast-region.no-composer { bottom: max(1rem, env(safe-area-inset-bottom)); }
.glass-toast.sticky.more { justify-content: center; }
.glass-toast.sticky::before { animation: none; background: transparent; }
/* On a phone the reminder text takes the first row and its buttons wrap below it, right-aligned, so a
   long "View in DM with …" label never squeezes the text; a label wider than the toast wraps inside. */
.toast-action { max-width: 100%; }
@media (max-width: 500px) { .glass-toast.sticky:not(.more) { flex-wrap: wrap; } .glass-toast.sticky:not(.more) > span { flex: 1 1 calc(100% - 1.5rem); } .glass-toast.sticky:not(.more) > .toast-action:first-of-type { margin-left: auto; } }
/* The update toast is a dark HUD in both themes, matching the Mac app's: lime text, icon and Refresh on
   blurred near-black, a hairline border and a grey Dismiss. It carries dark theme values so the buttons follow. */
.glass-toast.hud { --brand: #a6e3a1; --text: #cdd6f4; --muted: #9399b2; background: color-mix(in srgb, #11111b 80%, transparent); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .1), 0 .5rem 1.5rem #0009; backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); color: var(--brand); color-scheme: dark; }
/* Rex's update pill: compact, lime text that scrolls sideways when it is wider than its slot, a lime Refresh and a
   bare close x that brightens and grows on hover. The track is at least as wide as its slot; it slides by the difference (margin-left: 100% is the
   slot, translate -100% is the track), so text that fits never moves. Hover or focus pauses it. Screen readers get
   the static .sr-only copy once; the moving copy is aria-hidden. It scrolls under reduced motion too, by Mauricio's
   call, since the text would not fit otherwise; only the x's grow drops its easing there. */
.glass-toast.hud { gap: .5rem; padding: .3rem .3rem .3rem .75rem; border-radius: var(--radius-pill); }
.glass-toast.hud > .toast-icon { width: .95rem; height: .95rem; }
.toast-marquee { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, transparent, #000 .5rem, #000 calc(100% - .5rem), transparent); }
.toast-marquee-track { display: inline-block; min-width: 100%; padding: 0 .5rem; animation: toast-marquee 12s ease-in-out 1s infinite alternate; }
.glass-toast.hud:hover .toast-marquee-track, .glass-toast.hud:focus-within .toast-marquee-track { animation-play-state: paused; }
@keyframes toast-marquee { 0%, 15% { margin-left: 0; translate: 0; } 85%, 100% { margin-left: 100%; translate: -100%; } }
.glass-toast.hud > .toast-action { min-height: 1.6rem; font-weight: 700; }
.toast-close { display: grid; place-items: center; flex: 0 0 auto; width: 1.6rem; height: 1.6rem; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.toast-close svg { width: .85rem; height: .85rem; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; transition: scale var(--dur-fast) ease; }
.toast-close:hover, .toast-close:focus-visible { color: var(--text); }
.toast-close:hover svg, .toast-close:focus-visible svg { scale: 1.2; }
@media (prefers-reduced-motion: reduce) { .toast-close svg { transition: none; } }
@media (max-width: 500px) { .glass-toast.hud.sticky:not(.more) { flex-wrap: nowrap; } .glass-toast.hud.sticky:not(.more) > .toast-action:first-of-type { margin-left: 0; } }
.glass-toast .toast-icon { width: 1rem; height: 1rem; flex: 0 0 auto; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast-action { flex: 0 0 auto; min-height: 1.75rem; padding: 0 .75rem; border: 0; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); font: inherit; cursor: pointer; transition: background-color var(--dur-fast) ease; }
.toast-action:hover, .toast-action:focus-visible { background: color-mix(in srgb, var(--brand) 28%, transparent); }
.toast-action.quiet { background: transparent; color: var(--muted); }
.toast-action.quiet:hover, .toast-action.quiet:focus-visible { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
@keyframes toast-in { from { opacity: 0; translate: 0 .75rem; } }
@media (prefers-reduced-motion: reduce) { .glass-toast { animation: none; } .toast-action { transition: none; } }
/* Something new landed below while the reader is scrolled up; tapping it goes to the bottom. */
.new-below { position: fixed; z-index: var(--z-sidebar); left: 50%; bottom: calc(var(--composer-space, 5rem) + .75rem); min-height: 2.25rem; padding: 0 1rem; border: 0; border-radius: var(--radius-pill); background: var(--glass-tint); box-shadow: var(--shadow-md); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); color: var(--text); font: 650 var(--text-sm)/1 var(--ui); translate: -50% 0; touch-action: manipulation; cursor: pointer; }
.new-below.public { bottom: calc(4.8rem + env(safe-area-inset-bottom) + .75rem); }
/* Bottom stack: nav pill, composer above it, both glass. Every offset derives from these so keyboard and safe-area math lives in one place. */
:root { --nav-h: 4.1rem; --nav-lift: max(.5rem, env(safe-area-inset-bottom, 0px)); --composer-bottom: calc(var(--kb, 0px) + var(--nav-h) + var(--nav-lift) + .5rem); }
body.kb-open { --composer-bottom: calc(var(--kb, 0px) + .5rem); }
.mobile-nav { position: fixed; z-index: var(--z-popover); inset: auto 1rem var(--nav-lift); height: var(--nav-h); display: grid; grid-template-columns: repeat(3, 1fr); padding: .3rem .5rem; border: 0; border-radius: var(--radius-pill); background: var(--nav-surface); backdrop-filter: var(--glass-filter); touch-action: manipulation; transition: translate var(--dur-base) ease-out, opacity var(--dur-base) ease-out; }
body.kb-open .mobile-nav { translate: 0 150%; opacity: 0; pointer-events: none; }
.mobile-nav button { position: relative; display: grid; place-items: center; justify-items: center; gap: .2rem; min-height: 3.4rem; padding: .45rem 0 .5rem; border: 0; background: transparent; color: var(--muted); font: 650 var(--text-xs)/1 var(--ui); cursor: pointer; transition: color var(--dur-micro) var(--ease-standard); }
.mobile-nav button .menu-icon { display: block; width: 2.1rem; height: 1.6rem; object-fit: contain; filter: grayscale(1) opacity(.62); transition: filter var(--dur-fast) ease; }
.mobile-nav button .nav-dot { top: .35rem; }
.mobile-nav button.active .menu-icon { filter: none; }
.mobile-nav button.active .nav-label { color: var(--brand); }
.mobile-back { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; margin-left: -.35rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); }
.mobile-back svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mobile-nav .nav-dot { position: absolute; right: calc(50% - 1.2rem); width: .42rem; height: .42rem; border-radius: var(--radius-round); background: var(--brand); }
.mobile-screen { position: fixed; z-index: var(--z-mobile-screen); inset: 0 0 0; display: flex; flex-direction: column; background: var(--bg-glow); overflow: hidden; }
.mobile-screen-body { animation: mobile-body-in var(--dur-base) ease both; }
/* Landing on Home, DMs or More: rows arrive in a short stagger (index set at reveal), badges ease in. */
html.boot-landed .mobile-screen .mobile-row { animation: row-in var(--dur-entrance) cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 28ms); }
@keyframes row-in { from { opacity: 0; translate: 0 6px; } }
.unread-badge { animation: badge-in var(--dur-base) ease both; }
@keyframes badge-in { from { opacity: 0; scale: .8; } }
@media (prefers-reduced-motion: reduce) { html.boot-landed .mobile-screen .mobile-row, .unread-badge { animation: none; } }
.mobile-screen.swipe-right .mobile-screen-body { animation: swipe-right-in var(--dur-base) cubic-bezier(.22, .8, .3, 1) both; }
.mobile-screen.swipe-left .mobile-screen-body { animation: swipe-left-in var(--dur-base) cubic-bezier(.22, .8, .3, 1) both; }
@keyframes mobile-body-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes swipe-right-in { from { opacity: 0; transform: translateX(9%); } }
@keyframes swipe-left-in { from { opacity: 0; transform: translateX(-9%); } }
.mobile-screen-head { position: sticky; top: 0; z-index: var(--z-content); display: flex; align-items: center; justify-content: space-between; min-height: calc(4.6rem + env(safe-area-inset-top, 0px)); padding: calc(.95rem + env(safe-area-inset-top, 0px)) 1rem .95rem; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: var(--blur-medium); -webkit-backdrop-filter: var(--blur-medium); font: 750 var(--text-lg)/1 var(--ui); flex: 0 0 auto; }
.home-brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; }
.home-brand img { width: 1.85rem; height: 1.85rem; }
.home-brand strong { display: flex; align-items: center; font: 750 var(--text-lg)/1 var(--ui); color: var(--text); }
.mobile-profile { width: 2rem; height: 2rem; padding: 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: var(--radius-round); background: var(--panel-hi); }
.mobile-profile img { width: 100%; height: 100%; object-fit: cover; }
.mobile-profile-fixed { position: fixed; z-index: var(--z-profile-control); top: calc(.95rem + env(safe-area-inset-top, 0px)); right: 1rem; }
.mobile-screen-body { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; padding: 0 .5rem calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
.mobile-screen-body::-webkit-scrollbar { display: none; }
.mobile-spacer { margin-top: auto; min-height: 2rem; }
/* The Home, DMs and More lists scroll under their heads, glass like the conversation header. */
.mobile-screen-head.tab-screen-head { position: absolute; inset: 0 0 auto; background: transparent; backdrop-filter: var(--blur-medium); -webkit-backdrop-filter: var(--blur-medium); }
.tab-screen-head + .mobile-screen-body { padding-top: calc(4.6rem + env(safe-area-inset-top, 0px)); }
.mobile-row { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 3.15rem; padding: .58rem .65rem; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--text); text-align: left; font: var(--text-base)/1.1 var(--ui); cursor: pointer; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.mobile-row:active { background: color-mix(in srgb, var(--panel-hi) 72%, transparent); }
.mobile-row, .mobile-row:hover { text-decoration: none; }
.mobile-row .menu-icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; color: var(--muted); }
.mobile-row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: .22rem; }
.mobile-row-main small, .mobile-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-row-main strong { font-weight: 650; }
.mobile-row-main small { color: var(--muted); font-size: var(--text-sm); }
/* Informational row: no tap target, dimmed. */
.mobile-row-static { opacity: .55; pointer-events: none; cursor: default; }
.mobile-section-label { margin: 1.05rem .65rem .35rem; color: var(--muted); font: 700 var(--text-sm)/1 var(--ui); }
.mobile-section-toggle { display: flex; align-items: center; gap: .35rem; width: calc(100% - 1.3rem); min-height: 2.5rem; margin-block: .4rem 0; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.mobile-section-toggle svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transition: transform var(--dur-fast) ease; }
.mobile-section-toggle.collapsed svg { transform: none; }
.mobile-empty { margin: 1.5rem .65rem; color: var(--muted); font-size: var(--text-base); }
.glass-toast .toast-check { width: 1rem; height: 1rem; color: var(--brand); flex: 0 0 auto; }
.reaction-tooltip { position: fixed; z-index: var(--z-floating); display: flex; align-items: center; gap: .45rem; width: max-content; max-width: min(18rem, calc(100vw - 2rem)); padding: .45rem .55rem; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-md); background: var(--glass-tint); box-shadow: var(--shadow-md); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); color: var(--text); font: var(--text-xs)/1.25 var(--ui); pointer-events: none; }
.reaction-tooltip strong { display: inline-flex; align-items: center; gap: .15rem; line-height: 1; color: var(--brand); }
.reaction-tooltip small { color: var(--text); font: inherit; }
.reaction-chip small { color: var(--muted); font-size: var(--text-xs); }
.reaction-chip.mine { color: var(--brand); }
.reaction-chip.mine small { color: var(--muted); }
.reaction-chip.stamp { animation: stamp var(--dur-reaction) cubic-bezier(.12,.8,.25,1); }
.thread-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: .35rem 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color var(--dur-micro) var(--ease-standard);
}
.thread-link svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: scaleX(-1); }
.thread-avatars { display: flex; flex-direction: row-reverse; }
.thread-avatar { width: 1.1rem; height: 1.1rem; margin-left: -.3rem; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--bg); border-radius: var(--radius-round); background: var(--avatar-fill); }
.thread-avatar img { width: 100%; height: 100%; display: block; border-radius: 0 !important; object-fit: cover; scale: 1 !important; }
.thread-avatar:has(img[src^="data:image/svg+xml"]), .thread-avatar:has(img[src^="/icons/agents/"]) { background: var(--panel-hi); }
.thread-avatar img[src^="data:image/svg+xml"], .thread-avatar img[src^="/icons/agents/"] { object-fit: contain !important; }
.thread-link:hover, .thread-link:focus-visible { color: var(--brand); }
.msg.action { grid-template-columns: 2rem 3.25rem auto minmax(0, 1fr); color: var(--muted); font-style: italic; }
.msg.action .nick { color: var(--brand); font-weight: 650; overflow: visible; font-style: italic; }
.msg.action .nick::before { content: "* "; }
.msg .body a { color: var(--mine); }
/* Inline chips sit on top of the space around them, so their padding reads as a double gap. The negative
   margin pulls the layout back to a plain word space while the background keeps its breathing room. */
.msg .body .mention { display: inline; padding: .08rem .35rem; border: 0; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; transition: opacity var(--dur-micro) ease, background-color var(--dur-micro) ease; }
.msg .body .mention:hover, .msg .body .mention:focus-visible { background: color-mix(in srgb, var(--brand) 28%, transparent); outline: none; }
.msg .body .mention.me { background: var(--mention-me-fill); color: var(--mine); }
/* An agent mention shows its harness mark and display name; the nick is in the tooltip. */
.msg .body .mention.agent-mention { white-space: nowrap; }
.msg .body .agent-mention-mark { display: inline-block; width: 1em; height: 1em; margin-right: .3em; vertical-align: -.15em; object-fit: contain; }
.msg .body .message-link { display: inline-block; max-width: 100%; overflow: hidden; overflow-wrap: normal; word-break: normal; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
.message-link:hover { text-decoration: underline; }
.link-popover { z-index: var(--z-dialog); display: flex; align-items: center; gap: .2rem; padding: .25rem; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg); background: var(--glass-tint); backdrop-filter: var(--blur-medium) saturate(1.15); -webkit-backdrop-filter: var(--blur-medium) saturate(1.15); box-shadow: var(--shadow-md); }
.link-popover a, .link-popover button { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 2.4rem; padding: 0 .65rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: 650 var(--text-sm)/1 var(--ui); text-decoration: none; cursor: pointer; transition: background-color var(--dur-micro) var(--ease-standard), color var(--dur-micro) var(--ease-standard); }
.link-popover a:hover, .link-popover a:focus-visible, .link-popover button:hover, .link-popover button:focus-visible { background: color-mix(in srgb, var(--panel-hi) 72%, transparent); color: var(--brand); outline: none; }
.link-popover svg { width: .95rem; height: .95rem; }
@media (pointer: coarse) { .link-popover a, .link-popover button { min-height: 2.75rem; } }
.gif-label { padding: 0; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.gif-label:hover, .gif-label:focus-visible { color: var(--brand); text-decoration: underline; }
/* Inline, not inline-block: an inline-block with overflow other than visible sits on its bottom edge, so the chip floated above the text. Long code wraps instead of scrolling. */
.msg .body code { padding: .08rem .28rem; border-radius: var(--radius-xs); background: var(--panel-hi); color: var(--mine); font: .9em var(--mono); overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.edited-marker { margin-left: .35rem; color: var(--muted); font-size: var(--text-xs); font-style: normal; }
/* Outbox status (stage 3, .plans/instant.md): shown on a message row whose op failed after
   its 30s retry window, never as a modal. Pending rows carry no visible marker of their own,
   just the ordinary "sent" tick swapped in once the echo confirms them. */
.outbox-status { margin-left: .35rem; color: var(--danger); font-size: var(--text-xs); font-style: normal; }
.outbox-status[data-state="saving"], .outbox-status[data-state="queued"], .outbox-status[data-state="sending"] { color: var(--muted); }
.outbox-status .typing-dots { margin-left: var(--space-2); vertical-align: middle; }
.agent-request-status { margin-left: var(--space-2); color: var(--muted); font-size: var(--text-xs); font-style: normal; }
.outbox-retry, .outbox-discard { padding: 0; border: 0; background: transparent; color: var(--danger); font: inherit; text-decoration: underline; cursor: pointer; }
.msg.pending { opacity: .6; }
.msg .body .fence { display: block; margin: .375rem 0 .25rem; padding: .625rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); overflow-x: auto; }
.msg .body .fence code { padding: 0; background: transparent; color: var(--text); }
.fence code b, .fence code strong { color: var(--brand); font-weight: 700; }
.fence code em { color: var(--mine); font-style: normal; }
.fence code sup { color: var(--muted); font-style: italic; font-size: inherit; vertical-align: baseline; }
.fence code label { color: var(--mine); }
.fence code i { color: var(--muted); font-style: normal; }
.fence code u { text-decoration: none; color: var(--brand); }
.fence code mark { background: transparent; color: var(--brand); }
.fence code ins { color: var(--brand); text-decoration: none; }
.fence code del { color: var(--danger); opacity: .75; }
.fence code dfn { color: var(--mine); font-style: normal; }
.image-preview { position: relative; width: min(100%, 440px); margin-top: .45rem; }
.image-preview summary {
  position: absolute;
  z-index: var(--z-content);
  top: .5rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: var(--radius-round);
  background: color-mix(in srgb, var(--panel-hi) 92%, #000);
  color: #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  list-style: none;
  opacity: .92;
  transition: opacity var(--dur-micro) var(--ease-standard);
}
.image-preview summary:hover, .image-preview summary:focus-visible { opacity: 1; }
.image-preview summary::-webkit-details-marker { display: none; }
.image-preview summary svg { width: .9rem; height: .9rem; fill: none; stroke: currentColor; stroke-width: 2; transition: transform var(--dur-micro) var(--ease-standard); }
.image-preview .image-icon { display: none; }
.image-preview:not([open]) { display: inline-block; width: fit-content; margin: 0; vertical-align: top; }
.image-preview:not([open]) summary { position: static; margin: 0; }
.image-preview:not([open]) .image-chevron { display: none; }
.image-preview:not([open]) .image-icon { display: block; }
/* The native details-content close animation keeps children painted while height interpolates.
   Hide the photo immediately so it cannot scale/reflow during that shrink; summary stays usable. */
.image-preview:not([open]) > .message-media { visibility: hidden; }
/* Tall photos hit .msg .body img's 300px max-height, so their rendered width can be narrower
   than the 22rem button cap. Shrink-wrap button to that rendered image; summary anchors to it. */
.image-preview[open]:has(> .message-media) { width: fit-content; max-width: min(22rem, 100%); }
.image-preview[open]:has(> .message-media) > .message-media { width: fit-content; }
.image-preview[open]:has(> .message-media) > .message-media img { width: auto; max-width: 100%; }
.image-preview[open]:has(> .message-media) > summary { right: .5rem; }
/* Embed cards: toggle sits top-right on a plain dark chip; text keeps clear of it. */

.embed-card .embed-copy, .embed-card .embed-player-copy { padding-right: 1.75rem; }
/* The bracketed Giphy label, and the direct-image fallback, are the visible links that replace
   the raw URL the body no longer prints. */
.message-media-item { display: block; }
.giphy-caption, .media-fallback { display: block; width: fit-content; max-width: 100%; margin-top: .3rem; font-size: .82em; overflow-wrap: anywhere; }
/* A collapsed Giphy puts its icon inline to the right of the bracketed label. The expanded
   photo and ordinary images keep the stacked layout. The kind class is explicit because every
   media item carries a hidden .giphy-caption, so :has(> .giphy-caption) alone would match images. */
.message-media-item.is-giphy:has(> .image-preview:not([open])) { display: flex; align-items: center; gap: .35rem; }
.message-media-item.is-giphy:has(> .image-preview:not([open])) > .giphy-caption { margin-top: 0; min-width: 0; }
/* An ordinary image collapsed to its toggle rides on the caption line: the copy turns inline only
   while that toggle exists, so the icon follows the text and wraps with it. Expanded photos keep
   the stacked block below the text, and Giphy keeps its own inline label/icon rule above. */
.msg .body:has(> .message-media-item.is-image > .image-preview:not([open])) > .message-copy { display: inline; }
.message-media-item.is-image:has(> .image-preview:not([open])) { display: inline; margin-left: .35rem; }
.msg .body img {
  display: block;
  max-width: min(100%, 440px);
  max-height: 300px;
  aspect-ratio: auto 4 / 3;
  margin-top: 0;
  border-radius: 7px;
}
.custom-emoji, .msg .body .custom-emoji { display: inline-block; width: 1.25em; height: 1.25em; margin: 0 .06em; border-radius: .18em; object-fit: contain; vertical-align: -.25em; }
.reaction-chip .custom-emoji, .picker-reaction .custom-emoji, .sheet-reactions .custom-emoji, .sheet-reaction-rows .custom-emoji, .reaction-tooltip .custom-emoji { width: 1.35rem; height: 1.35rem; margin: 0; vertical-align: middle; }
.thread-title-rich .custom-emoji { width: 1em; height: 1em; }
.msg .body video {
  display: block;
  max-width: min(100%, 440px);
  max-height: 300px;
  aspect-ratio: auto 16 / 9;
  border-radius: 7px;
  background: #000;
  cursor: pointer;
}
.msg.system {
  display: block;
  margin: 12px 0 5px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: var(--text-base);
  white-space: pre-line;
}
.msg.error { color: var(--danger); }
.history-event {
  margin: .25rem 0;
  padding: .2rem 0;
  color: var(--muted);
  opacity: .5;
  transition: opacity var(--dur-micro) var(--ease-standard);
}
.history-event:hover, .history-event[open] { opacity: 1; }
.history-event summary { display: flex; align-items: center; gap: .25rem; cursor: pointer; list-style: none; font-family: var(--ui); }
.history-event:focus-visible, .history-event summary:focus-visible { outline: none; }
.history-event summary::-webkit-details-marker { display: none; }
.history-event svg { width: .85rem; height: .85rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-micro) var(--ease-standard); }
.history-event[open] svg { transform: rotate(90deg); }
.history-event > div { padding: .25rem 0 .25rem 1.1rem; }
.system-event { user-select: none; -webkit-user-select: none; }
.system-text { white-space: pre-wrap; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid transparent; border-top-color: var(--brand); border-radius: var(--radius-round); vertical-align: -.2rem; animation: spin .8s linear infinite; }
.loading { display: inline-flex; align-items: center; gap: .5rem; }
/* Buttons: btn-primary (brand), btn-secondary (neutral), btn-danger (red). No other button classes. */
.btn-primary, .btn-secondary, .btn-danger {
  min-height: 2.5rem; padding: 0 .9rem; border: 0; border-radius: var(--radius-md); background: var(--secondary-fill); color: var(--text);
  font: 700 var(--text-sm)/1 var(--ui); cursor: pointer;
  transition: transform var(--dur-fast) ease, background-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.btn-primary { background: var(--brand-fill); color: var(--on-brand); }
.btn-danger { background: var(--danger); color: var(--bg); }
.btn-primary:not(:disabled):hover, .btn-primary:focus-visible,
.btn-secondary:not(:disabled):hover, .btn-secondary:focus-visible,
.btn-danger:not(:disabled):hover, .btn-danger:focus-visible {
  outline: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm), 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
}
.btn-primary:not(:disabled):hover, .btn-primary:focus-visible { background: color-mix(in srgb, var(--brand-fill) 86%, white); }
.btn-secondary:not(:disabled):hover, .btn-secondary:focus-visible { background: var(--secondary-fill-hover); }
.btn-danger:not(:disabled):hover, .btn-danger:focus-visible {
  background: color-mix(in srgb, var(--danger) 86%, white);
  box-shadow: var(--shadow-sm), 0 0 0 3px color-mix(in srgb, var(--danger) 28%, transparent);
}
.btn-primary:not(:disabled):active, .btn-secondary:not(:disabled):active, .btn-danger:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: none;
  transition-duration: .06s;
}
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
  opacity: var(--disabled-opacity);
  cursor: default;
  transform: none;
  box-shadow: none;
}
@media (pointer: coarse) {
  .btn-primary:hover:not(:focus-visible), .btn-secondary:hover:not(:focus-visible), .btn-danger:hover:not(:focus-visible) {
    transform: none;
    box-shadow: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn-primary, .btn-secondary, .btn-danger { transition: none; }
}
.public-help-composer .btn-primary { min-height: 2.75rem; padding: .75rem 1rem; font-size: var(--text-base); line-height: 1.45; }
.session-expired .btn-primary { justify-self: start; font-size: var(--text-sm); }
.btn-primary.busy, .btn-secondary.busy, .btn-danger.busy, button[disabled].busy { position: relative; color: transparent !important; }
.btn-primary.busy::after, .btn-secondary.busy::after, .btn-danger.busy::after, button[disabled].busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1rem; height: 1rem; border: 2px solid transparent; border-top-color: var(--on-brand); border-radius: var(--radius-round); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .busy::after { animation-duration: 2s; } }
.help-list { display: grid; gap: .3rem; }
.help-item { display: contents; }
.help-line { display: block; }
.help-docs { display: block; margin-top: .25rem; color: var(--brand); text-decoration: none; font-weight: 650; }
.help-docs:hover { text-decoration: underline; }
.help-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.help-actions .btn-secondary { display: inline-flex; align-items: center; min-height: 2.25rem; font-size: var(--text-sm); text-decoration: none; }
.help-line strong { margin-right: .45rem; color: color-mix(in srgb, var(--brand) 45%, var(--muted)); font-weight: 650; }
.reaction-picker {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  position: fixed;
  z-index: var(--z-floating-panel);
  width: max-content;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: .35rem .45rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  /* backdrop-filter over message text does not visibly blur on Chromium (AGENTS.md); a low-alpha panel
     tint carries readability instead, and it has to be there on the first frame, not faded in with the
     rest of the panel, or message text shows through while the entrance animation runs. */
  background: var(--glass-tint);
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  animation: picker-in var(--dur-fast) ease-out;
}
.picker-reaction { display: inline-flex; align-items: center; gap: .15rem; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--text); padding: .2rem; cursor: pointer; opacity: .7; transition: opacity var(--dur-micro) var(--ease-standard), transform var(--dur-micro) var(--ease-standard); }
.picker-reaction .pr-emoji { font-size: var(--text-lg); line-height: 1; }
.picker-reaction .pr-count { color: var(--muted); font: 650 var(--text-2xs)/1 var(--mono); }
.picker-reaction:hover { opacity: 1; transform: scale(1.16); }
.picker-search { flex: 1 1 100%; }
.picker-search-input { width: 100%; padding: .35rem .5rem; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); outline: none; background: transparent; color: var(--text); font: var(--text-sm)/1.3 var(--ui); }
.picker-search-input::placeholder { color: var(--muted); }
.picker-empty { flex: 1 1 100%; margin: 0; padding: .25rem .5rem; color: var(--muted); font-size: var(--text-xs); }
.sheet-reaction-search { padding: 0 .25rem; }
.reaction-picker-presets { display: contents; }
.picker-reaction .pr-icon { display: grid; place-items: center; width: 1.15rem; height: 1.15rem; color: var(--muted); }
.picker-reaction .pr-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Add reaction: the picker grows into a search panel at the same anchor. */
.reaction-picker.searching { display: block; width: 19rem; padding: .35rem; border-radius: var(--radius-lg); }
.reaction-search-input { appearance: none; -webkit-appearance: none; }
.reaction-search-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .1rem; max-height: 12.5rem; margin-top: .35rem; overflow-y: auto; scrollbar-width: none; }
.reaction-search-grid button { display: grid; place-items: center; aspect-ratio: 1; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: var(--text-lg)/1 var(--ui); cursor: pointer; }
.reaction-search-grid button.active { background: color-mix(in srgb, var(--brand) 18%, transparent); }
.reaction-search-grid button:disabled { opacity: var(--disabled-opacity); cursor: default; }
.reaction-search-grid .custom-emoji { width: 1.35rem; height: 1.35rem; margin: 0; }
.reaction-search-code { margin: .3rem .25rem 0; overflow: hidden; color: var(--muted); font: var(--text-xs)/1.2 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.message-more {
  position: absolute;
  z-index: var(--z-control);
  top: 0;
  left: 0;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: color var(--dur-micro) var(--ease-standard), opacity var(--dur-micro) var(--ease-standard);
}
.message-more svg { width: .875rem; height: .875rem; fill: currentColor; }
.msg:hover .message-more, .msg:focus-within .message-more, .message-more[aria-expanded="true"] { opacity: .7; }
.message-more:hover, .message-more:focus-visible { color: var(--text); opacity: 1; }
.message-more:active { opacity: .75; }
.message-menu {
  position: absolute;
  z-index: var(--z-sticky);
  top: 1.8rem;
  left: .2rem;
  min-width: 10rem;
  padding: .3rem;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: var(--radius-lg);
  background: var(--glass-tint);
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
}
.message-menu.popover-up { top: auto; bottom: calc(100% - .3rem); }
.message-menu button { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: var(--text-sm)/1.2 var(--ui); text-align: left; cursor: pointer; }
.message-menu button:hover, .message-menu button:focus-visible { background: var(--panel-hi); outline: none; }
.message-menu button.danger { color: var(--danger); }
.message-menu button.danger:hover, .message-menu button.danger:focus-visible { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.remind-form { display: grid; gap: .5rem; min-width: 14rem; padding: .3rem; }
.remind-form label { display: grid; gap: .35rem; color: var(--muted); font: var(--text-xs)/1.2 var(--ui); }
.remind-form input { min-height: 2.25rem; padding: 0 .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: var(--text-sm)/1.2 var(--ui); }
.remind-form-actions { display: flex; justify-content: flex-end; gap: .4rem; }
/* The menu's own button look would flatten the form buttons. */
.message-menu .remind-form button { width: auto; justify-content: center; padding: 0 .8rem; font-weight: 700; }
.message-menu .remind-form .btn-primary { background: var(--brand-fill); color: var(--on-brand); }
.message-menu .remind-form .btn-secondary { background: var(--secondary-fill); }
.message-menu .remind-form .btn-primary:hover, .message-menu .remind-form .btn-primary:focus-visible { background: color-mix(in srgb, var(--brand-fill) 86%, white); }
.message-menu .remind-form .btn-secondary:hover, .message-menu .remind-form .btn-secondary:focus-visible { background: var(--secondary-fill-hover); }
@keyframes picker-in { from { transform: translateY(-.25rem); } to { transform: translateY(0); } }
@keyframes reaction-in { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: .5; } }
@keyframes stamp { 0% { transform: scale(.65); } 55% { transform: scale(1.28); filter: drop-shadow(0 0 8px var(--brand)); } 100% { transform: scale(1); filter: none; } }

.giphy-results {
  position: fixed;
  z-index: var(--z-side-panel);
  inset: auto 0 var(--composer-space, calc(5rem + env(safe-area-inset-bottom)));
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .5rem .75rem;
  background: var(--glass-tint);
  backdrop-filter: var(--blur-medium) saturate(1.1);
}
.giphy-results::after { content: "GIPHY"; align-self: end; color: var(--muted); font: var(--text-2xs)/1 var(--mono); }
.giphy-results button { flex: 0 0 auto; padding: .18rem; border: 2px solid transparent; border-radius: var(--radius-md); background: none; cursor: pointer; transition: border-color var(--dur-micro) var(--ease-standard), transform var(--dur-micro) var(--ease-standard); }
.giphy-results button.selected { border-color: var(--brand); transform: translateY(-.1rem); }
.giphy-results img { display: block; width: 5rem; height: 4rem; object-fit: cover; border-radius: var(--radius-xs); }
.command-palette { position: fixed; z-index: var(--z-floating); display: grid; max-height: min(18rem, 45vh); overflow-y: auto; padding: .35rem; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg); background: var(--glass-tint); box-shadow: var(--shadow-md); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); scrollbar-width: none; -ms-overflow-style: none; }
.command-palette::-webkit-scrollbar { display: none; }
.command-palette button { display: flex; align-items: baseline; gap: .7rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.command-palette button:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); outline: none; }
@media (hover: hover) { .command-palette button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); outline: none; } }
.command-palette code { min-width: 4.8rem; color: var(--brand); font: var(--text-sm)/1 var(--mono); }
.command-palette button.danger code, .command-palette button.danger:hover { color: var(--danger); }
@media (hover: hover) { .command-palette button.danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); } }
.mention-palette button { align-items: center; gap: .6rem; padding: .4rem .5rem; }
.mention-palette button.active { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--text); }
.mention-avatar { position: relative; flex: 0 0 auto; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; overflow: hidden; border-radius: var(--radius-round); background: var(--avatar-fill); color: #11111b; font: 750 var(--text-xs)/1 var(--ui); }
.command-palette .mention-nick { min-width: 0; color: var(--muted); }
.mention-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mention-avatar > span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: var(--radius-round); }
.mention-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.mention-copy strong { color: var(--text); font-size: var(--text-sm); }
.mention-copy small { overflow: hidden; color: var(--muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.mention-hint { margin-left: auto; color: var(--muted); font-size: var(--text-xs); }
.emoji-palette button { align-items: center; gap: .6rem; padding: .4rem .5rem; }
.emoji-palette button.active { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--text); }
.emoji-glyph { flex: 0 0 auto; display: grid; place-items: center; width: 1.5rem; font-size: var(--text-lg); line-height: 1; }
.emoji-glyph .custom-emoji { width: 1.4rem; height: 1.4rem; margin: 0; }
.emoji-code { min-width: 0; overflow: hidden; color: var(--text); font: var(--text-sm)/1 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.composer {
  position: fixed;
  z-index: var(--z-header);
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: min(calc(100% - 1rem), 860px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .375rem;
  padding: var(--space-2);
  border-radius: var(--radius-pill);
  /* Native feel: taps never start a double-tap zoom or a delayed click. */
  touch-action: manipulation;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  background: var(--glass-chrome);
  box-shadow: var(--shadow-md);
  backdrop-filter: var(--glass-filter);
  translate: -50% 0;
  transition: background-color var(--dur-fast) ease;
}

/* A bot's answer takes a moment (docs search, then the model), so the wait gets a label above the
   composer. It floats: no layout shift, and it lives out its short life without touching the list.
   The left offset lines it up with the message avatars: the messages column's 1rem padding, the row's
   .25rem padding and 2rem leading grid column, and the column gap. */
.bot-thinking { position: absolute; bottom: 100%; left: calc(1rem + .25rem + 2rem + 9px); display: flex; align-items: center; gap: .35rem; margin-bottom: .3rem; padding: .3rem .45rem; border-radius: var(--radius-pill); background: var(--glass-tint); color: var(--muted); font: 500 var(--text-xs)/1 var(--ui); pointer-events: none; animation: thinking-in var(--dur-fast) ease-out; }
.thinking-dots { display: inline-flex; gap: .15rem; }
.thinking-dots i { width: .2rem; height: .2rem; border-radius: var(--radius-round); background: currentColor; animation: thinking 1.2s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@keyframes thinking-in { from { opacity: 0; } }
/* A status line whose text is only for screen readers; the dots carry it visually. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { .bot-thinking { animation: none; } .thinking-dots i { animation: none; opacity: .6; } }

.composer-editor {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 1.5rem;
  max-height: 10rem;
  overflow-y: auto;
}
.composer-input {
  display: block;
  width: 100%;
  min-height: 1.5rem;
  max-height: 10rem;
  overflow-y: auto;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 0 .25rem;
  font: var(--text-base)/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  caret-color: var(--brand);
}
.composer-input:empty::before { content: attr(data-placeholder); color: var(--muted); opacity: .78; pointer-events: none; }
.composer-input code { border-radius: var(--radius-xs); background: color-mix(in srgb, var(--panel) 70%, transparent); color: var(--mine); padding: 0 .16em; font: .9em/1.5 var(--mono); }
.composer-input .fence { margin: .35rem 0; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--panel) 55%, transparent); overflow-x: auto; }
.composer-input .fence code { display: block; width: max-content; min-width: 100%; padding: 0; background: transparent; color: var(--text); }
.composer-input a { color: var(--mine); text-decoration: underline; text-underline-offset: .15em; }
.composer-waiting { display: flex; align-items: center; gap: .45rem; min-height: 1.5rem; color: var(--muted); font: var(--text-sm)/1.5 var(--ui); }
/* Typing: a compact avatar row anchored above the composer, so the composer itself never moves. */
.typing-row { position: absolute; left: .35rem; bottom: calc(100% + .35rem); display: flex; align-items: center; gap: .4rem; padding: .18rem .5rem .18rem .25rem; border-radius: var(--radius-pill); border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); background: var(--glass-tint); box-shadow: var(--shadow-sm); backdrop-filter: var(--blur-medium); pointer-events: none; }
.typing-avatars { display: flex; align-items: center; }
.typing-avatar { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius-round); background: var(--avatar-fill); pointer-events: auto; }
.typing-avatar + .typing-avatar { margin-left: -.4rem; }
.typing-avatar img { width: 100%; height: 100%; object-fit: cover; }
.typing-avatar:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.typing-dots { display: inline-flex; gap: .16rem; padding-left: .1rem; }
.typing-dots i { width: .22rem; height: .22rem; border-radius: var(--radius-round); background: var(--muted); animation: typing-bounce .95s cubic-bezier(.2,.7,.2,1) infinite; }
.typing-dots i:nth-child(2) { animation-delay: .12s; }
.typing-dots i:nth-child(3) { animation-delay: .24s; }
@keyframes typing-bounce { 0%, 100% { transform: translateY(0); } 35% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing-dots i { animation: none; opacity: .6; } }
.composer-nick {
  flex: 0 0 auto;
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: .5rem;
  color: var(--muted);
  font: var(--text-sm)/1 var(--mono);
  opacity: .7;
}
.composer.tall { align-items: start; border-radius: 1.25rem; }
.composer-nick.editing { color: var(--mine); }
/* Phone: the edit label takes its own line above the field, so the draft keeps the full width, and
   Esc becomes a Cancel button. Its padding is pulled back by margins: a full touch target, no taller row. */
@media (pointer: coarse) {
  .composer-editing { order: -2; flex-basis: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin: 0; padding: 0 .25rem; color: var(--brand); font: var(--text-xs)/1.3 var(--ui); }
  .composer-edit-cancel { margin: -.6rem -.25rem -.6rem 0; padding: .6rem .75rem; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; }
}
.composer-plus {
  flex: 0 0 auto;
  width: 2.125rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-fast) ease, transform var(--dur-micro) ease;
}
.composer-plus:hover { color: var(--brand); }
.composer-plus:active { transform: scale(.92); }
.composer-plus { order: -1; }
.composer-plus img { display: block; width: 1.2rem; height: 1.2rem; }
.composer-send {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  position: relative;
  border: 0;
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--brand);
  box-shadow: none;
  cursor: pointer;
  transition: transform var(--dur-micro) ease;
}
.composer-send img { display: block; width: 1.5rem; height: 1.5rem; transition: filter var(--dur-fast) ease, opacity var(--dur-fast) ease; }
.composer-send:disabled { cursor: default; color: color-mix(in srgb, var(--muted) 60%, transparent); box-shadow: none; opacity: var(--disabled-opacity); filter: saturate(0); }

.composer-send:not(:disabled):active { transform: scale(.92); }
.composer-plus:focus-within { outline: .125rem solid var(--brand); outline-offset: .125rem; }
.custom-modal { position: fixed; z-index: var(--z-dialog); inset: 0; display: grid; overflow-y: auto; padding: 1rem; padding-bottom: calc(1rem + var(--kb, 0px)); background: #09091040; backdrop-filter: var(--blur-light); }
/* Auto margins centre the card and still let it scroll into view when it is taller than the screen.
   align-items/place-items would pin it and clip the top. */
.custom-modal > section { margin: auto; }
/* Signed-out #open-chat (peek.html): the real shell, read only. The rail holds the one room, and
   the bar where the composer goes opens sign-in. */
.peek-section-title { cursor: default; }
/* No composer measures itself here, so the transcript clears the bar by a fixed amount. */
body.peeking .chat #messages { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
.peek-more { margin: .75rem 10px 0; color: var(--muted); font: var(--text-xs)/1.45 var(--ui); }
/* Guest has no photo or initial: the person icon on a muted disc, the same size as every avatar. */
.peek-guest-avatar { background: var(--panel-hi); color: var(--muted); }
.peek-guest-avatar svg { width: 1.1rem; height: 1.1rem; }
.archived-channel.peek-bar { justify-content: space-between; gap: var(--space-2); padding: .4rem .4rem .4rem 1.1rem; border-style: solid; color: var(--text); text-align: left; cursor: text; }
.peek-input { flex: 1; min-width: 0; padding: .45rem 0; border: 0; background: transparent; color: var(--text); font: var(--text-base)/1.4 var(--mono); cursor: text; }
.peek-input::placeholder { color: var(--muted); }
.peek-input:focus { outline: none; }
.peek-bar .btn-primary { width: auto; flex: none; min-height: 2.25rem; padding-inline: 1rem; border-radius: var(--radius-pill); }
.auth-keep-reading { display: block; margin: .5rem auto 0; padding: .5rem .75rem; }
.profile-dialog-card, .notice-card, .auth-card, .delete-dialog { width: min(27rem, calc(100vw - 2rem)); border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-xl); background: color-mix(in srgb, var(--panel) 96%, transparent); color: var(--text); box-shadow: var(--shadow-lg); }
.delete-dialog::backdrop { background: #09091040; backdrop-filter: var(--blur-light); }
.profile-dialog-card { position: relative; width: min(36rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; padding: 1.35rem; }
/* The channel panel on its own: no profile heading or tabs, the panel's own title shows instead, and the
   card only needs room for the form. */
.profile-dialog-card.channels-only { width: min(30rem, calc(100vw - 2rem)); }
.channels-only .profile-heading, .channels-only .profile-tabs { display: none; }
.profile-panels { overflow: hidden; }
.mobile-settings-head { display: none; }
.profile-close { position: absolute; top: .75rem; right: .75rem; display: grid; place-items: center; width: 2rem; height: 2rem; border: 0; border-radius: var(--radius-round); background: transparent; color: var(--muted); font-size: var(--text-lg); cursor: pointer; }
.profile-close svg { width: 1.15rem; height: 1.15rem; }
.profile-close:hover, .profile-close:focus-visible { background: var(--panel-hi); color: var(--text); outline: none; }
.profile-heading { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.2rem; }
.profile-heading h2 { display: flex; align-items: center; gap: .4rem; margin: 0; font: 700 var(--text-lg)/1.25 var(--ui); }
.profile-heading p { margin: .15rem 0 0; color: var(--muted); font-size: var(--text-xs); }
.profile-dialog-card .profile-modal-avatar { width: 4rem; height: 4rem; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius-round); background: var(--panel-hi); color: var(--bg); font: 750 1.75rem/1 var(--ui); }
.avatar-upload { position: relative; cursor: pointer; }
.avatar-upload::after { content: "Change"; position: absolute; inset: auto 0 0; padding: .25rem 0; background: #11111bb8; color: var(--text); font: 650 .62rem/1 var(--ui); text-align: center; opacity: 0; transition: opacity var(--dur-micro) var(--ease-standard); }
.avatar-upload:hover::after, .avatar-upload:focus-within::after { opacity: 1; }
.avatar-upload.busy::after { content: ""; inset: 0; margin: auto; width: 1.2rem; height: 1.2rem; padding: 0; border: 2px solid transparent; border-top-color: var(--brand); border-radius: var(--radius-round); background: transparent; opacity: 1; animation: spin .8s linear infinite; }
.profile-modal-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-dialog-card form { display: grid; gap: .75rem; }
.profile-page .profile-form { gap: 1rem; }
.profile-page .profile-form .profile-actions { margin-top: .5rem; }
.profile-status-group { display: grid; gap: .3rem; }
.profile-status-row { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); align-items: end; gap: .5rem; }
.profile-badge-trigger, .profile-status-row input { min-height: 2.75rem; }
.profile-badge-trigger { display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); color: var(--text); cursor: pointer; transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease; }
.profile-badge-trigger:hover, .profile-badge-trigger:focus-visible { border-color: var(--brand); background: var(--panel-hi); }
.profile-badge-symbol { flex: 0 0 auto; display: grid; place-items: center; place-content: center; width: 10px; height: 10px; border-radius: var(--radius-round); background: var(--muted); }
.profile-badge-symbol[data-badge="available"] { background: var(--brand); }
.profile-badge-symbol[data-badge="busy"] { background: var(--danger); }
.profile-badge-symbol:is([data-badge="focus"], [data-badge="break"], [data-badge="resting"], [data-badge="vacation"]) { width: 1rem; height: 1rem; background: transparent; font: var(--text-base)/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.profile-badge-picker { position: fixed; inset: auto; width: min(14rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); margin: 0; padding: .35rem; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--glass-tint); color: var(--text); box-shadow: var(--shadow-md); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transition: opacity var(--dur-fast) ease; }
.profile-badge-picker:popover-open { display: grid; gap: .15rem; }
.profile-badge-picker button { display: flex; align-items: center; gap: .7rem; min-height: 2.75rem; padding: .4rem .7rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: var(--text-sm)/1.3 var(--ui); text-align: left; cursor: pointer; }
.profile-badge-picker button:hover, .profile-badge-picker button:focus-visible, .profile-badge-picker button[aria-pressed="true"] { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.profile-badge-check { margin-left: auto; color: var(--brand); }
@starting-style { .profile-badge-picker:popover-open { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .profile-badge-trigger, .profile-badge-picker { transition: none; } }
.irc-settings h3, .irc-credential h4 { margin: 0 0 .35rem; }
.irc-settings > .mobile-settings-body > p, .irc-credential > p { margin: 0 0 .9rem; color: var(--muted); font-size: var(--text-xs); line-height: 1.45; }
.irc-device-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; margin-bottom: .8rem; }
.irc-device-row { display: flex; min-width: 0; min-height: 3rem; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .65rem; border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 42%, transparent); }
.irc-device-row > span { min-width: 0; flex: 1; }
.irc-device-row > button { flex-shrink: 0; }
.irc-device-remove-all { justify-self: end; }
.irc-device-row strong, .irc-device-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.irc-device-row strong { font: 650 var(--text-sm)/1.35 var(--ui); }
.irc-device-row small { color: var(--muted); font-size: var(--text-2xs); }
.irc-connect-button { width: 100%; }
.irc-device-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.irc-device-form { padding: .7rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 35%, transparent); }
.irc-device-form > p { margin: 0; color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.irc-device-form > p a, .irc-settings > .mobile-settings-body > p a { color: var(--brand); }
.irc-credential { display: grid; gap: .7rem; }
.irc-password { display: flex; align-items: stretch; gap: .45rem; }
.irc-password code { min-width: 0; flex: 1; padding: .65rem; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); color: var(--brand); font: var(--text-xs)/1.35 var(--mono); }
.irc-password button { border: 0; border-radius: var(--radius-md); padding: 0 .8rem; color: var(--text); font-weight: 700; }
.irc-config { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); }
.irc-config > div { display: flex; align-items: center; justify-content: space-between; padding: .5rem .65rem; background: var(--panel-hi); font-size: var(--text-xs); }
.irc-config .link-button { min-height: 1.75rem; padding: .25rem .5rem; border-radius: var(--radius-sm); transition: background-color var(--dur-micro) var(--ease-standard), color var(--dur-micro) var(--ease-standard); }
.irc-config .link-button:hover, .irc-config .link-button:focus-visible { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--text); }
.irc-config .link-button.copied { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.irc-config pre { max-height: 12rem; margin: 0; padding: .65rem; overflow: auto; background: var(--bg); color: var(--text); font: var(--text-2xs)/1.45 var(--mono); white-space: pre; }
.irc-done { justify-self: end; }
.link-button { padding: 0 .25rem; border: 0; background: transparent; color: var(--brand); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.link-button.danger { min-width: 2.75rem; min-height: 2.75rem; color: var(--danger); opacity: .7; transition: opacity var(--dur-fast) ease; }
.link-button.danger:hover, .link-button.danger:focus-visible { opacity: 1; }
.profile-dialog-card label { display: grid; gap: .3rem; color: var(--muted); font-size: var(--text-xs); }
.form-fields { display: grid; gap: var(--space-4); }
.form-fields > label, .form-fields > .form-field > label { gap: var(--space-2); font-size: var(--text-sm); }
.form-field { display: grid; gap: var(--space-2); }
.profile-dialog-card .form-field .field-hint { margin: 0; font-size: var(--text-sm); }
.form-error { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0; padding: var(--space-3); border: 0; border-radius: var(--radius-md); background: color-mix(in srgb, var(--danger) 10%, var(--panel)); color: var(--danger); font-size: var(--text-sm); line-height: 1.45; }
.form-error svg { flex: 0 0 auto; width: 1.125rem; height: 1.125rem; margin-top: .0625rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.profile-dialog-card .form-consent { display: flex; align-items: center; gap: var(--space-3); min-height: 2.75rem; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); color: var(--text); font-size: var(--text-sm); cursor: pointer; }
.profile-dialog-card .form-consent input[type="checkbox"] { flex: 0 0 auto; width: 1.125rem; height: 1.125rem; margin: 0; padding: 0; appearance: auto; accent-color: var(--brand); }
.profile-dialog-card .form-consent input[type="checkbox"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.profile-dialog-card input, .profile-dialog-card textarea, .profile-dialog-card select { width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-md); outline: none; background: var(--bg); color: var(--text); font: var(--text-sm)/1.35 var(--ui); resize: vertical; }
.profile-dialog-card input:focus, .profile-dialog-card textarea:focus, .profile-dialog-card select:focus { border-color: var(--brand); }
.profile-dialog-card input:read-only, .profile-dialog-card textarea:read-only { border-color: transparent; padding-left: 0; background: transparent; resize: none; }
.profile-dialog-card textarea { resize: none; }
.profile-member + .profile-member { margin-top: .3rem; }
.profile-member a, .field-hint a { color: var(--brand); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color var(--dur-base) ease-in-out; }
.profile-member a:hover, .profile-member a:focus-visible, .field-hint a:hover, .field-hint a:focus-visible { border-bottom-color: currentColor; }
.profile-meta { display: flex; align-items: baseline; justify-content: space-between; gap: .35rem 1rem; flex-wrap: wrap; }
.profile-meta .profile-member { margin: 0; }
/* Founder-only welcome control: stays out of the profile save form so toggling it never saves drafts. */
.profile-welcome { display: grid; gap: .5rem; margin-top: .5rem; padding-top: 1rem; border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.profile-welcome .settings-toggle { margin: 0; }
/* "Add your phone": the first card on Devices. One click shows a one-time pairing QR. Desktop only. */
.phone-offer { display: grid; gap: .75rem; margin-bottom: 1rem; padding: 1rem; border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.phone-offer-intro { display: flex; align-items: center; gap: .9rem; }
.phone-offer-intro > div { flex: 1; min-width: 0; }
.phone-offer-intro h3 { margin: 0; font-size: var(--text-lg); }
.phone-offer-intro p { margin: .15rem 0 0; color: var(--muted); font-size: var(--text-sm); }
.phone-offer-intro .btn-primary { flex: 0 0 auto; }
.phone-offer-welcome { justify-self: start; padding: 0; text-decoration: none; }
.phone-offer-app { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.phone-offer-app a { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0; text-decoration: none; }
.phone-offer-app .menu-icon { width: .875rem; height: .875rem; }
.phone-offer-mark { display: grid; place-items: center; flex: 0 0 auto; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-round); background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.phone-offer-mark svg { width: 1.25rem; height: 1.25rem; }
.profile-prefs { margin-top: 1rem; }
.phone-offer-card { display: grid; justify-items: center; gap: var(--space-2, .5rem); padding: .75rem; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: var(--radius-lg); text-align: center; }
.phone-offer-card .invite-qr { padding: .7rem; border-radius: var(--radius-md); }
.phone-offer-card .invite-qr svg { width: 11rem; height: 11rem; display: block; }
.phone-offer-card p { margin: 0; }
.phone-offer-countdown { color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.profile-member a { color: var(--brand); }
.field-hint code { font-size: var(--text-xs); color: var(--text); }
.admin-email { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .4rem .7rem; }
.admin-email .profile-note { grid-column: 1 / -1; margin: 0; }
.profile-member, .profile-note, .profile-error { margin: 0; color: var(--muted); font-size: var(--text-xs); }
.profile-error { color: var(--danger); }
.profile-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .25rem; }
/* Reserve room for the saving spinner so the button does not change width mid-save. */
.profile-save { min-width: 8.75rem; }
.profile-save .spinner { width: .85rem; height: .85rem; margin-right: .4rem; vertical-align: -.1rem; }
.admin-refresh .spinner { width: .85rem; height: .85rem; margin-right: .4rem; vertical-align: -.1rem; }
.profile-tabs { display: flex; gap: .25rem; margin: -.25rem 0 1rem; padding: .2rem; border-radius: var(--radius-lg); background: var(--bg); }
.profile-tabs button { flex: 1; min-height: 2.25rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); font: 650 var(--text-sm)/1 var(--ui); cursor: pointer; }
.profile-tabs button.active { background: var(--panel-hi); color: var(--text); }
.account-tabs a { flex: 1; display: grid; place-items: center; min-height: 2.75rem; border-radius: var(--radius-md); color: var(--muted); text-decoration: none; font: 650 var(--text-sm)/1 var(--ui); transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.account-tabs a:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.account-tabs a.active { background: var(--panel-hi); color: var(--text); }
.account-tabs a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .account-tabs a { transition: none; } }
/* Channel settings dialog: name in the title, a compact segmented control, one Save, delete apart below. */
.channel-settings-card { display: grid; gap: 1.25rem; width: min(28rem, calc(100vw - 2rem)); }
.channel-settings-title { margin: 0; font: 700 var(--text-lg)/1.25 var(--ui); overflow-wrap: anywhere; }
.profile-dialog-card .channel-settings-form { gap: 1rem; }
.channel-visibility { display: grid; justify-items: start; gap: .4rem; }
.channel-visibility-label { color: var(--muted); font-size: var(--text-xs); }
.channel-visibility-value { font: 600 var(--text-sm)/1.3 var(--ui); }
.profile-dialog-card .channel-visibility .field-hint { margin: 0; }
.segmented { display: inline-flex; gap: .125rem; padding: .125rem; border-radius: var(--radius-md); background: color-mix(in srgb, var(--text) 8%, transparent); }
.segmented button { min-height: 2rem; padding: 0 .85rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: 600 var(--text-sm)/1 var(--ui); cursor: pointer; transition: background var(--dur-fast) ease, color var(--dur-fast) ease; }
.segmented button:not(:disabled):hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.segmented button:disabled { cursor: default; }
@media (pointer: coarse) { .segmented button { min-height: 2.75rem; } }
@media (prefers-reduced-motion: reduce) { .segmented button { transition: none; } }
.channel-danger { padding-top: 1rem; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.channel-danger-row { display: flex; align-items: center; gap: 1rem; }
.channel-danger .btn-secondary, .channel-danger .btn-danger { flex: 0 0 auto; min-height: 2.25rem; font-size: var(--text-sm); }
.channel-danger-button { color: var(--danger); }
.channel-danger .prefs-confirm { margin: 0; }
.channel-danger .prefs-confirm input:disabled { opacity: var(--disabled-opacity); }
.agent-list { display: grid; gap: .35rem; }
.agent-row { display: flex; align-items: flex-start; gap: .7rem; min-height: 3.5rem; padding: .55rem .65rem; border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 42%, transparent); }
.agent-mark { flex: 0 0 auto; padding: .2rem .4rem; border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: var(--radius-pill); color: var(--brand); font: 750 .6rem/1 var(--ui); letter-spacing: .05em; text-transform: uppercase; }
.agent-avatar { flex: 0 0 auto; width: 2rem; height: 2rem; display: grid; place-items: center; align-self: center; }
.agent-avatar img { width: 100%; height: 100%; }
.agent-copy { min-width: 0; flex: 1; display: grid; gap: .1rem; }
.agent-copy strong, .agent-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-copy strong { font: 700 var(--text-sm)/1.25 var(--mono); }
.agent-copy small { color: var(--muted); font-size: var(--text-xs); }
.agent-copy .agent-presence { color: var(--brand); }
.agent-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.agent-open:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-sm); }
.agent-status { display: inline-flex; align-items: center; align-self: center; gap: .35rem; flex: 0 0 auto; color: var(--muted); font: 600 var(--text-xs)/1 var(--ui); white-space: nowrap; }
.agent-status::before { content: ""; width: .5rem; height: .5rem; border-radius: var(--radius-round); background: var(--muted); }
.agent-status[data-state="ready"] { color: var(--brand); }
.agent-status[data-state="ready"]::before { background: var(--brand); }
.agent-status[data-state="working"] { color: var(--mine); }
.agent-status[data-state="working"]::before { background: var(--mine); }
.agent-status[data-state="input"] { color: var(--attention); }
.agent-status[data-state="input"]::before { background: var(--attention); }
.agent-status[data-state="unverified"]::before { background: transparent; border: 1px solid var(--muted); }
.agent-row > .link-button { align-self: center; flex-shrink: 0; }
.agent-intro { margin: 0 0 .9rem; color: var(--muted); font-size: var(--text-xs); line-height: 1.45; }
.agent-intro a { color: var(--brand); }
/* Admin page: ops status as plain label/value lists and tables of numbers. */
/* Admin page rhythm, one scale for every section: --space-6 between sections, --space-5 between the
   parts of Status, --space-2 from a heading to what follows it, --space-4 between the blocks under a
   section heading (text, list, table, form) and --space-3 inside a Status part. */
.admin-page .profile-screen-card > .irc-settings, .admin-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.admin-page .profile-screen-card > .irc-settings + .irc-settings { margin-top: var(--space-6); }
.admin-page .irc-settings h3 { margin: 0; }
.admin-page .admin-status-head { margin-bottom: calc(var(--space-2) - var(--space-4)); }
/* Devices and IRC clients follow the same scale: --space-6 between sections, --space-2 from a heading to
   its text and --space-4 between the blocks under it (text, form, list, buttons). */
.settings-page .phone-offer { margin: 0; }
.settings-page .session-settings, .irc-page .irc-settings, .irc-page .irc-settings > div:not(.irc-credential) { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.settings-page .phone-offer + .session-settings { margin-top: var(--space-6); }
.settings-page .session-settings h3, .irc-page .irc-settings h3 { margin: 0 0 calc(var(--space-2) - var(--space-4)); font: 700 var(--text-lg)/1.3 var(--ui); }
.settings-page .session-settings > p, .irc-page .irc-settings > p { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.45; }
.settings-page .session-settings .pair-code-form, .settings-page .session-more, .irc-page .irc-device-list { margin: 0; }
.settings-page .irc-device-remove-all, .irc-page .irc-device-remove-all, .irc-page .irc-done { align-self: flex-end; }
.admin-status-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.admin-status-body { display: flex; flex-direction: column; gap: var(--space-5); }
.admin-status-updated { margin: 0; font-size: var(--text-xs); }
.admin-status-section { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.admin-status-section h4 { margin: 0 0 calc(var(--space-2) - var(--space-3)); font-size: var(--text-sm); }
.admin-status-section p { margin: 0; font-size: var(--text-xs); }
.admin-status dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0; font-size: var(--text-xs); }
.admin-status dl div { display: contents; }
.admin-status dt { color: var(--muted); }
.admin-status dd { margin: 0; font-variant-numeric: tabular-nums; }
.admin-status-table { overflow-x: auto; }
.admin-status table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.admin-status th, .admin-status td { padding: var(--space-1) 0 var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
/* Alpine keeps its <template> as each row's first child, so the label cell is first-of-type, not first-child. */
.admin-status th:first-of-type, .admin-status td:first-of-type { min-width: 7rem; padding: var(--space-1) var(--space-2) var(--space-1) 0; text-align: left; white-space: normal; }
/* On a phone the day table scrolls sideways; the labels stay put. */
@media (max-width: 500px) { .admin-status th:first-of-type, .admin-status td:first-of-type { position: sticky; left: 0; background: var(--bg); } }
.admin-status th { color: var(--muted); font-weight: 500; }
.admin-status tbody tr:last-child td { border-bottom: 0; }
.admin-status .good { color: var(--brand); }
.admin-status .warn { color: var(--warning); }
.admin-status .bad { color: var(--danger); font-weight: 600; }
.admin-status .muted { color: var(--muted); }
.admin-branding-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.admin-branding-row .admin-branding-preview { width: 3rem; height: 3rem; border-radius: var(--radius-lg); font-size: var(--text-lg); }
.admin-branding-pick { display: inline-flex; align-items: center; min-height: 2.25rem; font-size: var(--text-sm); cursor: pointer; }
.admin-branding-pick:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.admin-branding-pick.disabled { opacity: var(--disabled-opacity); pointer-events: none; }
.icon-crop-card { width: min(24rem, calc(100vw - 2rem)); }
.icon-crop-card > p { margin: var(--space-2) 0 0; }
.icon-crop { position: relative; width: min(16rem, 100%); aspect-ratio: 1; margin: var(--space-4) auto; overflow: hidden; border-radius: var(--radius-lg); background: var(--bg); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.icon-crop:active { cursor: grabbing; }
.icon-crop:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon-crop img { position: absolute; max-width: none; max-height: none; pointer-events: none; }
.icon-crop::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent); pointer-events: none; }
.icon-crop-zoom { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); font-size: var(--text-sm); }
.icon-crop-zoom input { flex: 1; accent-color: var(--brand); }
.icon-crop-card .profile-error { margin-top: var(--space-3); }
.agent-pair { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin: 0 0 .9rem; padding: .45rem .3rem .45rem .7rem; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: var(--radius-md); background: color-mix(in srgb, var(--bg) 55%, transparent); }
.agent-pair code { min-width: 0; overflow-x: auto; color: var(--text); font: var(--text-xs)/1.4 var(--mono); white-space: nowrap; }
.agent-install { margin: 0 0 1.2rem; }
.agent-h { white-space: nowrap; }
.agent-h img { width: 1rem; height: 1rem; vertical-align: -.2rem; margin: 0 .2rem 0 .1rem; }
.agent-quiet { display: flex; align-items: center; gap: .45rem; margin: -.5rem 0 0; color: var(--muted); font-size: var(--text-xs); }
.agent-quiet .link-button, .agent-quiet a { font-size: var(--text-xs); padding: 0; color: var(--muted); }
.agent-quiet .spinner { margin: 0; }
.agent-connect-card { display: grid; gap: .35rem; margin: 0 0 1rem; padding: .7rem; border: 1px solid var(--brand); border-radius: var(--radius-md); }
.agent-connect-card code { color: var(--text); font: var(--text-sm)/1.4 var(--mono); letter-spacing: .06em; }
.agent-connect-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.agent-code-form { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: .6rem 0 0; }
.agent-code-form label { flex-basis: 100%; color: var(--muted); font-size: var(--text-xs); }
.agent-code-form input { flex: 1; min-width: 8rem; font: var(--text-sm)/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.agent-code-form .btn-secondary { flex: 0 0 auto; }
.agent-connect-meta { display: flex; align-items: center; min-height: 1.6rem; margin: 0 0 .4rem; color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.agent-connect-meta .link-button { padding: 0 .25rem; min-height: 1.6rem; font-size: var(--text-sm); }
.agent-connect-code { margin: .25rem 0 .5rem; color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }
.agent-connect-code code { margin: 0 .15rem; }
.agent-step { margin: 0 0 .4rem; color: var(--muted); font-size: var(--text-xs); line-height: 1.45; }
.agent-step code { color: var(--text); font: var(--text-xs)/1.4 var(--mono); user-select: all; }
.copy-button:disabled { opacity: var(--disabled-opacity); cursor: default; }
.profile-dialog-card .pair-code-form { display: flex; align-items: end; gap: .5rem; margin: 0 0 .9rem; }
.pair-code-form label { flex: 1; }
.pair-code-form input { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.pair-code-form .btn-secondary { flex: 0 0 auto; }
.copy-button { position: relative; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: 0 0 auto; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); cursor: pointer; }
.copy-button:focus-visible { color: var(--text); background: var(--panel-hi); outline: none; }
@media (hover: hover) { .copy-button:hover { color: var(--text); background: var(--panel-hi); outline: none; } }
.copy-button:not(:disabled):active { transform: scale(.92); }
.copy-button .menu-icon { grid-area: 1 / 1; transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease; }
.copy-button .check-glyph { color: var(--brand); opacity: 0; transform: scale(.6); }
.copy-button.copied .copy-glyph { opacity: 0; transform: scale(.6); }
.copy-button.copied .check-glyph { opacity: 1; transform: scale(1); }
.admin-settings > p, .channel-settings > p, .session-settings > p { margin: 0 0 1rem; color: var(--muted); font-size: var(--text-sm); }
.channel-settings h3 { margin: 0 0 .35rem; }
.channel-settings .mobile-settings-body > p { margin: 0 0 1rem; color: var(--muted); font-size: var(--text-sm); }
.profile-dialog-card .field-hint, .field-hint { margin: -.35rem 0 0; color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.field-hint a { color: var(--brand); }
.profile-dialog-card select { appearance: none; -webkit-appearance: none; padding-right: 2.4rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239399b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .85rem center; background-size: 1rem; }
.session-more { margin-top: .2rem; }
.session-more summary { display: inline-block; min-height: 2.25rem; padding: .5rem .25rem; color: var(--muted); font: 650 var(--text-sm)/1 var(--ui); cursor: pointer; list-style: none; }
.session-more summary::-webkit-details-marker { display: none; }
.session-more summary::after { content: ""; display: inline-block; width: .45rem; height: .45rem; margin-left: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-.15rem) rotate(45deg); transition: transform var(--dur-entrance) ease; }
.session-more[open] summary::after { transform: translateY(.05rem) rotate(-135deg); }
.session-more summary:focus-visible { color: var(--text); outline: none; }
@media (hover: hover) { .session-more summary:hover { color: var(--text); outline: none; } }
.session-list { display: grid; gap: .4rem; }
.session-row { display: flex; min-height: 3.25rem; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .65rem; border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 42%, transparent); }
.session-row > span { min-width: 0; flex: 1; }
.session-row > button { flex-shrink: 0; }
.session-row strong, .session-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-row strong { font: 650 var(--text-sm)/1.35 var(--ui); display: flex; align-items: center; gap: .45rem; }
.session-row strong > span { overflow: hidden; text-overflow: ellipsis; }
.session-row small { color: var(--muted); font-size: var(--text-2xs); }
.session-row strong b { padding: .12rem .35rem; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font-size: .62rem; text-transform: uppercase; }
.session-row strong b.pending { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }
.session-pending { margin-bottom: .6rem; }
.install-banner { margin: .35rem .15rem 0; flex: 0 0 auto; }
.install-banner .menu-icon { flex: 0 0 auto; width: 1.25rem; height: 1.25rem; color: var(--brand); }
.install-steps { margin: 0 0 1.25rem; padding-left: 1.2rem; color: var(--text); line-height: 1.5; }
.install-steps li { margin-bottom: .5rem; }
.admin-settings h3 { margin: 1.25rem 0 .35rem; }
.admin-settings .mobile-settings-body > p { margin: 0 0 1rem; color: var(--muted); font-size: var(--text-sm); }
.settings-toggle, .prefs-row, .prefs-radio { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; min-height: 3.5rem; padding: .6rem .75rem; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--text); text-align: left; cursor: pointer; }
.prefs-row { cursor: default; }
.settings-toggle > span:first-child { min-width: 0; display: flex; align-items: center; gap: .5rem; }
.settings-toggle small::before { content: "·"; margin-right: .5rem; }
.settings-toggle strong { font: 700 var(--text-sm)/1.25 var(--ui); }
.settings-toggle small { color: var(--muted); font-size: var(--text-xs); }
/* The trailing span is drawn as a switch; aria-checked carries the state and aria-label the name. */
.settings-toggle > span:last-child { position: relative; flex: 0 0 auto; width: 2.5rem; height: 1.5rem; border-radius: var(--radius-pill); background: var(--secondary-fill); color: transparent; font-size: 0; transition: background-color var(--dur-fast) var(--ease-standard); }
.settings-toggle > span:last-child::after { content: ""; position: absolute; top: .1875rem; left: .1875rem; width: 1.125rem; height: 1.125rem; border-radius: var(--radius-round); background: var(--muted); transition: translate var(--dur-fast) var(--ease-standard), background-color var(--dur-fast) var(--ease-standard); }
.settings-toggle[aria-checked="true"] > span:last-child { background: var(--brand-fill); }
.settings-toggle[aria-checked="true"] > span:last-child::after { translate: 1rem 0; background: var(--on-brand); }
@media (prefers-reduced-motion: reduce) { .settings-toggle > span:last-child, .settings-toggle > span:last-child::after { transition: none; } }
.settings-toggle:disabled { cursor: default; opacity: var(--disabled-opacity); }
.settings-toggle .menu-icon { color: var(--muted); }
/* Channel settings dialog: two toggles for everyone, owner fields below. */
/* Channel settings: title + summary, then Your view, About, Access, Danger. Spacing separates sections; no hairlines.
   Font floor in this dialog is .75rem. */
.channel-prefs .mobile-settings-body { display: grid; gap: 1.25rem; }
.channel-prefs-head { display: grid; gap: .2rem; padding-right: 2.5rem; }
.channel-prefs-title { margin: 0; font: 750 var(--text-lg)/1.2 var(--ui); }
.prefs-group { display: grid; gap: .4rem; }
.prefs-label { margin: 0 0 .1rem .1rem; color: var(--muted); font: 700 var(--text-xs)/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; }
.prefs-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: .35rem .1rem; border: 0; background: transparent; cursor: pointer; }
.prefs-toggle:hover { color: var(--text); }
.prefs-danger-toggle { color: var(--danger); }
.prefs-chevron { display: inline-flex; color: var(--muted); transition: transform var(--dur-fast) ease; }
.prefs-chevron svg { width: 1rem; height: 1rem; }
.prefs-chevron.open { transform: rotate(180deg); }
.prefs-body { display: grid; gap: .5rem; }
.prefs-danger .prefs-label { color: var(--danger); }
.prefs-text { display: grid; gap: .15rem; min-width: 0; flex: 1; }
.prefs-text strong { font: 700 var(--text-sm)/1.25 var(--ui); }
.prefs-text small { color: var(--muted); font-weight: 400; font-size: var(--text-xs); line-height: 1.35; overflow-wrap: anywhere; }
.prefs-text small::before { content: none; margin: 0; }
.settings-toggle:focus-visible, .prefs-radio:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.prefs-field { align-items: start; }
.prefs-value-line { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.prefs-value { display: block; min-width: 0; flex: 1; margin: -.15rem -.35rem; padding: .15rem .35rem; border-radius: var(--radius-sm); color: var(--text); font: var(--text-sm)/1.35 var(--ui); overflow-wrap: anywhere; outline: none; white-space: pre-wrap; }
.prefs-value[contenteditable="plaintext-only"] { cursor: text; }
.prefs-value[contenteditable="plaintext-only"]:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.prefs-value[contenteditable="plaintext-only"]:focus { background: color-mix(in srgb, var(--brand) 7%, var(--bg)); box-shadow: inset 0 -2px var(--brand); }
.prefs-value:empty::before { content: attr(data-placeholder); color: var(--muted); }
.prefs-check { display: inline-flex; flex: 0 0 auto; width: 1rem; height: 1rem; color: var(--brand); }
.prefs-check svg { width: 100%; height: 100%; }
.prefs-field-error { display: block; color: var(--danger); font-size: var(--text-xs); line-height: 1.35; }
.prefs-radios { display: grid; gap: .4rem; }
.prefs-radio { justify-content: flex-start; }
.prefs-radio:disabled { cursor: default; }
.radio-dot { position: relative; flex: 0 0 auto; width: 1.1rem; height: 1.1rem; border: 2px solid var(--muted); border-radius: var(--radius-round); transition: border-color var(--dur-fast) ease; }
.radio-dot::after { content: ""; position: absolute; inset: .15rem; border-radius: var(--radius-round); background: var(--brand); opacity: 0; transition: opacity var(--dur-fast) ease; }
.prefs-radio[aria-checked="true"] .radio-dot { border-color: var(--brand); }
.prefs-radio[aria-checked="true"] .radio-dot::after { opacity: 1; }
.prefs-danger .btn-secondary, .prefs-danger .btn-danger { flex: 0 0 auto; min-height: 2.25rem; font-size: var(--text-sm); }
.prefs-confirm { display: grid; gap: .6rem; margin: -.1rem 0 .2rem; padding: .75rem .85rem; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--panel-hi) 55%, transparent); }
.prefs-confirm p { margin: 0; color: var(--text); font-size: var(--text-sm); line-height: 1.45; }
.prefs-confirm p strong { color: var(--text); }
.profile-dialog-card .prefs-confirm label { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: var(--text-xs); }
.prefs-confirm label input { flex: 1 1 8rem; min-width: 0; }
.prefs-confirm label b { color: var(--text); font-family: var(--mono); }
.prefs-confirm-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.prefs-confirm-actions .btn-primary, .prefs-confirm-actions .btn-secondary, .prefs-confirm-actions .btn-danger { min-height: 2.25rem; font-size: var(--text-sm); }
.delete-dialog { width: min(27rem, calc(100vw - 2rem)); }
.delete-dialog-card { padding: 1.35rem; }
.delete-dialog h2 { margin: 0 0 .5rem; font: 700 var(--text-lg)/1.25 var(--ui); }
.delete-dialog p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.delete-dialog blockquote { max-height: 6rem; margin: 1rem 0; padding: .7rem .8rem; overflow: hidden; border-left: 2px solid var(--line); background: color-mix(in srgb, var(--bg) 60%, transparent); color: var(--text); font: var(--text-sm)/1.4 var(--mono); white-space: pre-wrap; }
.pair-actions, .delete-dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.pair-actions { margin-top: 1.2rem; }
.pair-actions button:focus-visible, .delete-dialog-actions button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.custom-emoji-card { width: min(23rem, calc(100vw - 2rem)); }
.custom-emoji-card > img { display: block; width: 8rem; height: 8rem; margin: .8rem auto 1rem; border-radius: var(--radius-lg); object-fit: cover; }
.custom-emoji-card form, .custom-emoji-card label { display: grid; gap: .55rem; }
.custom-emoji-card h2 { margin: 0; }
.custom-emoji-name { display: flex; align-items: center; gap: .25rem; color: var(--muted); font: var(--text-base)/1 var(--mono); }
.custom-emoji-name input { min-width: 0; flex: 1; }
.custom-emoji-card .profile-note, .custom-emoji-card .profile-error { margin: 0; }
.pair-modal { z-index: var(--z-dialog); }
.pair-card { padding: 1.4rem; text-align: left; }
.notice-card.pair-card h2 { margin: .2rem 0 .5rem; font: 700 var(--text-lg)/1.3 var(--ui); overflow-wrap: anywhere; }
.pair-card > p { margin: .4rem 0; }
.pair-card .pair-eyebrow { margin: 0 0 .25rem; color: var(--brand); font: 750 var(--text-2xs)/1 var(--ui); letter-spacing: .1em; text-transform: uppercase; }
.pair-card > p strong { color: var(--text); font-family: var(--mono); }
.pair-code { display: grid; justify-items: center; gap: .35rem; margin: 1.2rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--bg) 70%, transparent); }
.pair-code small { color: var(--muted); font: 700 var(--text-2xs)/1 var(--ui); letter-spacing: .1em; text-transform: uppercase; }
.pair-code strong { color: var(--text); font: 750 2rem/1 var(--mono); letter-spacing: .12em; }
.pair-card .pair-warning { color: var(--text); font-size: var(--text-sm); }
.pair-complete { min-height: 2.75rem; display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: 1.2rem !important; border-radius: var(--radius-md); background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand) !important; font-weight: 750; }
.agent-rename-input { width: 100%; min-height: 2.75rem; margin: .4rem 0; padding: 0 .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: var(--text-base)/1.2 var(--ui); }
.agent-rename-input:focus { border-color: var(--brand); outline: none; }
.agent-member { padding-left: .5rem; }
.agent-stale .room-mark img { filter: grayscale(1); opacity: .42; }
.rooms-sheet .agent-member > span:nth-child(2) { min-width: 0; display: grid; }
.rooms-sheet .agent-member > span:nth-child(2) > span, .rooms-sheet .agent-member > span:nth-child(2) > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rooms-sheet .agent-member > span:nth-child(2) > small { color: var(--muted); font-size: var(--text-2xs); }
@media (max-width: 500px) {
  .auth-modal { padding: .75rem; padding-bottom: calc(.75rem + var(--kb, 0px)); }
  .profile-dialog-card { max-height: calc(100dvh - 2rem); overflow-y: auto; padding: 1rem; }
  .profile-tabs button { min-width: 0; min-height: 2.75rem; font-size: var(--text-sm); }
  .agent-row { padding-inline: .5rem; }
  .agent-remove, .agent-rename { min-width: 4rem; }
  .pair-card { padding: 1.15rem; }
  .pair-code strong { font-size: 1.75rem; }
  .auth-card { width: min(100% - 1rem, 27rem); padding: 1rem; border-radius: 1.15rem; }
  .auth-card .login-logo { width: 4.5rem; height: 4.5rem; margin-bottom: .5rem; }
  .auth-card:has(.auth-step:not(.collapsed) .name-step) > .login-logo { display: none; }
  .name-step { gap: .9rem; padding: .25rem 0 .5rem; }
  .name-step p { font-size: var(--text-lg); }
  .nickname-logo { display: block; width: 2.5rem; height: 2.5rem; animation: nickname-logo-in var(--dur-reveal) cubic-bezier(.42,0,.58,1) both; }
  @keyframes nickname-logo-in { from { opacity: 0; transform: rotateY(180deg) scale(.9); } to { opacity: 1; transform: rotateY(360deg) scale(1); } }
  .msg, .msg.action { grid-template-columns: 1.25rem 2.25rem minmax(0, 1fr) auto; column-gap: .4rem; }
  .msg .time { display: none; }
  .msg .nick { display: none; }
  .message-avatar { display: grid; grid-column: 2; grid-row: 1; align-self: start; width: 1.5rem; height: 1.5rem; }
  .mobile-time { display: inline; grid-column: 4; grid-row: 1; align-self: baseline; }
  .msg .body { grid-column: 3; grid-row: 1; }
  .thread-root-origin { grid-column: 3; grid-row: 1; }
  .thread-root .body { grid-row: 2; }
  .composer { gap: .25rem; }
  .reaction-picker { display: none !important; }
  .composer-nick { max-width: 4.5rem; padding-left: .35rem; font-size: var(--text-xs); }
}
/* Desktop messages: avatar column, name and time on the first row of a run, follow-ups tuck under. */
@media (not (pointer: coarse)) and (min-width: 501px) {
  .msg { grid-template-columns: 4.25rem 2.25rem auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: .6rem; padding: .25rem .35rem; margin-bottom: .8rem; }
  .msg:not(.cont):not(.action) { padding-top: .45rem; }
  .msg.action { grid-template-columns: 4.25rem 2.25rem auto minmax(0, 1fr); }
  .message-entry:has(.msg:not(.cont)) { margin-top: .55rem; }
  /* Run spacing lives in the margin so the hover tint stops at the text. */
  .message-entry:has(+ .message-entry .msg.cont) .msg { margin-bottom: 0; }
  /* Hovering, or holding the picker or menu open, tints the row the action lands on. Half the focus tint, no edge. */
  .msg { transition: background-color var(--dur-micro) ease; }
  .msg:hover, .msg.menu-open, .msg.picker-open { background: color-mix(in srgb, var(--panel-hi) 28%, transparent); }
  /* Both actions sit in the left gutter on the message's first text line: row 2 under a name, row 1 otherwise. */
  .message-add, .message-more { grid-row: 2; align-self: start; height: 1.55rem; margin: 0; }
  .message-more { position: static; grid-column: 1; justify-self: start; }
  .msg.cont .message-add, .msg.action .message-add, .msg.cont .message-more, .msg.action .message-more { grid-row: 1; }
  .message-avatar { display: grid; grid-column: 2; grid-row: 1 / span 2; align-self: start; width: 2.25rem; height: 2.25rem; margin-top: .1rem; font-size: var(--text-base); }
  .msg .nick { grid-column: 3; grid-row: 1; justify-self: start; text-align: left; font: 700 var(--text-sm)/1.4 var(--ui); }
  .msg .time { grid-column: 4; grid-row: 1; align-self: baseline; justify-self: start; text-align: left; transform: translateY(.1875rem); color: color-mix(in srgb, var(--muted) 45%, transparent); font: 400 var(--text-xs)/1.4 var(--ui); }
  .msg .body { grid-column: 3 / span 2; grid-row: 2; line-height: 1.55; }
  .thread-root-origin { grid-column: 3 / span 2; grid-row: 1; }
  .msg.cont .message-avatar, .msg.cont:not(.action) .nick { display: none; }
  .msg.cont .body { grid-row: 1; }
  .msg.cont .time { display: none; }
  .msg.action .message-avatar { display: none; }
  .msg.action .nick { display: flex; grid-column: 3; grid-row: 1; font: inherit; font-style: italic; color: var(--brand); }
  .msg.action .body { grid-column: 4; grid-row: 1; }
  .msg.action .time { grid-column: 4; grid-row: 1; justify-self: end; align-self: start; margin-top: .3rem; }
}

/* Touch: long-press sheet replaces hover picker + kebab; composer rides the keyboard; 44px targets. */
@media (pointer: coarse) {
  .reaction-tooltip { display: none !important; }
  header { gap: .5rem; padding-inline: 12px; }
  /* Touch header: back, identity pill (name + topic or presence), unread DM avatars. Bell lives in More. */
  header > .notification-control { display: none; }
  .room-heading { flex: 0 1 auto; min-width: 0; margin-left: auto; justify-items: end; }
  .room-title { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; min-height: 2.75rem; max-width: 100%; padding: .3rem .55rem .3rem .35rem; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--panel-hi) 55%, transparent); color: var(--text); gap: .55rem; }
  .room-title .room-mark { width: 2.1rem; height: 2.1rem; font-size: var(--text-base); }
  .room-title-text { align-self: center; text-align: left; line-height: 1.15; }
  .room-title-text > span { font: 650 var(--text-base)/1.15 var(--ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .room-subtitle { display: block; overflow: hidden; color: var(--muted); font: 500 var(--text-xs)/1.2 var(--ui); text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
  .thread-link { gap: .35rem; margin-top: .25rem; color: var(--muted); font: 600 var(--text-xs)/1 var(--ui); white-space: nowrap; }
  .thread-avatar { width: 1.25rem; height: 1.25rem; }
  .room-title-chevron { display: block; flex: 0 0 auto; width: 1rem; height: 1rem; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-back svg, header button svg { width: 1.5rem; height: 1.5rem; stroke-width: 2; }
  /* 44pt hit areas for small visuals */
  .header-dm::after, .image-preview summary::after { content: ""; position: absolute; inset: -.45rem; }
  .mobile-time { font-size: var(--text-2xs); }
  /* Phones reach channels through More, and the channels panel hides both the back arrow and the × when it
     stands alone, so the sheet keeps no + that could strand someone. */
  .section-add { display: none; }
  .header-logo { display: none; }
  /* Signed out there is no back arrow, so the wordmark holds the left edge. */
  body.peeking header .header-logo { display: inline-flex; margin-right: auto; padding-left: .25rem; }
  .room-topic { display: none; }
  header .mobile-back, header .header-icon, header > .notification-control { flex: 0 0 2.75rem; }
  .msg { min-height: 2.75rem; padding: .35rem .25rem; transition: translate var(--dur-micro) ease-out; touch-action: pan-y; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
  .msg .body, .msg .body a { -webkit-touch-callout: none; }
  body:has(.sheet-backdrop:not([style*="display: none"])) { user-select: none; -webkit-user-select: none; }
  .message-add, .message-more, .reaction-picker, .message-menu { display: none; }
  .room, .profile-card, .thread-link { min-height: 2.75rem; }
  .reaction-chip { min-width: 2.75rem; min-height: 2.75rem; padding: .2rem .7rem; font-size: var(--text-base); }
  /* A fixed .5rem baseline lifted by translate to --composer-bottom, so riding the keyboard moves a layer instead of relaying out every frame. */
  .composer { left: 1rem; right: 1rem; bottom: .5rem; width: auto; padding: .5rem calc(.5rem + env(safe-area-inset-right, 0px)) .5rem calc(.5rem + env(safe-area-inset-left, 0px)); box-shadow: none; translate: 0 calc(.5rem - var(--composer-bottom)); transition: translate var(--dur-micro) ease-out; }
  /* iOS pans the page up under the keyboard; --vv-top (composer-editor.ts) moves the bars back into view. */
  header, .mobile-screen-head { translate: 0 var(--vv-top, 0px); }
  /* The phone message avatar is 24px; a 40px invisible pad makes it an easy tap and long press target. */
  .message-avatar.avatar-status-host::before { content: ""; position: absolute; inset: -.5rem; }
  .composer { background: var(--glass-chrome); backdrop-filter: var(--glass-filter); }
  .mobile-nav { background: var(--nav-surface); backdrop-filter: var(--glass-filter); }
  .mobile-screen-head { background: transparent; backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); }
  .mobile-settings-modal { z-index: var(--z-mobile-screen); display: block; overflow: hidden; padding: 0; background: var(--bg); backdrop-filter: none; }
  .mobile-settings-modal .profile-dialog-card { display: flex; flex-direction: column; width: 100%; height: 100dvh; max-height: none; overflow: hidden; padding: 0; border: 0; border-radius: 0; background: var(--bg); box-shadow: none; }
  .mobile-settings-modal .profile-close, .mobile-settings-modal .profile-heading, .mobile-settings-modal .profile-tabs, .mobile-settings-modal .profile-panels > .profile-note, .mobile-settings-modal .profile-panels > .profile-error { display: none !important; }
  .mobile-settings-modal .profile-panels { flex: 1; min-height: 0; height: 100% !important; overflow: hidden; transition: none; }
  .mobile-settings-modal .channel-prefs, .mobile-settings-modal .admin-settings, .mobile-settings-modal .channel-settings, .mobile-settings-modal .agent-settings, .mobile-settings-modal .bot-settings, .mobile-settings-modal .irc-settings { display: flex; height: 100%; min-height: 0; flex-direction: column; }
  .mobile-settings-modal .mobile-settings-head { display: flex; }
  .mobile-settings-modal .channel-prefs-head { display: none; }
  .channel-prefs .mobile-settings-body { align-content: start; }
  .mobile-settings-head .mobile-back, .mobile-head-balance { width: 2.75rem; height: 2.75rem; flex: 0 0 2.75rem; }
  .mobile-settings-head .mobile-back { margin: 0; }
  .mobile-settings-body { min-height: 0; flex: 1; overflow-y: auto; padding: .75rem 1rem calc(var(--nav-h) + var(--nav-lift) + 1rem); }
  .admin-settings > .mobile-settings-body, .channel-settings > .mobile-settings-body, .agent-settings > .mobile-settings-body, .bot-settings > .mobile-settings-body, .irc-settings > .mobile-settings-body { display: flex; flex-direction: column; }
  .admin-settings > .mobile-settings-body::before, .channel-settings > .mobile-settings-body::before, .agent-settings > .mobile-settings-body::before, .bot-settings > .mobile-settings-body::before, .irc-settings > .mobile-settings-body::before { content: ""; margin-top: auto; }
  .chat #messages { padding-bottom: calc(var(--composer-space, 4rem) + var(--nav-h) + var(--nav-lift) + .5rem - var(--kb, 0px)); }
  body.kb-open .chat #messages { padding-bottom: calc(var(--composer-space, 4rem) + .5rem - var(--kb, 0px)); }
  .composer-plus, .composer-send { width: 2.75rem; height: 2.75rem; }
  .composer-plus img { width: 1.1rem; height: 1.1rem; }
  .composer-send img { width: 1.65rem; height: 1.65rem; }
  header button, .channel-kebab { min-width: 2.75rem; min-height: 2.75rem; }
  .channel-menu button, .message-menu button { min-height: 2.75rem; }
  /* Touch: row popovers become bottom sheets, like message actions. */
  /* rooms-sheet's backdrop-filter makes fixed children position relative to it; span the viewport explicitly. */
  .rooms-sheet { backdrop-filter: none; background: var(--bg); }
  .channel-menu { position: fixed; z-index: var(--z-navigation-menu); inset: auto 0 0; width: 100vw; min-width: 0; padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom, 0px)); border: 0; border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent); border-radius: 1.25rem 1.25rem 0 0; background: var(--glass-tint); backdrop-filter: var(--blur-heavy) saturate(1.3); -webkit-backdrop-filter: var(--blur-heavy) saturate(1.3); box-shadow: none; animation: sheet-in var(--dur-base) ease-out; }
  .channel-menu button { min-height: 2.9rem; padding: 0 .9rem; border-radius: var(--radius-md); font: var(--text-base)/1 var(--ui); }
  .channel-menu button:active { background: var(--panel-hi); }
  .channel-menu-topic { display: block; margin: 0 0 .5rem; padding: .4rem .9rem .75rem; border-bottom: 1px solid var(--line); color: var(--muted); font: var(--text-sm)/1.35 var(--ui); overflow-wrap: anywhere; }
  /* Above-composer floaters: composer top edge = --composer-bottom + composer height (--composer-space minus kb and its 16px gap). */
  .toast-region, .giphy-results, .new-below { --above-composer: calc(var(--composer-bottom) + var(--composer-space, 4rem) - var(--kb, 0px) - 16px + .5rem); }
  .toast-region, .new-below { bottom: var(--above-composer); }
  .toast-region.no-composer { bottom: calc(var(--nav-h) + var(--nav-lift) + .75rem); }
  .giphy-results { inset: auto 0 var(--above-composer); }
}
/* A touchscreen laptop reports a coarse primary pointer between touches, which would take the selection
   away from message text with a mouse or trackpad sitting right there. A fine pointer means copyable text. */
@media (any-pointer: fine) {
  .msg { user-select: text; -webkit-user-select: text; }
}
.sheet-backdrop { position: fixed; z-index: var(--z-sheet-backdrop); inset: 0; display: grid; align-items: end; background: #0006; backdrop-filter: var(--blur-light); }
.action-sheet { display: grid; gap: .5rem; padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent); border-radius: 1.25rem 1.25rem 0 0; background: var(--glass-tint); backdrop-filter: var(--blur-heavy) saturate(1.3); -webkit-backdrop-filter: var(--blur-heavy) saturate(1.3); box-shadow: none; animation: sheet-in var(--dur-base) ease-out; }
.sheet-head { display: flex; justify-content: space-between; padding: .25rem .5rem; color: var(--muted); font: var(--text-xs)/1.2 var(--mono); }
.sheet-head strong { color: var(--accent); }
.sheet-reactions { display: flex; gap: .25rem; overflow-x: auto; padding: .25rem; scrollbar-width: none; }
.sheet-reactions button { display: inline-flex; align-items: center; justify-content: center; gap: .25rem; flex: 0 0 auto; min-height: 2.75rem; padding: 0 .45rem; border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--text); font: var(--text-lg)/1 var(--mono); white-space: nowrap; cursor: pointer; }
.sheet-reactions small { color: var(--muted); font-size: var(--text-2xs); }
.sheet-reactions button:active { transform: scale(.94); }
.sheet-actions { display: grid; }
.sheet-reaction-rows { display: grid; }
.sheet-reaction-rows button { min-height: 2.9rem; display: flex; align-items: center; gap: .7rem; padding: 0 .9rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font: var(--text-base)/1 var(--ui); text-align: left; cursor: pointer; }
.sheet-reaction-rows button:active { background: var(--panel-hi); }
.sheet-reaction-rows .rs-emoji { font-size: var(--text-lg); }
.sheet-reaction-rows .rs-count { min-width: 2rem; color: var(--muted); font: 750 var(--text-sm)/1 var(--mono); }
.sheet-reaction-rows .rs-names { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font: var(--text-base)/1 var(--ui); }
.sheet-reaction-rows button.mine .rs-emoji { text-shadow: 0 0 0 var(--brand); }
.sheet-reaction-rows .rs-empty { margin: .25rem 0; padding: .5rem .9rem; color: var(--muted); font-size: var(--text-sm); }
.sheet-divider { height: 1px; margin: .25rem 0; background: color-mix(in srgb, var(--text) 12%, transparent); }
.sheet-actions button { min-height: 2.9rem; padding: 0 .9rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font: var(--text-base)/1 var(--ui); text-align: left; cursor: pointer; display: flex; align-items: center; gap: .7rem; }
.sheet-actions button:active { background: var(--panel-hi); }
.sheet-actions button.danger { color: var(--danger); }
.sheet-actions button.danger:active { background: color-mix(in srgb, var(--danger) 14%, transparent); }
/* 1rem keeps iOS from zooming into the field; the native wheel picks the date and time. */
.action-sheet .remind-form { padding: .25rem .5rem; }
.action-sheet .remind-form input { min-height: 2.9rem; font-size: var(--text-base); }
.action-sheet .remind-form-actions button { min-height: 2.75rem; flex: 1; }
/* The sheet rides above the keyboard while the Add reaction field has focus. */
dialog.custom-modal.sheet-modal { padding: 0 0 var(--kb, 0px); }
.sheet-modal > .action-sheet { width: 100%; margin: auto 0 0; }
/* The finger that opened the sheet is still down over it; Android would select the header text. */
.sheet-modal { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sheet-modal input { user-select: text; -webkit-user-select: text; }
.sheet-reactions button:disabled { opacity: var(--disabled-opacity); cursor: default; }
.sheet-reactions .reaction-search-open { color: var(--muted); }
.sheet-reactions .reaction-search-open .menu-icon { width: 1.35rem; height: 1.35rem; }
.sheet-reaction-search { display: grid; gap: .25rem; }
.sheet-reaction-search .picker-search-input { min-height: 2.75rem; font-size: var(--text-base); }
.sheet-reaction-search .reaction-search-grid { max-height: 14rem; }
.sheet-reaction-search .reaction-search-grid button { min-height: 2.75rem; font-size: var(--text-xl); }
.sheet-reaction-search .reaction-search-grid button:active { background: var(--panel-hi); }
.sheet-reaction-search .reaction-search-code { display: none; }
.reaction-search-back { min-height: 2.75rem; }
@keyframes sheet-in { from { translate: 0 1.5rem; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .action-sheet, .msg, .message-entry { animation: none; transition: none; } }
@media (prefers-reduced-motion: reduce) {
  .composer, .composer-send { transition: none; }
  }

.login input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.login input:focus { border-color: var(--accent); }

.login {
  position: fixed;
  inset: 0;
  width: min(22.5rem, calc(100vw - 2rem));
  height: max-content;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.login-logo { width: 10rem; height: 10rem; margin: 0 auto 1.5rem; object-fit: contain; }
.login label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: var(--text-base);
}
.auth-modal { perspective: 700px; backdrop-filter: none; }
.auth-card { position: relative; padding: 1.25rem 1.25rem .85rem; }
.invite-heading { margin-bottom: .8rem; }
.auth-card .login-logo { width: 7rem; height: 7rem; margin-bottom: .75rem; }
.auth-card .login-logo.login-wordmark { width: auto; height: 2.25rem; margin-bottom: 1.1rem; }
.auth-card:has(.auth-view:not(.collapsed) .email-sent) > .login-logo { display: none; }
.auth-card:has(.auth-view:not(.collapsed) .pair-panel) > .login-logo { display: none; }
.auth-code { margin-top: .5rem; }
.scan-panel { width: 100%; }
.scan-video { width: 100%; max-width: 20rem; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-lg); background: #000; }
.auth-card form { display: grid; gap: 1rem; }
.auth-card .profile-error { display: flex; align-items: flex-start; gap: .5rem; width: 100%; color: var(--danger); font-size: var(--text-sm); line-height: 1.45; text-align: left; overflow-wrap: anywhere; }
.auth-card .profile-error .menu-icon { margin-top: .15rem; }
.auth-card > .profile-error { margin-top: 1rem; }
.auth-card > .auth-denied-signout { margin-top: 1.25rem; }
.auth-divider { display: flex; align-items: center; gap: .6rem; margin: 1.4rem 0 1.3rem; color: var(--muted); font: 650 var(--text-2xs)/1 var(--ui); letter-spacing: .12em; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: color-mix(in srgb, var(--line) 80%, transparent); }
.auth-secondary { display: flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; min-height: 2.5rem; padding: 0 .9rem; border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: var(--radius-md); background: color-mix(in srgb, var(--brand) 6%, transparent); color: var(--text); font: 700 var(--text-sm)/1 var(--ui); cursor: pointer; transition: border-color var(--dur-fast) ease, background-color var(--dur-fast) ease; }
.auth-secondary .menu-icon { color: var(--brand); }
.auth-secondary:not(:disabled):hover, .auth-secondary:focus-visible { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); outline: none; }
.auth-secondary:disabled { opacity: var(--disabled-opacity); cursor: default; }
@media (prefers-reduced-motion: reduce) { .auth-secondary { transition: none; } }
.pair-panel { display: grid; justify-items: center; gap: .7rem; text-align: center; }
.pair-panel h2 { margin: .1rem 0 0; font-size: var(--text-lg); }
.pair-panel-copy { margin: 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.45; }
.pair-code-block { display: grid; place-items: center; gap: .65rem; margin: .15rem 0; }
.pair-code-value { color: var(--text); font: 750 2rem/1 var(--mono); letter-spacing: .14em; text-indent: .14em; font-variant-numeric: tabular-nums; }
.pair-code-block .invite-qr { padding: .7rem; border-radius: var(--radius-md); }
.pair-code-block .invite-qr svg { width: 9rem; height: 9rem; }
.auth-card label { display: grid; gap: .3rem; color: var(--muted); font-size: var(--text-sm); }
.auth-step { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows var(--dur-entrance) ease-in-out, opacity var(--dur-base) ease-in-out; }
.auth-step.collapsed { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.auth-step > div { min-height: 0; overflow: hidden; margin-bottom: .75rem; }
.auth-view > div { margin-bottom: 0; }
.name-step { display: grid; gap: .75rem; }
.name-step p { margin: 0; font-size: var(--text-base); font-weight: 700; }
.name-step > small { color: var(--muted); line-height: 1.4; }
.nickname-logo { display: none; }
.change-email { justify-self: stretch; width: 100%; }
@media (hover: hover) { .change-email:hover { color: var(--text); } }
.email-sent { display: grid; justify-items: center; gap: .75rem; padding: .75rem .5rem .5rem; text-align: center; }
.email-sent-icon { display: grid; width: 7rem; height: 7rem; place-items: center; border-radius: var(--radius-round); background: transparent; color: var(--brand); }
.email-sent-icon.linked { cursor: pointer; }
.email-sent-icon.linked:hover { opacity: .85; }
.email-sent-icon svg { width: 5rem; height: auto; }
.email-sent h2 { margin: .15rem 0 0; font-size: var(--text-lg); }
.email-sent p { margin: 0; color: var(--muted); line-height: 1.5; }
.email-sent strong { color: var(--text); overflow-wrap: anywhere; }
.dev-link { display: grid; justify-items: center; gap: .5rem; padding: .75rem; border: 1px dashed color-mix(in srgb, var(--brand) 50%, transparent); border-radius: var(--radius-lg); }
.dev-link p { margin: 0; color: var(--muted); font-size: var(--text-xs); }
.dev-link a { color: var(--brand); font-weight: 700; word-break: break-all; }
.email-sent .change-email { justify-self: center; }
.email-sent .login-code { display: flex; align-items: end; gap: .5rem; width: 100%; max-width: 20rem; margin-top: .25rem; text-align: left; }
.email-sent .login-code label { flex: 1; }
.email-sent .login-code input { font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.email-sent .login-code .btn-primary { flex: 0 0 auto; }
.email-sent .login-code-error { margin: 0; color: var(--danger); }
.auth-card input { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-md); outline: none; background: var(--bg); color: var(--text); font: inherit; font-size: var(--text-base); }
.auth-card input:focus { border-color: var(--brand); }
.session-pair { display: grid; justify-items: center; gap: .65rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.session-pair-button { min-height: 2.75rem; padding: 0 .8rem; border: 0; background: transparent; color: var(--brand); font: 700 var(--text-sm)/1 var(--ui); cursor: pointer; }
.session-pair-panel { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows var(--dur-entrance) ease-in-out, opacity var(--dur-base) ease-in-out; }
.session-pair-panel.collapsed { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.session-pair-panel > div { display: grid; justify-items: center; gap: .65rem; min-height: 0; overflow: hidden; }
.session-pair-panel p { margin: 0; color: var(--muted); font-size: var(--text-xs); }
.session-pair-qr { align-self: center; }
.session-pair-qr svg { width: 9rem; height: 9rem; }
.session-pair-panel .change-email { justify-self: center; min-height: 2.75rem; }
.session-pair-error { margin: 0; font-size: var(--text-xs); }
.notice-card { position: relative; padding: 1.5rem; text-align: center; }
/* Members list, shared by the desktop panel and the phone sheet. */
.members-icon { display: block; width: 1.1rem; height: 1.1rem; background: currentColor; -webkit-mask: url(/icons/ui/members.svg?v=1) center / contain no-repeat; mask: url(/icons/ui/members.svg?v=1) center / contain no-repeat; }
.members-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; padding: .25rem .5rem .6rem; }
.members-close { margin-left: auto; align-self: center; padding: 0 .2rem; color: var(--muted); }
.members-close:hover, .members-close:focus-visible { color: var(--text); }
.members-head strong { font: 700 var(--text-sm)/1.2 var(--ui); }
.members-head small { color: var(--muted); font-size: var(--text-xs); }
.members-group { margin-bottom: .6rem; }
.members-label { display: flex; justify-content: space-between; margin: 0; padding: .35rem .5rem .2rem; color: var(--muted); font: 700 var(--text-2xs)/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; }
.member-row { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 2.5rem; padding: .3rem .5rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.member-row:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); outline: none; }
@media (hover: hover) { .member-row:hover { background: color-mix(in srgb, var(--text) 8%, transparent); outline: none; } }
.member-row.offline { opacity: .55; }
.member-row .room-mark { width: 1.6rem; height: 1.6rem; }
.member-copy { min-width: 0; display: grid; }
.member-nick { display: flex; align-items: center; gap: .35rem; overflow: hidden; font-size: var(--text-sm); white-space: nowrap; }
.member-nick > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.member-nick .admin-badge { width: .85rem; height: .85rem; }
.member-nick .agent-mark { padding: .12rem .3rem; font-size: .52rem; }
.member-copy small { color: var(--muted); font-size: var(--text-2xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members-empty { margin: 0; padding: .5rem; color: var(--muted); font-size: var(--text-xs); }
.members-sheet .sheet-head { padding-bottom: .35rem; }
/* WebKit can leave a scroller inside a backdrop-filter sheet unpainted until it is touched; its own
   compositing layer keeps the rows drawn. dvh tracks the iOS toolbar. */
.members-sheet-list { max-height: 60dvh; overflow-y: auto; overscroll-behavior: contain; padding: 0 .35rem .5rem; transform: translateZ(0); }
.members-sheet-list .member-row { min-height: 2.9rem; }
/* Command palette (Cmd/Ctrl+K), desktop. */
.palette-modal { align-items: start; padding-top: 12vh; }
.palette-modal .palette { animation: intro-in var(--dur-base) ease both; }
@media (prefers-reduced-motion: reduce) { .palette-modal .palette { animation: none; } }
.palette { width: min(34rem, calc(100vw - 2rem)); overflow: hidden; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-xl); background: color-mix(in srgb, var(--panel) 96%, transparent); box-shadow: var(--shadow-lg); font-family: var(--ui); }
.palette-input { width: 100%; padding: 1rem 1.1rem; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); outline: none; background: transparent; color: var(--text); font: var(--text-base)/1.3 var(--ui); }
.palette-input::placeholder { color: var(--muted); }
.palette-list { max-height: min(24rem, 55vh); overflow-y: auto; padding: .4rem; }
.palette-list button { display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 2.75rem; padding: .45rem .6rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.palette-list button.active { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.palette-list button.danger strong { color: var(--danger); }
.palette-mark { position: relative; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; flex: 0 0 auto; overflow: hidden; border-radius: var(--radius-round); background: var(--panel-hi); color: var(--muted); font: 750 var(--text-xs)/1 var(--ui); }
.palette-mark img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.palette-mark .lock-icon { width: .55rem; height: .8rem; }
.palette-mark .menu-icon { width: .85rem; height: .85rem; }
.palette-slash { color: var(--brand); font: 750 var(--text-sm)/1 var(--mono); }
.palette-copy { min-width: 0; flex: 1; display: grid; }
.palette-copy strong { overflow: hidden; font-size: var(--text-sm); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.palette-copy small { overflow: hidden; color: var(--muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { margin: 0; padding: 1rem .8rem; color: var(--muted); font-size: var(--text-sm); }
.palette-foot { display: flex; gap: .6rem; align-items: center; margin: 0; padding: .55rem 1rem; border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent); color: var(--muted); font-size: var(--text-xs); }
.palette-foot kbd { display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.25rem; margin-right: .1rem; padding: 0 .3rem; border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--bg); color: var(--text); font: 650 var(--text-2xs)/1 var(--ui); }
.notice-dismiss { margin-left: .5rem; }
.notice-card:not(.delete-confirmation) .pair-actions { justify-content: center; }
.notice-card.delete-confirmation { text-align: left; }
.notice-card h2 { margin: .8rem 0 .5rem; font-size: var(--text-lg); }
.notice-card p { color: var(--muted); }
.delete-thread-name { margin: .8rem 0 1rem; padding: .2rem 0 .2rem .8rem; border-left: 2px solid var(--brand); color: var(--text); font-style: italic; font-weight: 550; line-height: 1.4; }
.channel-topic-card { text-align: left; }
.channel-topic-card form, .channel-topic-card label { display: grid; gap: .75rem; }
.channel-topic-card input { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-md); outline: none; background: var(--bg); color: var(--text); font: inherit; }
.channel-topic-card input:focus { border-color: var(--brand); }
.notice-icon { width: 3.5rem; height: 3.5rem; fill: none; stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.notice-steps { padding: .75rem 1rem; border-radius: var(--radius-lg); background: var(--bg); text-align: left; }
.notice-steps ol { margin: .5rem 0; padding-left: 1.25rem; }
.notice-steps li + li { margin-top: .4rem; }

@media (min-width: 700px) {
  header { padding-inline: max(24px, calc((100vw - 860px) / 2)); }
}

.invite-message {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .75rem .9rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
}
.invite-link {
  color: var(--brand);
  word-break: break-all;
  font-family: var(--mono);
  font-size: var(--text-sm);
}
.invite-qr {
  align-self: flex-start;
  background: #fff;
  border-radius: 8px;
  padding: .5rem;
  line-height: 0;
}
.invite-qr svg { width: 8.5rem; height: 8.5rem; }
.invite-copy {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  padding: .4rem .75rem;
  font: inherit;
  cursor: pointer;
}
.invite-copy:hover { border-color: var(--accent); }

.invite-hint { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.invite-actions { display: flex; gap: .5rem; }

.join-eyebrow {
  color: var(--muted);
  font-size: var(--text-xs);
  letter-spacing: .14em;
  text-transform: uppercase;
  margin: 0;
}
.join-heading { color: var(--text); font-size: var(--text-lg); margin: 0; }
.join-note { color: var(--muted); margin: 0; }
.session-expired { display: grid; gap: .75rem; margin-bottom: 1rem; padding: .85rem; border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.session-expired p { margin: 0; color: var(--text); font-size: var(--text-sm); line-height: 1.4; }
.join-error { display: flex; align-items: flex-start; gap: .5rem; margin: 1.25rem 0 0; color: var(--danger); }
.join-error svg { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; margin-top: .15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.join-accept.btn-primary { width: 100%; }

/* An agent's offline notice (+slirc/agent-offline). It stands outside the message layout, like the
   date divider: no author row, aligned to the column's left edge, in the conversation intro's look,
   so it reads as Slirc speaking. Once the agent is back the card leaves the transcript. */
.agent-offline-card { margin: .45rem 0 .6rem; font-family: var(--ui); }
.agent-offline-full { display: flex; align-items: flex-start; gap: .8rem; padding: .85rem .95rem .9rem; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--panel-hi) 50%, transparent); }
.agent-offline-mark { position: relative; display: grid; place-items: center; flex: 0 0 auto; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-round); background: var(--panel-hi); }
.agent-offline-mark img { width: 1.6rem; height: 1.6rem; border-radius: var(--radius-round); filter: grayscale(.7); opacity: .8; }
.agent-offline-mark::after { content: ""; position: absolute; right: -.05rem; bottom: -.05rem; width: .72rem; height: .72rem; border-radius: var(--radius-round); background: var(--muted); box-shadow: 0 0 0 2px var(--panel); }
.agent-offline-main { flex: 1; min-width: 0; }
.agent-offline-head { display: flex; align-items: center; gap: .35rem .55rem; margin: .15rem 0 .2rem; }
.agent-offline-title { min-width: 0; color: var(--text); font: 750 var(--text-base)/1.25 var(--ui); letter-spacing: -.01em; }
.agent-offline-state { flex: 0 0 auto; padding: .12rem .5rem; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); font: 700 var(--text-xs)/1.3 var(--ui); letter-spacing: .03em; }
.agent-offline-time { flex: 0 0 auto; margin-left: auto; color: var(--muted); font: var(--text-xs)/1.3 var(--ui); font-variant-numeric: tabular-nums; }
.agent-offline-hint { margin: 0 0 .65rem; color: var(--muted); font-size: var(--text-sm); line-height: 1.45; }
.agent-offline-command { align-items: flex-start; margin: 0 0 .75rem; }
/* One part per line: `cd <folder>`, then `claude --resume <id>`. A long folder may wrap; the id never does. */
.agent-offline-card .agent-offline-command code { display: grid; gap: .15rem; padding: .5rem 0; background: none; white-space: normal; }
.agent-offline-line { overflow-wrap: anywhere; }
.agent-offline-line:last-child { white-space: nowrap; overflow-wrap: normal; }
.agent-offline-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.agent-offline-actions .btn-secondary { min-height: 2.25rem; }
@media (max-width: 500px) {
  .agent-offline-full { gap: .65rem; padding: .75rem .8rem .8rem; }
  .agent-offline-mark { width: 2.1rem; height: 2.1rem; }
  .agent-offline-mark img { width: 1.35rem; height: 1.35rem; }
  /* A full id can't fit a phone's width: there it breaks at its hyphens, never mid-word, and the
     copy button still copies the one line. */
  .agent-offline-line:last-child { white-space: normal; overflow-wrap: normal; word-break: normal; }
}
}
.channel-intro { margin: 1.5rem 0 2.5rem; padding: 0; font-family: var(--ui); }
.channel-intro-mark { display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: .8rem; border-radius: var(--radius-round); background: var(--panel-hi); color: var(--muted); font: 750 var(--text-lg)/1 var(--ui); }
.channel-intro-mark .lock-icon { width: 1rem; height: 1.4rem; }
.channel-intro-mark .menu-icon { width: 1.5rem; height: 1.5rem; }
/* The shell's inline .menu-icon svg rule pins glyphs at 1rem; the intro's larger icon fills its box. */
.channel-intro-mark .menu-icon svg { width: 100%; height: 100%; }
.dm-intro .channel-intro-mark { position: relative; overflow: hidden; color: #11111b; font: 750 var(--text-lg)/1 var(--ui); }
.dm-intro .channel-intro-mark img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.channel-intro h2 { margin: 0 0 .2rem; font: 750 var(--text-xl)/1.2 var(--ui); letter-spacing: -.02em; }
.channel-intro-meta { margin: 0 0 .7rem; color: var(--muted); font-size: var(--text-xs); }
.channel-intro-topic { max-width: 40rem; margin: 0 0 1rem; color: var(--text); font-size: var(--text-base); line-height: 1.5; }
.channel-intro-topic.muted { color: var(--muted); }
.channel-intro-actions { display: flex; gap: .5rem; }
.channel-intro-actions button { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.25rem; padding: 0 .8rem; border: 0; border-radius: var(--radius-md); font: 650 var(--text-sm)/1 var(--ui); cursor: pointer; }
.channel-intro-actions .menu-icon { width: .9rem; height: .9rem; }
.public-channel-intro { margin: 1rem 0 2rem; padding: 1.25rem 0; }
.public-channel-intro h1 { margin: 0 0 .8rem; color: var(--text); font: 750 clamp(1.7rem, 6vw, 2.8rem)/1 var(--ui); letter-spacing: -.035em; }
.public-motd { display: grid; margin-bottom: .75rem; color: var(--muted); font: var(--text-base)/1.5 var(--mono); }
.public-motd-break { height: .5rem; margin: .65rem 0; line-height: 0; }
.public-motd-cta { color: var(--text); font-weight: 700; }
.public-channel-intro a { color: var(--brand); }
/* Member view of the same welcome: mono copy, sized to sit inside the intro card. */
.channel-intro-lines { max-width: 40rem; margin-bottom: 1rem; font-size: var(--text-base); }
.channel-intro-pulse::before { content: ""; display: inline-block; width: .4rem; height: .4rem; margin-right: .45rem; border-radius: var(--radius-round); background: color-mix(in srgb, var(--muted) 70%, transparent); vertical-align: middle; }
.channel-intro-pulse.fresh::before { background: var(--brand); }
/* Archived channel: a quiet pill in the composer's place, docked the same way. */
.archived-channel { position: fixed; z-index: var(--z-header); left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); width: min(calc(100% - 1rem), 860px); display: flex; align-items: center; justify-content: center; gap: .5rem; margin: 0; padding: .8rem 1rem; border: 1px dashed color-mix(in srgb, var(--line) 95%, transparent); border-radius: var(--radius-pill); background: var(--glass-chrome); backdrop-filter: var(--glass-filter); color: var(--muted); font-size: var(--text-sm); text-align: center; translate: -50% 0; }
.archived-channel .menu-icon { width: 1rem; height: 1rem; flex: 0 0 auto; }
.channel-archive .channel-danger-button { color: var(--text); }
.chat.public-readonly { left: 0; width: min(100%, 860px); inset-block-end: calc(4.8rem + env(safe-area-inset-bottom)); }
body.rooms-docked .chat.public-readonly { left: 0; right: 0; width: min(100%, 860px); margin-inline: auto; }
.public-help-composer { position: fixed; z-index: var(--z-bottom-panel); inset: auto 0 0; display: flex; align-items: stretch; gap: .55rem; width: min(100%, 860px); margin-inline: auto; padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom)); }
.public-help-composer input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: var(--radius-md); outline: none; background: var(--bg); color: var(--text); padding: .7rem .8rem; font: inherit; }
.public-help-composer input:focus { border-color: var(--brand); }

.media-preview {
  order: -2; /* first row, above the + button (order -1), input, and send */
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding: .25rem .15rem 0;
}
.media-chip {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--panel-hi);
}
.media-chip img, .media-chip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: .15rem .3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #000a;
  color: var(--text);
  font: var(--text-2xs)/1.2 var(--mono);
}
.media-remove {
  position: absolute;
  top: .15rem;
  right: .15rem;
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-round);
  background: #0009;
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
}
.media-remove:hover { background: var(--danger); color: var(--bg); }

.lightbox {
  width: fit-content;
  max-width: none;
  max-height: none;
  grid-template-rows: auto auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  overflow: visible;
  background: #050508ee;
  color: var(--text);
  box-shadow: 0 2rem 6rem #000c;
}
.lightbox[open] { display: grid; position: fixed; inset: 0; width: fit-content; max-width: 92vw; height: fit-content; margin: auto; max-height: 94dvh; align-content: start; }
.lightbox::backdrop { background: #050508cc; backdrop-filter: var(--blur-light); }
.lightbox-media { display: grid; place-items: center; border-radius: var(--radius-md); overflow: hidden; background: #000; color-scheme: dark; }
.lightbox-media video { display: block; width: auto; height: auto; max-width: 92vw; max-height: calc(94dvh - 2.75rem); object-fit: contain; }
/* Images stay natural-sized until the viewport is too small; maximize remains explicit. */
.lightbox-media img { display: block; width: auto; height: auto; max-width: 92vw; max-height: calc(94dvh - 2.75rem); object-fit: contain; }
/* Players: as much of the viewport as 16:9 allows, whichever side binds. */
.lightbox-media iframe { --ar: 1.7778; display: block; width: min(92vw, calc(82dvh * var(--ar)), 1400px); aspect-ratio: var(--ar); height: auto; border: 0; border-radius: var(--radius-md); background: #000; color-scheme: dark; }
.lightbox-media iframe.compact { width: min(92vw, 40rem); }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 2.75rem; padding: .3rem .4rem .3rem .85rem; }
.lightbox-meta { min-width: 0; display: grid; gap: .05rem; opacity: .5; transition: opacity var(--dur-base) ease; }
.lightbox-bar:focus-within .lightbox-meta { opacity: 1; }
@media (hover: hover) { .lightbox-bar:hover .lightbox-meta { opacity: 1; } }
.lightbox-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 650 var(--text-sm)/1.25 var(--ui); }
.lightbox-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: var(--text-xs); }
.lightbox-actions { display: flex; align-items: center; gap: .1rem; flex: 0 0 auto; margin-left: auto; }
.lightbox-btn { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); cursor: pointer; opacity: .5; transition: opacity var(--dur-base) ease, background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.lightbox-btn:focus-visible { opacity: 1; }
@media (hover: hover) { .lightbox-bar:hover .lightbox-btn { opacity: 1; } }
.lightbox-btn:focus-visible { background: var(--panel-hi); color: var(--text); outline: none; }
@media (hover: hover) { .lightbox-btn:hover { background: var(--panel-hi); color: var(--text); outline: none; } }
.lightbox-btn:active { transform: scale(.92); }
.lightbox-btn .menu-icon { width: 1rem; height: 1rem; }
.ui-icon { display: block; width: 1rem; height: 1rem; background: currentColor; -webkit-mask: var(--ui-icon) center / contain no-repeat; mask: var(--ui-icon) center / contain no-repeat; }
.icon-xmark { --ui-icon: url(/icons/ui/xmark.svg?v=1); width: .8rem; height: .8rem; }
.icon-expand { --ui-icon: url(/icons/ui/expand.svg?v=1); }
.icon-collapse { --ui-icon: url(/icons/ui/collapse.svg?v=1); }
.lightbox.maximized { inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; translate: none; border-radius: 0; grid-template-rows: 1fr auto; align-content: stretch; }
.lightbox.maximized .lightbox-media { border-radius: 0; }
.lightbox.maximized .lightbox-media img, .lightbox.maximized .lightbox-media video, .lightbox.maximized .lightbox-media iframe { width: 100vw; height: calc(100dvh - 2.75rem); max-width: none; max-height: none; aspect-ratio: auto; object-fit: contain; }
@media (pointer: coarse) { .lightbox-btn:has(.icon-expand), .lightbox-btn:has(.icon-collapse) { display: none; } }

.embed-card {
  position: relative;
  width: min(100%, 440px);
  margin-top: .45rem;
}
.embed-og {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: color-mix(in srgb, var(--panel) 76%, transparent);
  backdrop-filter: var(--blur-medium);
}
.embed-og > a { display: flex; gap: .75rem; padding: .6rem; color: inherit; text-decoration: none; }
@media (hover: hover) { .embed-og > a:hover { background: color-mix(in srgb, var(--panel-hi) 55%, transparent); } }
.embed-og img { width: 7rem; height: 5rem; flex: 0 0 auto; object-fit: cover; border-radius: var(--radius-sm); }
.embed-copy { min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.embed-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font: 700 var(--text-sm)/1.25 var(--ui); }
.embed-copy span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font: var(--text-xs)/1.35 var(--ui); }
.embed-copy small { color: color-mix(in srgb, var(--muted) 80%, transparent); font: var(--text-2xs)/1.2 var(--ui); }
.embed-thumb {
  position: relative;
  width: min(100%, 440px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  cursor: pointer;
}
.embed-thumb img, .msg .body .embed-thumb img { display: block; width: 100%; height: auto; max-width: none; max-height: none; aspect-ratio: 16 / 9; border-radius: 0; object-fit: cover; }
.embed-inline { display: block; width: 100%; border: 0; border-radius: 12px; background: transparent; }
/* Spotify's strip stops reflowing under 300px and crops. Narrow columns keep the strip at 300px and scale it
   down in steps; the negative margin makes the card follow the visual height. */
@container (max-width: 300px) {
  .embed-card:has(.embed-inline) { overflow: hidden; }
  .embed-inline { --s: .9; width: 300px; transform-origin: 0 0; transform: scale(var(--s)); margin-bottom: calc(152px * (var(--s) - 1)); }
}
@container (max-width: 270px) { .embed-inline { --s: .8; } }
@container (max-width: 240px) { .embed-inline { --s: .72; } }
@container (max-width: 216px) { .embed-inline { --s: .65; } }
.embed-player { display: grid; min-height: 6rem; }
.embed-player img, .embed-player .embed-player-copy, .embed-player .embed-play { grid-area: 1 / 1; }
.embed-player .embed-player-copy { z-index: var(--z-content); align-self: end; display: grid; gap: .1rem; padding: .6rem .75rem; background: linear-gradient(transparent, #000c); color: #fff; }
.embed-player .embed-player-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 var(--text-sm)/1.25 var(--ui); }
.embed-player .embed-player-copy small { font-size: var(--text-2xs); opacity: .8; }
.embed-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.embed-play::before {
  content: "";
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-round);
  background: #0009;
  box-shadow: 0 0 0 6px #0005;
  transition: transform var(--dur-micro) var(--ease-standard);
}
.embed-play::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  margin-left: .2rem;
  border-left: .85rem solid var(--brand);
  border-top: .55rem solid transparent;
  border-bottom: .55rem solid transparent;
}
.embed-thumb:hover .embed-play::before { transform: scale(1.12); }

/* Threads nest one step under their channel; only the active channel shows them, four at most. */
.nested-thread > .room { padding-left: 1.85rem; }
.nested-thread .room-mark { width: 1.1rem; height: 1.1rem; }
.nested-thread .room-mark .menu-icon { width: .85rem; height: .85rem; }
.thread-more { color: var(--muted); }
.mobile-row.nested { padding-left: 2.6rem; min-height: 2.5rem; }
.mobile-row.nested .room-mark { width: 1.4rem; height: 1.4rem; }
.mobile-row.nested strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-section-toggle svg { margin-left: auto; }
.row-chevron { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; margin-right: -.5rem; border-radius: var(--radius-round); color: var(--muted); }
.row-chevron svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transition: transform var(--dur-fast) ease; }
.row-chevron.collapsed svg { transform: none; }


.agent-connected-title { display: flex; align-items: center; gap: .45rem; margin: 0 0 .25rem; }
.agent-connected-title .menu-icon { color: var(--brand); width: 1.1rem; height: 1.1rem; }
.agent-connected .pair-actions { gap: .6rem; margin-top: .75rem; }

/* New conversation dialog, groups under DMs, and the sent-invitations page. */
.section-head { display: flex; align-items: center; margin: 16px 0 7px; }
.section-head .section-title { flex: 1; min-width: 0; margin: 0; }
.mobile-section-head { display: flex; align-items: center; justify-content: space-between; margin: 1.05rem .65rem .35rem; }
.mobile-section-head .mobile-section-label { margin: 0; }
.plus-button { flex: 0 0 auto; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; transition: background-color var(--dur-fast) ease; }
.plus-button img { width: 1rem; height: 1rem; opacity: .55; }
.plus-button:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.plus-button:hover img { opacity: 1; }
.plus-button:active { transform: scale(.92); }
.plus-button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.mobile-screen-head .plus-button { margin-left: auto; margin-right: .35rem; }

.rail-link { display: flex; align-items: center; gap: .4rem; width: 100%; margin-bottom: .3rem; padding: .4rem .55rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--muted); font: 650 var(--text-xs)/1 var(--ui); text-align: left; cursor: pointer; transition: color var(--dur-fast) ease; }
.rail-link:hover, .rail-link:focus-visible { color: var(--text); }
/* Ghost shortcut: an active route reads from text colour, never a filled panel. */
.rail-link.active { color: var(--text); }
.rail-link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.rail-link .menu-icon { width: .9rem; height: .9rem; }
/* One shared ghost row owns the hover/focus background; the invite action flexes, the X sits in flow. */
.rail-shortcut { display: flex; align-items: center; gap: .1rem; margin-bottom: .3rem; padding-right: .1rem; border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel) 55%, transparent); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); transition: background-color var(--dur-fast) ease; }
/* The shortcut floats over the scrolling list; the tint keeps Chromium's blur readable. */
.rail-shortcut:hover, .rail-shortcut:focus-within { background: color-mix(in srgb, var(--panel-hi) 70%, transparent); }
.rail-shortcut .rail-link { flex: 1; min-width: 0; margin-bottom: 0; }
.rail-dismiss { flex: 0 0 auto; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; opacity: 0; pointer-events: none; transition: opacity var(--dur-micro) ease, color var(--dur-fast) ease; }
.rail-shortcut:hover .rail-dismiss, .rail-shortcut:focus-within .rail-dismiss { opacity: 1; pointer-events: auto; }
.rail-dismiss:hover, .rail-dismiss:focus-visible { color: var(--text); }
.rail-dismiss:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.rail-dismiss .menu-icon { width: .75rem; height: .75rem; }
/* Touch has no hover, so the X stays discoverable and tappable. */
@media (pointer: coarse) {
  .rail-shortcut .rail-dismiss { opacity: 1; pointer-events: auto; width: 2.75rem; height: 2.75rem; }
}

.new-conversation-card { box-sizing: border-box; width: min(30rem, 100%); overflow: hidden; text-align: left; transition: height var(--dur-base) ease; }
.new-conversation-content, .new-conversation-form { display: grid; gap: .55rem; }
.new-conversation-success { display: grid; gap: .75rem; }
.new-conversation-success p { margin: 0; }
@media (prefers-reduced-motion: reduce) { .new-conversation-card { transition: none; } }
.new-conversation-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.new-conversation-title-row { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.new-conversation-head h2 { margin: 0; font: 700 var(--text-lg)/1.3 var(--ui); }
.dialog-close { display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.dialog-close:hover, .dialog-close:focus-visible { background: var(--panel-hi); color: var(--text); }
.dialog-close svg { width: 1.1rem; height: 1.1rem; }
.new-conversation-field { display: grid; }
.new-conversation-field input { min-height: 2.5rem; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); color: var(--text); font: var(--text-sm)/1.3 var(--ui); }
.new-conversation-field input:focus { border-color: var(--brand); outline: none; }
.new-conversation-results { display: grid; gap: .1rem; max-height: 14rem; overflow-y: auto; margin: 0 -.5rem; padding: 0 .25rem; overscroll-behavior: contain; }
.new-conversation-person { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .4rem .5rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.new-conversation-person:hover, .new-conversation-person.active, .new-conversation-person:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); }
.new-conversation-person:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.new-conversation-person-main { display: flex; flex-direction: column; min-width: 0; }
.new-conversation-person-main strong { font: 650 var(--text-sm)/1.2 var(--ui); }
.new-conversation-person-main small { color: var(--muted); font: var(--text-xs)/1.2 var(--mono); }
.new-conversation-hint { margin: .1rem .25rem; color: var(--muted); font: var(--text-xs)/1.4 var(--ui); }
.new-conversation-email { display: grid; gap: .75rem; margin-top: .35rem; }
.new-conversation-email .field-hint { margin: 0; }
.new-conversation-email-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .5rem; }
.new-conversation-email-actions .btn-primary { margin-left: auto; }
/* Invite many: a ledger of addresses with one status each, a bar that counts them, and a meter while sending. */
.bulk-invite-card { box-sizing: border-box; width: min(36rem, 100%); max-height: calc(100dvh - 2rem); display: flex; flex-direction: column; text-align: left; }
.bulk-invite-body { display: grid; gap: var(--space-3); min-height: 0; }
.bulk-invite-card .new-conversation-head { margin-bottom: var(--space-4); }
.bulk-invite-card .new-conversation-head h2 { margin: 0; }
.bulk-invite-body .pair-actions { margin-top: var(--space-1); }
.bulk-invite-field { display: grid; gap: var(--space-1); font-size: var(--text-sm); color: var(--muted); }
.bulk-invite-field select { min-height: 2.5rem; padding: .55rem 2.4rem .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-md); outline: none; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239399b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right .85rem center / 1rem; color: var(--text); font: var(--text-sm)/1.35 var(--ui); appearance: none; -webkit-appearance: none; cursor: pointer; }
.bulk-invite-field select:focus { border-color: var(--brand); }
.bulk-invite-hint { margin: 0; }
/* Disabled reads as unavailable, not as a dimmer go button. */
.bulk-invite-body .btn-primary:disabled { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); opacity: 1; }
.bulk-invite-drop { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); transition: border-color var(--dur-fast) var(--ease-standard), background-color var(--dur-fast) var(--ease-standard); }
.bulk-invite-drop:focus-within { border-color: var(--brand); }
.bulk-invite-drop.dragging { border-style: dashed; border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--bg)); }
.bulk-invite-drop textarea { display: block; box-sizing: border-box; width: 100%; min-height: 9rem; padding: .6rem .7rem; border: 0; outline: none; background: transparent; color: var(--text); font: var(--text-sm)/1.55 var(--mono); resize: vertical; }
.bulk-invite-drop-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) var(--space-2) var(--space-1) .7rem; border-top: 1px solid var(--line); font-size: var(--text-xs); color: var(--muted); }
.bulk-invite-count { font-variant-numeric: tabular-nums; }
.bulk-invite-file { position: relative; display: inline-flex; align-items: center; gap: var(--space-1); min-height: 2rem; font-size: var(--text-xs); }
.bulk-invite-file:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-sm); }
.bulk-invite-file .menu-icon svg { width: .9rem; height: .9rem; }
.bulk-invite-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.bulk-invite-entry { margin: .35rem 0 0; }
.bulk-invite-entry .link-button { padding: 0; font-size: inherit; }
.bulk-invite-body { --tone-go: var(--brand); --tone-add: var(--mine); --tone-held: var(--warning); --tone-bad: var(--danger); --tone-quiet: var(--muted); }
.bulk-invite-bar { display: flex; gap: 2px; height: .5rem; border-radius: var(--radius-pill); overflow: hidden; background: var(--panel-hi); }
.bulk-invite-bar > span { min-width: 4px; transition: flex-grow var(--dur-entrance) var(--ease-standard); }
.bulk-invite-bar .tone-go, .bulk-invite-legend .tone-go::before { background: var(--tone-go); }
.bulk-invite-bar .tone-add, .bulk-invite-legend .tone-add::before { background: var(--tone-add); }
.bulk-invite-bar .tone-held, .bulk-invite-legend .tone-held::before { background: var(--tone-held); }
.bulk-invite-bar .tone-bad, .bulk-invite-legend .tone-bad::before { background: var(--tone-bad); }
.bulk-invite-bar .tone-quiet, .bulk-invite-legend .tone-quiet::before { background: color-mix(in srgb, var(--tone-quiet) 55%, transparent); }
.bulk-invite-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin: 0; padding: 0; list-style: none; font: var(--text-xs)/1.4 var(--ui); color: var(--muted); }
.bulk-invite-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.bulk-invite-legend li::before { content: ""; width: .5rem; height: .5rem; border-radius: var(--radius-round); }
.bulk-invite-legend strong { color: var(--text); font-variant-numeric: tabular-nums; }
.bulk-invite-progress { display: grid; gap: var(--space-1); font-size: var(--text-xs); color: var(--muted); }
.bulk-invite-progress .join-link-meter { margin: 0; height: 4px; }
.bulk-invite-progress .join-link-meter > span { transition: width var(--dur-entrance) var(--ease-standard); }
.bulk-invite-note { margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--text); font-size: var(--text-xs); line-height: 1.45; }
.bulk-invite-table { max-height: min(22rem, 45dvh); overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-md); overscroll-behavior: contain; }
.bulk-invite-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; padding: .45rem .7rem; border-left: 3px solid transparent; }
.bulk-invite-row + .bulk-invite-row { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.bulk-invite-who { display: grid; min-width: 0; }
.bulk-invite-who strong, .bulk-invite-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-invite-who strong { font: 500 var(--text-sm)/1.35 var(--mono); }
.bulk-invite-who small { color: var(--muted); font: var(--text-xs)/1.35 var(--mono); }
.bulk-invite-status { display: grid; justify-items: end; font: 600 var(--text-xs)/1.3 var(--ui); color: var(--muted); white-space: nowrap; }
.bulk-invite-status small { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.bulk-invite-row.tone-go { border-left-color: var(--tone-go); } .bulk-invite-row.tone-go .bulk-invite-status { color: var(--tone-go); }
.bulk-invite-row.tone-add { border-left-color: var(--tone-add); } .bulk-invite-row.tone-add .bulk-invite-status { color: var(--tone-add); }
.bulk-invite-row.tone-held { border-left-color: var(--tone-held); } .bulk-invite-row.tone-held .bulk-invite-status { color: var(--tone-held); }
.bulk-invite-row.tone-bad { border-left-color: var(--tone-bad); } .bulk-invite-row.tone-bad .bulk-invite-status { color: var(--tone-bad); }
.bulk-invite-row.tone-quiet .bulk-invite-who strong { color: var(--muted); }
@media (max-width: 40rem) {
  .bulk-invite-offer .phone-offer-intro { flex-wrap: wrap; }
  .bulk-invite-offer .phone-offer-intro .btn-primary { flex: 1 1 100%; min-height: 2.75rem; }
  .bulk-invite-dialog { padding: 0; }
  .bulk-invite-card { width: 100%; max-height: none; min-height: 100dvh; border-radius: 0; padding: calc(var(--space-4) + env(safe-area-inset-top)) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .bulk-invite-table { max-height: none; flex: 1; }
  .bulk-invite-row { grid-template-columns: 1fr; gap: .1rem; }
  .bulk-invite-status { justify-items: start; }
  .bulk-invite-body .pair-actions .btn-primary { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .bulk-invite-bar > span, .bulk-invite-progress .join-link-meter > span, .bulk-invite-drop { transition: none; } }
.new-conversation-outcomes { display: grid; gap: .3rem; margin: 0; padding: 0; list-style: none; }
.new-conversation-outcomes li { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; padding: .35rem .5rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--brand) 10%, transparent); font: var(--text-xs)/1.3 var(--ui); }
.new-conversation-outcomes li.warn { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.new-conversation-outcomes small { flex-basis: 100%; color: var(--muted); }

.invitations-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.invitations-heading h3 { margin: 0; font: 700 var(--text-lg)/1.3 var(--ui); }
.invitation-quota { margin: 0; color: var(--muted); font: var(--text-sm)/1.3 var(--ui); text-align: right; }
.invitation-quota strong { color: var(--brand); font-variant-numeric: tabular-nums; }
.invitation-explainer { margin: .4rem 0 .9rem; }
.invitation-empty { margin: .75rem 0 0; padding: .875rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel) 60%, transparent); color: var(--muted); font: var(--text-base)/1.45 var(--ui); }
.invitation-empty a { color: var(--mine); }
/* Invitations vertical rhythm. Deliberate groups (heading / copy / feedback / actions), scoped
   here so the shared .field-hint negative margin and other profile pages stay untouched. */
.invitations-page .invitations-heading { margin: 0 0 .8rem; }
.invitations-page .field-hint { margin: .4rem 0 0; font-size: var(--text-base); }
.invitations-page .invitation-explainer { margin: 0 0 1.6rem; }
.invitations-page .invitation-empty { margin-top: 1.6rem; }
.invitations-page .profile-error { margin: 1rem 0 0; font-size: var(--text-base); }
.invitations-page .admission-requests { margin-top: 2.4rem; }
/* Compact informative notice: subtle panel for empty state, light danger tint for a load failure
   with its Retry inside. Placed after the scoped .profile-error rules so the inner copy loses
   their leading margin. No stripe, no divider. */
.invitation-notice-error { margin: 1rem 0 0; padding: .875rem 1rem; border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); border-radius: var(--radius-md); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.invitation-notice-error .profile-error { margin: 0; }
.invitation-notice-error .btn-secondary { margin-top: .75rem; background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.invitation-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.invitation-row { display: grid; gap: .4rem; padding: .6rem .65rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel) 60%, transparent); }
.invitation-main { display: flex; align-items: center; gap: .6rem; }
.invitation-main .room-mark { flex: 0 0 auto; }
.invitation-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.invitation-copy strong { font: 650 var(--text-base)/1.3 var(--ui); overflow-wrap: anywhere; }
.invitation-copy small { color: var(--muted); font: var(--text-xs)/1.3 var(--ui); }
.invitation-status { flex: 0 0 auto; padding: .2rem .5rem; border-radius: var(--radius-pill); font: 700 var(--text-xs)/1 var(--ui); text-transform: uppercase; letter-spacing: .05em; background: var(--panel-hi); color: var(--muted); }
.invitation-status.status-pending, .invitation-status.status-sending, .invitation-status.status-accepted { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); }
.invitation-status.status-expired, .invitation-status.status-cancelled { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--muted); }
.invitation-status.status-failed, .invitation-status.status-uncertain { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.invitation-actions { display: grid; gap: .35rem; }
.invitation-actions-row { display: flex; gap: .5rem; }
.invitation-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--danger); font: 650 var(--text-sm)/1.2 var(--ui); }
@media (prefers-reduced-motion: reduce) { .plus-button, .rail-link, .rail-shortcut, .rail-dismiss { transition: none; } }

/* Invitation landing/acceptance. Reuses the shared auth-card and join-* typography. */
.invitation-card { display: grid; gap: .75rem; text-align: left; }
.invitation-body { display: grid; gap: .9rem; }
.invitation-body h2 { margin: 0; font: 700 var(--text-lg)/1.3 var(--ui); }
.invitation-body form { display: grid; gap: .85rem; }
.invitation-body .join-accept { width: 100%; margin-top: .25rem; }
.invitation-dismiss { justify-self: start; }

/* Admission. Reuses the invitation card, join-* typography and invitation rows; only the action
   row needs a narrow stacked layout so both destinations stay full-width on a phone. */
.admission-card { display: grid; gap: .75rem; text-align: left; }
.admission-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.admission-actions button { min-height: 2.75rem; }
.admission-card .btn-primary { min-height: 2.75rem; width: 100%; }
.admission-card .link-button { min-height: 2.75rem; padding-inline: .5rem; }
@media (max-width: 30rem) { .admission-actions { display: grid; } .admission-actions button { width: 100%; } }
.admission-dismiss { justify-self: start; }

/* One palette, selected before paint by theme.js. Brand fills stay lime; ink meets text contrast. */
:root[data-theme="light"] {
  --nav-surface: color-mix(in srgb, #dce0e8 88%, transparent);
  color-scheme: light;
  --glass-filter: var(--blur-medium) saturate(1.1);
  --bg: #eff1f5;
  --bg-glow: radial-gradient(max(50vw, 34rem) 34rem at 50% -10rem, #fff, var(--bg));
  --panel: #e6e9ef;
  --panel-hi: #e6e9ef;
  --text: #4c4f69;
  --muted: #65687e;
  --line: #ccd0da;
  --brand: #237719;
  --mine: #2b726a;
  --on-brand: #4c4f69;
  --danger: #af425a;
  --warning: #856000;
  --attention: #a34b09;
  --mention-fill: #c3e9c3;
  --mention-ink: var(--text);
  --shadow: #4c4f691a;
  --shadow-sm: 0 .2rem .6rem var(--shadow);
  --shadow-md: 0 .5rem 1.5rem var(--shadow);
  --shadow-lg: 0 1rem 3rem var(--shadow);
  --active-fill: #d9eddc;
  --active-ring: #2377192e;
  --mention-me-fill: #b8e7b6;
  --avatar-fill: #ccd0da;
  /* Light panel-hi equals panel, so secondary buttons take Surface0/Surface1 to stay visible on cards. */
  --secondary-fill: #ccd0da;
  --secondary-fill-hover: #bcc0cc;
}
.theme-setting { margin: 1rem 0 .5rem; }
/* Both controls use real Lucide glyphs, not dark-only coloured image assets. */
.composer .composer-plus, .composer .composer-send {
  width: 2.5rem; height: 2.5rem; border: 0; border-radius: var(--radius-round);
  background: var(--brand-fill); color: var(--on-brand);
}
/* + is secondary to Send: plain muted glyph, no brand circle. */
.composer .composer-plus { background: transparent; color: var(--muted); }
.composer .composer-plus:hover, .composer .composer-plus:active { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.composer-plus svg, .composer-send svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.composer .composer-send:not(:disabled) { opacity: 1; }
.composer-plus:disabled { opacity: var(--disabled-opacity); cursor: default; }
.composer-send:focus-visible, .btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (pointer: coarse) { .composer .composer-plus, .composer .composer-send { width: 2.75rem; height: 2.75rem; } }
:root[data-theme="light"] .channel-row:has(.room.active),
:root[data-theme="light"] .room.active.draft-room,
:root[data-theme="light"] .room.active.thread-room { background: var(--active-fill); box-shadow: inset 0 0 0 1px var(--active-ring); }
:root[data-theme="light"] .room.active { background: var(--active-fill); color: var(--text); box-shadow: inset 0 0 0 1px var(--active-ring); }
:root[data-theme="light"] .channel-row > .room.active { background: transparent; box-shadow: none; }
:root[data-theme="light"] .room.active .room-mark, :root[data-theme="light"] .room.active .room-mark:not(:has(img[src^="data:image/svg+xml"])):not(:has(img[src^="/icons/agents/"])) { box-shadow: 0 0 0 2px var(--active-ring); }
:root[data-theme="light"] :where(.peer-avatar, .profile-avatar, .message-avatar, .mention-avatar, .typing-avatar, .thread-avatar) { background: var(--avatar-fill); }
/* Initials sit on pastel fills in both themes, so they keep dark ink; --bg would turn them white here. */
:root[data-theme="light"] :where(.profile-avatar, .message-avatar, .profile-modal-avatar) { color: var(--text); }
:root[data-theme="light"] .chat .msg .body .mention.me { background: var(--mention-me-fill); color: var(--text); }
:root[data-theme="light"] .msg .body a { text-decoration: underline; text-underline-offset: .15em; }
:root[data-theme="light"] .msg .time, :root[data-theme="light"] .mobile-time { color: var(--muted); font-weight: 300; }
:root[data-theme="light"] .mobile-nav button .menu-icon { filter: grayscale(1) brightness(.55); }
:root[data-theme="light"] .mobile-nav button.active .menu-icon,
:root[data-theme="light"] .plus-button img, :root[data-theme="light"] .section-add img,
:root[data-theme="light"] .home-brand img[src*="/icons/ui/"] { filter: brightness(.52) saturate(1.6); }
/* The shell wordmark: slirc.org on the public playground, slirc.app on private workspaces (data-brand from the server). */
:root[data-theme="light"] img.brand-wordmark { content: url("/brand-org-light.svg"); }
:root[data-brand="app"] img.brand-wordmark { content: url("/brand-app-dark.svg"); }
:root[data-brand="app"][data-theme="light"] img.brand-wordmark { content: url("/brand-app-light.svg"); }
:root[data-theme="light"] img[src*="/logo.webp"] { content: url("/logo-light.webp"); }
:root[data-theme="light"] img[src="/icons/slirc.svg"] { content: url("/icons/slirc-light.svg"); }
:root[data-theme="light"] img[src*="/icons/ui/nav-home.svg"] { content: url("/icons/ui/nav-home-light.svg"); }
:root[data-theme="light"] img[src*="/icons/ui/nav-dms.svg"] { content: url("/icons/ui/nav-dms-light.svg"); }
/* The light gradient icons carry their own colour; only the monochrome ones need the darkening filter. */
:root[data-theme="light"] .mobile-nav button.active .menu-icon:is([src*="/icons/ui/nav-home"], [src*="/icons/ui/nav-dms"]),
:root[data-theme="light"] .home-brand img[src*="/icons/ui/nav-dms"] { filter: none; }
/* Helper bot marks are data URIs in Catppuccin Mocha colours; light swaps each for its Latte file. */
:root[data-theme="light"] img[src^="data:image/svg+xml"][src*="41F79B" i] { content: url("/icons/bots/help-light.svg"); }
:root[data-theme="light"] img[src^="data:image/svg+xml"][src*="fab387" i] { content: url("/icons/bots/remind-light.svg"); }
:root[data-theme="light"] img[src^="data:image/svg+xml"][src*="cba6f7" i] { content: url("/icons/bots/poll-light.svg"); }
:root[data-theme="light"] img[src^="data:image/svg+xml"][src*="89dceb" i] { content: url("/icons/bots/welcome-light.svg"); }
:root[data-theme="light"] img[src^="data:image/svg+xml"][src*="f9e2af" i] { content: url("/icons/bots/updates-light.svg"); }
/* Monochrome agent marks are drawn in the dark text colour; light swaps in the Latte text variant. */
:root[data-theme="light"] img[src="/icons/agents/pi.svg"] { content: url("/icons/agents/pi-light.svg"); }
:root[data-theme="light"] img[src="/icons/agents/agent.svg"] { content: url("/icons/agents/agent-light.svg"); }
:root[data-theme="light"] img[src*="/wordmark"] { filter: brightness(0) saturate(100%) invert(31%) sepia(12%) saturate(1046%) hue-rotate(195deg) brightness(94%) contrast(88%); }
:root[data-theme="light"] .custom-modal, :root[data-theme="light"] .sheet-backdrop,
:root[data-theme="light"] body:not(.rooms-docked) .rooms, :root[data-theme="light"] .delete-dialog::backdrop { background: #4c4f6926; }
:root[data-theme="light"] .glass-toast, :root[data-theme="light"] .new-below,
:root[data-theme="light"] .notify-banner, :root[data-theme="light"] .pull-indicator { backdrop-filter: var(--blur-medium); -webkit-backdrop-filter: var(--blur-medium); }
:root[data-theme="light"] .glass-toast.hud { backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); }
:root[data-theme="light"] .profile-dialog-card, :root[data-theme="light"] .notice-card, :root[data-theme="light"] .auth-card, :root[data-theme="light"] .delete-dialog { background: var(--bg); }
:root[data-theme="light"] .profile-dialog-card label { color: var(--text); }
.btn-secondary.busy::after { border-top-color: var(--text); }
.btn-danger.busy::after { border-top-color: var(--bg); }
:root[data-theme="light"] .btn-danger:not(:disabled):hover, :root[data-theme="light"] .btn-danger:focus-visible { background: color-mix(in srgb, var(--danger) 90%, black); }
/* Media is still a dark viewing surface, regardless of the surrounding app theme. */
:root[data-theme="light"] .lightbox { color: #cdd6f4; --text: #cdd6f4; --brand: #a6e3a1; --line: #313244; }

.admission-founder .invitation-actions-row { flex-wrap: wrap; }
@media (max-width: 34rem) { .invitations-heading { align-items: flex-start; flex-direction: column; gap: .2rem; } .invitation-quota { text-align: left; } .invitations-page .invitations-heading { margin-bottom: .75rem; } .invitations-page .invitation-explainer { margin-bottom: 1.25rem; } .invitations-page .invitation-empty { margin-top: 1.25rem; } .invitations-page .admission-requests { margin-top: 1.75rem; } }
/* After the light hover override so the notice ring wins in both themes. */
:root .invitation-notice-error .btn-secondary:not(:disabled):hover, :root .invitation-notice-error .btn-secondary:focus-visible { background: color-mix(in srgb, var(--danger) 12%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 55%, var(--line)), 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
/* People: the admin's open join link, above the sent invitations. The shell is the Devices
   "Add your phone" card (.phone-offer); rows, pills and buttons are the existing ones. */
.join-links { grid-template-columns: minmax(0, 1fr); margin-bottom: 1.5rem; }
.profile-dialog-card .join-link-form { display: flex; align-items: center; gap: .6rem; }
.profile-dialog-card .join-link-form select { width: auto; flex: 1 1 0; min-width: 0; }
.profile-dialog-card .join-link-form .btn-primary { flex: 0 0 auto; width: auto; }
.join-link-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; margin: 0; padding: 0; list-style: none; }
.join-link-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; padding: .6rem .5rem .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel) 60%, transparent); transition: border-color var(--dur-base) ease; }
.join-link-row.fresh { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); background: color-mix(in srgb, var(--brand) 5%, var(--panel)); }
.join-link-row.past .join-link-copy strong { color: var(--muted); }
.join-link-line { display: flex; align-items: center; gap: .6rem; }
.join-link-copy { display: grid; gap: .15rem; flex: 1; min-width: 0; }
.join-link-copy strong { font: 650 var(--text-base)/1.3 var(--ui); overflow-wrap: anywhere; }
.join-link-copy small { color: var(--muted); font: var(--text-xs)/1.3 var(--ui); }
.join-link-meter { display: block; width: 100%; height: 3px; margin-top: -.25rem; border-radius: var(--radius-pill); background: var(--panel-hi); overflow: hidden; }
.join-link-meter > span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: var(--brand); }
.join-link-fresh { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; min-width: 0; }
.join-link-share { min-width: 0; display: flex; align-items: center; gap: .5rem; padding: .3rem .3rem .3rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); }
.join-link-url { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); font: var(--text-sm)/1.3 var(--mono); }
.join-link-copy-button { display: inline-flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.join-link-copy-button .menu-icon svg { width: 1rem; height: 1rem; }
/* Phones: the icon alone, so the URL keeps the room; the button keeps its accessible name. */
@media (pointer: coarse), (max-width: 500px) {
  .join-link-copy-button { width: 2.75rem; min-height: 2.75rem; padding: 0; justify-content: center; }
  .join-link-copy-label { display: none; }
}
.join-link-full { font-family: var(--mono); }
.join-link-fresh .field-hint { margin: 0; }
.past-toggle { justify-self: start; padding: 0; color: var(--muted); }
.past-toggle:hover, .past-toggle:focus-visible { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .join-link-row { transition: none; } }
/* Invitation rows: icon and status sit beside the email; actions line up under the text. */
.invitations-page .invitation-main { align-items: flex-start; }
.invitations-page .invitation-main .room-mark { margin-top: -.05rem; background: transparent; }
.invitations-page .invitation-main .invitation-status { margin-top: .1rem; }
.invitations-page .invitation-actions { padding-left: calc(1.5rem + .6rem); }
.invitations-page .invitation-actions-row { align-items: center; gap: 1rem; }
@media (pointer: fine) { .invitations-page .invitation-actions-row .link-button { min-width: 0; min-height: 0; padding: 0; } }

/* Links view: a channel's saved links in the main area. Search on top, rows under day headings,
   filters in a column beside them. It takes .chat's place on screen and scrolls as one. */
/* It starts under the header on every shell, so the search field can stick to its own top edge. */
.links-view { top: var(--header-h); width: auto; font-family: var(--ui); padding-top: 0; padding-bottom: 4rem; }
.links-frame { display: grid; grid-template-columns: minmax(0, 46rem) 13.5rem; justify-content: center; align-items: start; gap: var(--space-6); }
.links-main { min-width: 0; }

/* The search field stays put while the list scrolls under it. */
/* The band is opaque, painted with the page's own background so it does not show as a patch,
   and a short fade under it lets a row leave cleanly. */
.links-search { position: sticky; z-index: var(--z-local); top: 0; display: grid; gap: var(--space-2); margin-inline: calc(-1 * var(--space-3)); padding: var(--space-4) var(--space-3) var(--space-2); background: var(--bg-glow) fixed, var(--bg); }
.links-search::after { content: ""; position: absolute; inset: 100% 0 auto; height: .9rem; background: linear-gradient(to bottom, var(--bg), transparent); pointer-events: none; }
.links-field { display: flex; align-items: center; gap: var(--space-2); min-height: 2.9rem; padding: 0 var(--space-2) 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--panel) 80%, transparent); transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease; }
.links-field:focus-within { border-color: color-mix(in srgb, var(--brand) 60%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); }
.links-field-icon { display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); }
.links-field-icon svg { width: 1.1rem; height: 1.1rem; }
.links-field input { flex: 1; min-width: 0; height: 2.75rem; border: 0; outline: none; background: transparent; color: var(--text); font: var(--text-base)/1.5 var(--mono); }
.links-field input::placeholder { color: var(--muted); opacity: .8; }
.links-filters-button { display: none; flex: 0 0 auto; align-items: center; gap: .35rem; min-height: 2.1rem; padding: 0 .7rem; border: 0; border-radius: var(--radius-md); background: var(--secondary-fill); color: var(--text); font: 600 var(--text-sm)/1 var(--ui); cursor: pointer; }
.links-filters-button.on { background: var(--active-fill); box-shadow: inset 0 0 0 1px var(--active-ring); }
.links-filters-count { min-width: 1.15rem; padding: .12rem .3rem; border-radius: var(--radius-pill); background: var(--brand-fill); color: var(--on-brand); font: 700 var(--text-2xs)/1.2 var(--mono); text-align: center; }
.links-action { display: flex; align-items: center; gap: var(--space-3); }
.links-add { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.25rem; padding: 0 .8rem; border: 0; border-radius: var(--radius-md); font: 700 var(--text-sm)/1 var(--ui); cursor: pointer; }
.links-add kbd { padding: .15rem .35rem; border-radius: var(--radius-xs); background: color-mix(in srgb, var(--on-brand) 12%, transparent); font: 600 var(--text-2xs)/1 var(--mono); }
.links-add[disabled] { opacity: var(--disabled-opacity); cursor: default; }
.links-known { display: flex; align-items: center; gap: var(--space-2); color: var(--muted); font: var(--text-sm)/1.4 var(--ui); }
.links-note { margin: 0; color: var(--muted); font: var(--text-sm)/1.4 var(--ui); }
.links-tokens { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.links-token { display: inline-flex; align-items: center; gap: .3rem; min-height: 1.75rem; padding: 0 .35rem 0 .6rem; border: 0; border-radius: var(--radius-sm); background: var(--active-fill); box-shadow: inset 0 0 0 1px var(--active-ring); color: var(--text); font: 600 var(--text-sm)/1 var(--ui); cursor: pointer; transition: background-color var(--dur-fast) ease; }
.links-token:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.links-token-x { display: grid; place-items: center; color: var(--muted); }
.links-token-x svg { width: .85rem; height: .85rem; }
.links-token:hover .links-token-x { color: var(--text); }
.links-clear { padding: .2rem .4rem; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); font: 600 var(--text-sm)/1.2 var(--ui); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .2em; }
.links-clear:hover { color: var(--text); text-decoration-color: currentColor; }
.links-count { margin: 0; color: var(--muted); font: var(--text-xs)/1.4 var(--mono); }

/* Rows, dense: icon, title and domain; one line of summary; topics and who shared it. */
.links-day + .links-day { margin-top: var(--space-4); }
/* Days off screen skip layout and paint but stay in find-in-page and the accessibility tree. The
   size is a guess until a day has been drawn once; after that the browser remembers it. The
   containment clips to the padding box, so the padding holds row hovers and focus rings, and a
   day being edited opts out so the topic list can overflow and the phone sheet stays fixed. */
.links-day { content-visibility: auto; contain-intrinsic-size: auto 520px; margin-inline: calc(-1 * var(--space-3)); padding: 0 var(--space-3) .25rem; }
.links-day:has(.link-row.editing) { content-visibility: visible; }
.links-day-heading { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); padding: var(--space-3) 0 var(--space-1); color: var(--muted); font: 700 var(--text-2xs)/1.2 var(--ui); letter-spacing: .09em; text-transform: uppercase; }
.links-list { display: grid; margin: 0; padding: 0; list-style: none; }
.link-row { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 0 var(--space-4); margin-inline: calc(-1 * var(--space-3)); padding: .55rem var(--space-3); border-radius: var(--radius-md); transition: background-color var(--dur-fast) ease; }
.link-row:hover, .link-row:focus-within { background: color-mix(in srgb, var(--panel) 75%, transparent); }
/* The preview sits at the left, 16:10, its space reserved so the list never jumps. */
.link-thumb { display: grid; place-items: center; width: 6rem; aspect-ratio: 16 / 10; margin-top: .2rem; overflow: hidden; border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 38%, transparent); }
.link-thumb-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.link-row.has-image .link-thumb { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 60%, transparent); }
.link-icon { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; overflow: hidden; border-radius: var(--radius-xs); opacity: .9; }
.link-icon.inline { display: inline-grid; width: .875rem; height: .875rem; margin-right: .3rem; vertical-align: -.12em; opacity: .85; }
.link-icon.inline img { width: .875rem; height: .875rem; }
/* Every row keeps the left slot, so titles line up. A row without an image shows the site's
   icon there on a quiet surface, and then the icon is not repeated beside the domain. */
.link-row.no-image .link-icon.inline { display: none; }
.links-day-new { padding: .1rem .35rem; border-radius: var(--radius-xs); background: var(--active-fill); box-shadow: inset 0 0 0 1px var(--active-ring); color: var(--brand); font: 700 var(--text-2xs)/1.2 var(--ui); letter-spacing: .04em; text-transform: none; }
.link-thumb .link-icon { position: relative; }
.link-icon-none { position: absolute; inset: 0; display: grid; place-items: center; color: color-mix(in srgb, var(--muted) 55%, transparent); }
.link-icon-none svg { width: 1rem; height: 1rem; }
.link-thumb .link-icon img { position: relative; background: var(--bg); }
.link-icon img { display: block; width: 1.25rem; height: 1.25rem; object-fit: contain; }
.link-body { display: grid; gap: .1rem; min-width: 0; }
.link-body h3 { margin: 0; font: 600 var(--text-base)/1.4 var(--ui); overflow-wrap: anywhere; }
.link-title { color: var(--text); text-decoration: underline; text-decoration-color: transparent; text-decoration-thickness: 1px; text-underline-offset: .2em; transition: text-decoration-color var(--dur-fast) ease; }
.link-title:hover, .link-title:focus-visible { text-decoration-color: var(--brand); }
.link-title:visited { color: color-mix(in srgb, var(--text) 68%, var(--muted)); }
.link-host { margin-left: var(--space-2); padding: 0; border: 0; background: none; color: var(--muted); font: 500 var(--text-xs)/1 var(--mono); white-space: nowrap; cursor: pointer; }
.link-host:hover { color: var(--mine); }
.link-post-text { margin: 0; color: var(--text); font: var(--text-sm)/1.5 var(--ui); display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link-row.post .link-title { font-weight: 600; }
.link-summary { display: -webkit-box; margin: 0; overflow: hidden; -webkit-line-clamp: 1; -webkit-box-orient: vertical; color: var(--muted); font: var(--text-sm)/1.5 var(--ui); }
.link-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .55rem; min-height: 1.4rem; color: var(--muted); font: var(--text-xs)/1.4 var(--ui); }
.link-topic { padding: 0; border: 0; background: none; color: var(--mine); font: 500 var(--text-xs)/1.4 var(--mono); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .2em; }
.link-topic:hover { text-decoration-color: currentColor; }
.link-topic.on { color: var(--brand); font-weight: 700; }
.link-filter { padding: 0; border: 0; background: none; color: color-mix(in srgb, var(--text) 78%, var(--muted)); font: 500 var(--text-xs)/1.4 var(--ui); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .2em; transition: text-decoration-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.link-filter:hover { color: var(--text); text-decoration-color: currentColor; }
.links-known .link-filter { font-size: var(--text-sm); color: var(--text); text-decoration-color: color-mix(in srgb, var(--brand) 60%, transparent); }
.link-filter.by { color: var(--muted); font-weight: 400; }
.link-filter.by:hover { color: var(--text); }
.link-by-name { font-weight: 500; }
.link-extra::before { content: "·"; margin-right: .55rem; color: color-mix(in srgb, var(--muted) 60%, transparent); }
.link-private { color: var(--brand); }
.link-remove { margin-left: auto; padding: 0 .4rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: 600 var(--text-xs)/1.4 var(--ui); cursor: pointer; opacity: 0; transition: opacity var(--dur-fast) ease, color var(--dur-fast) ease, background-color var(--dur-fast) ease; }
.link-row:hover .link-remove, .link-row:focus-within .link-remove { opacity: 1; }
.link-remove:hover, .link-remove:focus-visible { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
@media (hover: none) { .link-remove { opacity: 1; } }
.link-title:focus-visible, .link-host:focus-visible, .link-filter:focus-visible, .link-topic:focus-visible, .link-remove:focus-visible, .links-entry:focus-visible, .links-show-all:focus-visible, .links-token:focus-visible, .links-clear:focus-visible, .links-filters-button:focus-visible, .links-add:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-xs); }
.links-more { margin: var(--space-4) 0 0; color: var(--muted); font: var(--text-xs)/1.4 var(--ui); text-align: center; }
/* Past the rows scrolling loads, one button asks for the next stretch. */
.links-older { display: block; margin: var(--space-5) auto 0; }
.links-empty { display: grid; justify-items: center; gap: var(--space-2); margin: 14vh auto 0; text-align: center; }
.links-empty h2 { margin: 0; font: 700 var(--text-lg)/1.25 var(--ui); }
.links-empty p { max-width: 30rem; margin: 0; color: var(--muted); font: var(--text-sm)/1.5 var(--ui); }
.links-empty .btn-secondary { margin-top: var(--space-2); }
.links-remove-name { margin: 0 0 var(--space-2) !important; color: var(--text) !important; font: var(--text-sm)/1.45 var(--mono); overflow-wrap: anywhere; }

/* Filters: fixed groups in a fixed order. A chosen entry is marked where it stands. */
.links-filters { position: sticky; top: 0; display: grid; align-content: start; gap: var(--space-5); max-height: calc(100dvh - var(--header-h)); padding: calc(var(--space-4) + .35rem) 0 var(--space-6); overflow-y: auto; scrollbar-width: none; }
.links-filters::-webkit-scrollbar { display: none; }
.links-sheet-head, .links-sheet-backdrop { display: none; }
.links-group h3 { margin: 0 0 var(--space-1); padding-left: var(--space-2); color: var(--muted); font: 700 var(--text-2xs)/1.2 var(--ui); letter-spacing: .09em; text-transform: uppercase; }
.links-group ul { display: grid; margin: 0; padding: 0; list-style: none; }
.links-entry { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); width: 100%; padding: .22rem var(--space-2); border: 0; border-radius: var(--radius-sm); background: none; color: color-mix(in srgb, var(--text) 82%, var(--muted)); font: 500 var(--text-sm)/1.4 var(--ui); text-align: left; cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.links-entry:hover { background: color-mix(in srgb, var(--panel-hi) 55%, transparent); color: var(--text); }
.links-entry-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links-entry-count { flex: 0 0 auto; color: var(--muted); font: var(--text-xs)/1.4 var(--mono); }
.links-entry.on { background: var(--active-fill); box-shadow: inset 0 0 0 1px var(--active-ring); color: var(--text); font-weight: 650; }
.links-entry.on .links-entry-count { color: var(--brand); }
.links-show-all { margin: .15rem 0 0; padding: .2rem var(--space-2); border: 0; background: none; color: var(--muted); font: 500 var(--text-xs)/1.4 var(--ui); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .2em; }
.links-show-all:hover { color: var(--text); text-decoration-color: currentColor; }

/* Header: the Links and Messages switch. */
.view-switch { display: inline-flex; flex: 0 0 auto; padding: .15rem; border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 55%, transparent); }
.view-switch button { min-height: 1.85rem; padding: 0 .7rem; border: 0; border-radius: calc(var(--radius-md) - .1rem); background: transparent; color: var(--muted); font: 600 var(--text-sm)/1 var(--ui); cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.view-switch button:hover { color: var(--text); }
.view-switch button.on { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.view-switch button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Narrow: the column becomes a sheet opened from the Filters button in the field. */
@media (max-width: 60rem) {
  .links-frame { grid-template-columns: minmax(0, 46rem); }
  .links-filters-button { display: inline-flex; }
  .links-filters { position: fixed; z-index: calc(var(--z-overlay) + 1); inset: auto 0 0; max-height: min(78dvh, 40rem); padding: 0 var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-top: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-lg); gap: var(--space-4); translate: 0 105%; visibility: hidden; transition: translate var(--dur-entrance) var(--ease-standard), visibility 0s linear var(--dur-entrance); }
  .links-filters.open { translate: 0 0; visibility: visible; transition: translate var(--dur-entrance) var(--ease-standard), visibility 0s; }
  .links-sheet-head { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; gap: var(--space-3); margin-inline: calc(-1 * var(--space-4)); padding: var(--space-4) var(--space-4) var(--space-3); background: var(--panel); }
  .links-sheet-head h2 { margin: 0 auto 0 0; font: 700 var(--text-base)/1.2 var(--ui); }
  .links-sheet-close { min-height: 2.25rem; padding: 0 .9rem; border: 0; border-radius: var(--radius-md); font: 700 var(--text-sm)/1 var(--ui); cursor: pointer; }
  .links-sheet-backdrop { display: block; position: fixed; z-index: var(--z-overlay); inset: 0; border: 0; background: #09091066; backdrop-filter: var(--blur-light); -webkit-backdrop-filter: var(--blur-light); }
  .links-entry { padding-block: .5rem; font-size: var(--text-base); }
}
@media (max-width: 640px) {
  .links-view { padding-bottom: calc(var(--composer-bottom, 1rem) + 2rem); }
  .link-row { grid-template-columns: 4rem minmax(0, 1fr); gap: 0 var(--space-3); }
  .link-thumb { width: 4rem; border-radius: var(--radius-sm); }
  .link-icon { width: 1rem; height: 1rem; }
  .link-icon img { width: 1rem; height: 1rem; }
  .link-summary { -webkit-line-clamp: 2; }
  .link-host { display: block; margin: .1rem 0 0; }
  .view-switch button { padding: 0 .55rem; }
}
@media (prefers-reduced-motion: reduce) { .link-row, .link-title, .link-remove, .links-entry, .links-token, .links-filters, .view-switch button { transition: none; } }
/* The list is its own layer under the phone navigation, so the navigation steps aside for the sheet. */
body:has(.links-filters.open) .mobile-nav { translate: 0 150%; opacity: 0; pointer-events: none; }

/* Editing a row's topics: a "+" on the meta line opens a type-ahead in the row. On a phone it
   opens as a small sheet. Clicking a topic still filters; removing one is its own control.
   The "+" keeps its place and shows on hover and keyboard focus, always on a phone, and always
   on a row with no topics, so nothing shifts when it appears. */
.link-topic-item { display: inline-flex; align-items: center; gap: .1rem; }
.link-topic-x { display: grid; place-items: center; width: 1.1rem; height: 1.1rem; padding: 0; border: 0; border-radius: var(--radius-xs); background: none; color: var(--muted); cursor: pointer; }
.link-topic-x svg { width: .75rem; height: .75rem; }
.link-topic-x:hover, .link-topic-x:focus-visible { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.link-topic-add { display: inline-flex; align-items: center; gap: .25rem; min-height: 1.2rem; padding: 0 .25rem; border: 0; border-radius: var(--radius-xs); background: none; color: var(--muted); font: 500 var(--text-xs)/1.4 var(--ui); cursor: pointer; opacity: 0; transition: opacity var(--dur-fast) ease, color var(--dur-fast) ease, background-color var(--dur-fast) ease; }
.link-topic-plus { display: grid; place-items: center; }
.link-topic-plus svg { width: .8rem; height: .8rem; }
.link-topic-add.empty, .link-row:hover .link-topic-add, .link-row:focus-within .link-topic-add { opacity: 1; }
.link-topic-add:hover, .link-topic-add:focus-visible { background: color-mix(in srgb, var(--panel-hi) 70%, transparent); color: var(--text); }
@media (hover: none) { .link-topic-add { opacity: 1; } }
@media (pointer: coarse) { .link-topic-add, .link-remove { opacity: 1; } }
.link-row.editing { background: color-mix(in srgb, var(--panel) 75%, transparent); }
.link-row.editing .link-meta { position: relative; }
.topic-editor { position: relative; display: inline-flex; align-items: center; }
.topic-editor-title, .topic-editor-done, .topic-editor-current { display: none; }
.topic-editor input { width: 9.5rem; height: 1.5rem; padding: 0 .4rem; border: 1px solid color-mix(in srgb, var(--brand) 55%, var(--line)); border-radius: var(--radius-sm); outline: none; background: var(--bg); color: var(--text); font: var(--text-xs)/1 var(--mono); }
.topic-editor input::placeholder { color: var(--muted); }
.topic-options { position: absolute; z-index: var(--z-popover); top: calc(100% + .3rem); left: 0; width: 14rem; margin: 0; padding: .25rem; list-style: none; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg); background: var(--glass-tint); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); box-shadow: var(--shadow-md); }
.topic-option { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); padding: .3rem .5rem; border-radius: var(--radius-md); color: var(--text); font: 500 var(--text-sm)/1.3 var(--mono); cursor: pointer; }
.topic-option.active { background: color-mix(in srgb, var(--text) 10%, transparent); }
.topic-option-count { color: var(--muted); font: var(--text-xs)/1.3 var(--mono); }
.topic-option.create { margin-top: .25rem; padding-top: .45rem; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 0 0 var(--radius-md) var(--radius-md); color: var(--muted); font-family: var(--ui); }
.topic-option.create.active { color: var(--text); }
.topic-editor-error { position: absolute; top: calc(100% + .3rem); left: 0; width: 14rem; margin: 0; padding: .35rem .5rem; border-radius: var(--radius-md); background: var(--panel); color: var(--danger); font: var(--text-xs)/1.3 var(--ui); box-shadow: var(--shadow-sm); }
.topic-editor.sheet { position: fixed; z-index: calc(var(--z-overlay) + 1); inset: auto 0 var(--kb, 0px); display: grid; gap: var(--space-2); padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); border-radius: var(--radius-xl) var(--radius-xl) 0 0; background: var(--panel); box-shadow: var(--shadow-lg); grid-template-columns: minmax(0, 1fr) auto; }
.topic-editor.sheet .topic-editor-title { display: block; margin: 0; color: var(--muted); font: 700 var(--text-2xs)/1.2 var(--ui); letter-spacing: .09em; text-transform: uppercase; }
/* The sheet covers the row, so the row's topics show here with their remove controls. */
.topic-editor.sheet .topic-editor-title { grid-column: 1; align-self: center; }
.topic-editor.sheet .topic-editor-done { grid-column: 2; grid-row: 1; min-height: 2.1rem; }
.topic-editor.sheet .topic-editor-current { display: flex; flex-wrap: wrap; gap: .4rem; grid-column: 1 / -1; }
.topic-editor.sheet input { grid-column: 1 / -1; width: 100%; height: 2.6rem; padding: 0 .75rem; border-radius: var(--radius-md); font-size: var(--text-base); }
.topic-editor.sheet .topic-editor-done { display: inline-flex; align-items: center; min-height: 2.6rem; padding: 0 .9rem; border: 0; border-radius: var(--radius-md); background: var(--secondary-fill); color: var(--text); font: 600 var(--text-sm)/1 var(--ui); cursor: pointer; }
.topic-editor.sheet .topic-options { position: static; grid-column: 1 / -1; width: auto; max-height: 40dvh; overflow-y: auto; padding: 0; border: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.topic-editor.sheet .topic-option { padding: .6rem .5rem; font-size: var(--text-base); }
.topic-editor.sheet .topic-editor-error { position: static; grid-column: 1 / -1; width: auto; padding: 0; background: none; box-shadow: none; }
body:has(.topic-editor.sheet) .mobile-nav { translate: 0 150%; opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .link-topic-add { transition: none; } }

/* An X post is a quoted post: the handle and the words behind a thin rule. Its text starts at
   the same left edge as every other row's, and its slot holds a picture only when the post has
   one or its author's is known. */
.link-row.post.no-image .link-thumb { background: none; }
.link-row.avatar .link-thumb { background: none; box-shadow: none; }
.link-row.avatar .link-thumb-image { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-round); }
.link-post { display: grid; gap: .3rem; min-width: 0; }
.link-quote { margin: .1rem 0 .15rem; padding: 0 0 0 var(--space-3); border-left: 2px solid color-mix(in srgb, var(--line) 90%, var(--muted)); }
.link-quote-by { display: flex; align-items: baseline; gap: var(--space-2); margin: 0; font: var(--text-sm)/1.45 var(--ui); }
.link-handle { color: color-mix(in srgb, var(--text) 82%, var(--muted)); font-weight: 600; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .2em; transition: text-decoration-color var(--dur-fast) ease; }
.link-handle.main { color: var(--text); font-size: var(--text-base); }
.link-handle:hover, .link-handle:focus-visible { text-decoration-color: var(--brand); }
.link-handle.main:visited { color: color-mix(in srgb, var(--text) 68%, var(--muted)); }
.link-onx { color: var(--muted); font: 500 var(--text-xs)/1 var(--mono); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent); text-underline-offset: .2em; }
.link-onx:hover, .link-onx:focus-visible { color: var(--text); text-decoration-color: currentColor; }
.link-handle:focus-visible, .link-onx:focus-visible, .links-fold:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-xs); }
.link-quote-text { display: -webkit-box; margin: 0; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; color: color-mix(in srgb, var(--text) 88%, var(--muted)); font: var(--text-sm)/1.5 var(--ui); white-space: pre-line; overflow-wrap: anywhere; }

/* Orientation: where the member stopped reading, and busy days folded behind one control. */
.links-last-here { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-3); margin: .15rem 0 .5rem; color: var(--brand); font: 700 var(--text-2xs)/1.2 var(--ui); letter-spacing: .06em; text-transform: uppercase; }
.links-last-here::before, .links-last-here::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--brand) 45%, transparent); }
.links-day > .links-last-here { margin: var(--space-2) 0; }
.links-fold { display: block; margin: .1rem 0 0 calc(6rem + var(--space-4)); padding: .3rem .6rem; border: 0; border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 45%, transparent); color: color-mix(in srgb, var(--text) 82%, var(--muted)); font: 600 var(--text-sm)/1.3 var(--ui); cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.links-fold:hover { background: var(--secondary-fill); color: var(--text); }
@media (max-width: 640px) { .links-fold { margin-left: calc(4rem + var(--space-3)); } .link-row.avatar .link-thumb-image { width: 2rem; height: 2rem; } .link-quote-text { -webkit-line-clamp: 4; } }
@media (prefers-reduced-motion: reduce) { .links-fold, .link-handle { transition: none; } }

/* "Clear all" at the top of the filter column, in line with the first group's heading. On a
   phone the sheet's own head carries it. */
.links-clear-column { position: absolute; top: calc(var(--space-4) + .15rem); right: 0; padding: .1rem .4rem; font-size: var(--text-xs); color: var(--brand); }
.links-clear-column:hover { color: var(--text); }
@media (max-width: 60rem) { .links-clear-column { display: none; } }

/* A saved copy: a quiet second link on the row, and a plain reader view. The stored text is
   drawn as text, block by block; nothing from the page is rendered as markup. */
.link-copy { margin-left: var(--space-2); padding: 0; border: 0; background: none; color: var(--muted); font: 500 var(--text-xs)/1 var(--mono); cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--muted) 45%, transparent); text-underline-offset: .2em; white-space: nowrap; }
.link-quote-by .link-copy { margin-left: 0; }
.link-copy:hover, .link-copy:focus-visible { color: var(--text); text-decoration-color: currentColor; }
.link-copy:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-xs); }
.link-gone { margin-left: var(--space-2); color: var(--attention); font: 500 var(--text-xs)/1 var(--ui); white-space: nowrap; }
.link-quote-by .link-gone { margin-left: 0; }
.links-reader-card { width: min(44rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; overflow-y: auto; text-align: left; }
.links-reader-head { position: sticky; z-index: 1; top: 0; display: grid; gap: .3rem; padding: var(--space-5) var(--space-5) var(--space-3); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); background: var(--panel); }
.links-reader-kicker { margin: 0; color: var(--brand); font: 700 var(--text-2xs)/1.2 var(--ui); letter-spacing: .09em; text-transform: uppercase; }
.links-reader-head h2 { margin: 0; font: 700 var(--text-lg)/1.25 var(--ui); overflow-wrap: anywhere; }
.links-reader-meta { margin: 0; color: var(--muted); font: var(--text-xs)/1.4 var(--mono); overflow-wrap: anywhere; }
.links-reader-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.links-reader-actions .btn-secondary { display: inline-flex; align-items: center; min-height: 2.1rem; padding: 0 .8rem; text-decoration: none; }
.links-reader-card > .profile-error { margin: var(--space-4) var(--space-5); }
.links-reader-text { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-6); color: var(--text); font: var(--text-base)/1.65 var(--ui); }
.links-reader-text p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.links-reader-image { display: block; max-width: 100%; height: auto; border-radius: var(--radius-md); }
.links-reader-text .reader-h1 { margin-top: var(--space-2); font: 700 var(--text-lg)/1.3 var(--ui); }
.links-reader-text .reader-h2, .links-reader-text .reader-h3 { margin-top: var(--space-2); font: 700 var(--text-base)/1.35 var(--ui); }
.links-reader-text .reader-li { padding-left: 1.1rem; text-indent: -1.1rem; }
.links-reader-text .reader-li::before { content: "•"; display: inline-block; width: 1.1rem; text-indent: 0; color: var(--muted); }
@media (max-width: 640px) { .links-reader-head { padding: var(--space-4) var(--space-4) var(--space-3); } .links-reader-text { padding: var(--space-4) var(--space-4) var(--space-6); } .link-copy, .link-gone { display: inline-block; margin: .15rem var(--space-2) 0 0; } }
/* Notes: your own scratchpad rows carry no name, avatar or presence, only the text with its time on the right. */
.msg.note { grid-template-columns: 2rem minmax(0, 1fr) auto; grid-template-rows: auto; }
.msg.note .nick, .msg.note .message-avatar, .msg.note .mobile-time, .msg.note .message-add { display: none; }
.msg.note .body { grid-column: 2; grid-row: 1; }
.msg.note .time { display: block; grid-column: 3; grid-row: 1; align-self: baseline; justify-self: end; transform: none; font-size: var(--text-2xs); }
@media (max-width: 500px) { .msg.note { grid-template-columns: 1.25rem minmax(0, 1fr) auto; } }
@media (not (pointer: coarse)) and (min-width: 501px) {
  .msg.note { grid-template-columns: 4.25rem minmax(0, 1fr) auto; }
  .msg.note, .msg.note:not(.cont):not(.action) { margin-bottom: .35rem; padding-top: .25rem; }
  .message-entry:has(.msg.note) { margin-top: 0; }
  .msg.note .message-more { grid-row: 1; }
}

/* Poll cards (+slirc/poll=<id>). Like the agent offline card, a poll stands outside the message
   layout in the conversation intro's look. Options read as a ledger: a tick, the label, voters'
   faces, a tabular count, and a thin bar of the share of people who picked it. */
.poll-card { width: min(100%, 30rem); margin: .45rem 0 .7rem; font-family: var(--ui); }
.poll-card-body, .poll-card.is-loading { padding: .85rem .95rem .7rem; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--panel-hi) 50%, transparent); }
.poll-loading { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.poll-head { display: flex; align-items: center; gap: .55rem; }
.poll-mark { display: grid; place-items: center; flex: 0 0 auto; width: 1.75rem; height: 1.75rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.poll-mark svg, .poll-tick svg, .poll-winner svg, .poll-flag svg, .composer-plus-menu svg, .poll-option-handle svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.poll-byline { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; min-width: 0; margin: 0; }
.poll-eyebrow { color: var(--brand); font: 750 var(--text-xs)/1.3 var(--ui); letter-spacing: .06em; text-transform: uppercase; }
.poll-card.is-closed .poll-eyebrow, .poll-card.is-closed .poll-mark { color: var(--muted); }
.poll-card.is-closed .poll-mark { background: color-mix(in srgb, var(--muted) 16%, transparent); }
.poll-by { color: var(--muted); font-size: var(--text-xs); }
.poll-flag { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-size: var(--text-xs); }
.poll-flag svg { width: .8rem; height: .8rem; }
.poll-time { margin-left: auto; color: var(--muted); font: var(--text-xs)/1.3 var(--ui); font-variant-numeric: tabular-nums; }
.poll-menu-host { position: relative; flex: 0 0 auto; }
.poll-more { display: grid; place-items: center; width: 1.85rem; height: 1.85rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.poll-more:hover, .poll-more:focus-visible, .poll-more[aria-expanded="true"] { background: var(--panel-hi); color: var(--text); }
.poll-more:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.poll-menu, .composer-plus-menu { position: absolute; z-index: var(--z-sticky); min-width: 10.5rem; padding: .3rem; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg); background: var(--glass-tint); box-shadow: var(--shadow-md); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); animation: picker-in var(--dur-fast) var(--ease-standard); }
.poll-menu { top: calc(100% + .25rem); right: 0; }
.poll-menu button, .composer-plus-menu button { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .55rem .6rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: var(--text-sm)/1.2 var(--ui); text-align: left; cursor: pointer; }
.poll-menu button:hover, .poll-menu button:focus-visible, .composer-plus-menu button:hover, .composer-plus-menu button:focus-visible { background: var(--panel-hi); outline: none; }
.poll-menu button.danger { color: var(--danger); }
.poll-menu button.danger:hover, .poll-menu button.danger:focus-visible { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.poll-question { margin: .6rem 0 .15rem; color: var(--text); font: 750 var(--text-base)/1.35 var(--ui); letter-spacing: -.01em; overflow-wrap: anywhere; }
.poll-hint { margin: 0 0 .55rem; color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.poll-options { display: grid; gap: .15rem; }
.poll-option { display: flex; align-items: flex-start; gap: .65rem; width: 100%; padding: .5rem .45rem .55rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background-color var(--dur-fast) ease; }
.poll-option:hover { background: color-mix(in srgb, var(--panel-hi) 70%, transparent); }
.poll-option:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.poll-option.is-mine { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.poll-card.is-closed .poll-option { cursor: default; }
.poll-card.is-closed .poll-option:hover { background: transparent; }
.poll-card.is-closed .poll-option.is-mine { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.poll-tick { display: grid; place-items: center; flex: 0 0 auto; width: 1.15rem; height: 1.15rem; margin-top: .05rem; border: 2px solid color-mix(in srgb, var(--muted) 80%, transparent); color: transparent; transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.poll-tick.is-dot { border-radius: var(--radius-round); }
.poll-tick.is-box { border-radius: var(--radius-xs); }
.poll-tick svg { width: .75rem; height: .75rem; stroke-width: 3.25; }
.poll-option.is-mine .poll-tick { border-color: var(--brand-fill); background: var(--brand-fill); color: var(--on-brand); }
.poll-card.is-closed .poll-option:not(.is-mine) .poll-tick { opacity: .45; }
.poll-option-main { display: grid; gap: .35rem; flex: 1; min-width: 0; }
.poll-option-row { display: flex; align-items: center; gap: .45rem; min-height: 1.2rem; }
.poll-option-label { flex: 1; min-width: 0; font-size: var(--text-sm); line-height: 1.35; overflow-wrap: anywhere; }
.poll-option.is-winner .poll-option-label { font-weight: 700; }
.poll-winner { display: inline-grid; place-items: center; flex: 0 0 auto; color: var(--brand); }
.poll-winner svg { width: .9rem; height: .9rem; }
.poll-voters { display: inline-flex; flex: 0 0 auto; flex-direction: row-reverse; }
.poll-voters img { width: 1.125rem; height: 1.125rem; margin-left: -.3rem; border-radius: var(--radius-round); background: var(--avatar-fill); box-shadow: 0 0 0 2px var(--panel); }
.poll-voters img:last-child { margin-left: 0; }
.poll-count { flex: 0 0 auto; min-width: 1.25rem; color: var(--muted); font: 600 var(--text-xs)/1 var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.poll-option.is-mine .poll-count, .poll-option.is-winner .poll-count { color: var(--text); }
.poll-bar { display: block; height: .25rem; overflow: hidden; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--panel-hi) 90%, transparent); }
.poll-bar > span { display: block; height: 100%; border-radius: inherit; background: color-mix(in srgb, var(--muted) 70%, transparent); transition: width var(--dur-entrance) var(--ease-standard); }
.poll-option.is-mine .poll-bar > span, .poll-option.is-winner .poll-bar > span { background: var(--brand-fill); }
.poll-error { margin: .4rem .45rem 0; font-size: var(--text-xs); }
.poll-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .45rem; padding: .5rem .45rem 0; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.poll-total { color: var(--muted); font-size: var(--text-xs); }
.poll-view-votes { padding: .3rem .5rem; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--brand); font: 700 var(--text-sm)/1.2 var(--ui); cursor: pointer; }
.poll-view-votes:hover, .poll-view-votes:focus-visible { background: color-mix(in srgb, var(--brand) 12%, transparent); outline: none; }

/* The composer's + menu sits above the button. */
.composer-plus-menu { bottom: calc(100% + .4rem); left: .25rem; }

/* Create-poll dialog and the votes sheet: a centred card on desktop, a bottom sheet on phones. */
.poll-dialog-card { text-align: left; }
.poll-dialog-card.notice-card { width: min(28rem, calc(100vw - 2rem)); padding: 1.15rem 1.25rem 1.25rem; }
.poll-dialog-card.action-sheet { max-height: calc(100dvh - 2rem - var(--kb, 0px)); overflow-y: auto; padding-inline: 1rem; }
.poll-form { display: grid; gap: 1rem; }
.poll-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.poll-dialog-head h2 { margin: 0; font: 700 var(--text-lg)/1.3 var(--ui); }
.poll-field { display: grid; gap: .4rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.poll-field > span, .poll-field > legend { padding: 0; color: var(--muted); font: 600 var(--text-xs)/1.2 var(--ui); letter-spacing: .03em; }
.poll-field > legend { margin-bottom: .4rem; }
.poll-field input[type="text"] { width: 100%; min-height: 2.5rem; padding: 0 .7rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); color: var(--text); font: var(--text-sm)/1.2 var(--ui); }
.poll-field input[type="text"]:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.poll-option-list { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.poll-option-list .poll-draft-row { display: flex; align-items: center; gap: .25rem; border-radius: var(--radius-md); transition: background-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease; }
.poll-option-list .poll-draft-row.is-dragging { background: color-mix(in srgb, var(--panel-hi) 80%, transparent); box-shadow: var(--shadow-sm); }
.poll-option-handle, .poll-option-remove { display: grid; place-items: center; flex: 0 0 auto; width: 2rem; height: 2.5rem; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); }
.poll-option-handle { cursor: grab; touch-action: none; }
.poll-draft-row.is-dragging .poll-option-handle { cursor: grabbing; }
.poll-option-remove { cursor: pointer; }
.poll-option-handle:hover, .poll-option-handle:focus-visible, .poll-option-remove:hover, .poll-option-remove:focus-visible { background: var(--panel-hi); color: var(--text); outline: none; }
.poll-option-handle svg { stroke-width: 3; }
.poll-option-add { display: inline-flex; align-items: center; justify-self: start; gap: .4rem; margin-top: .15rem; padding: .45rem .6rem .45rem .5rem; border: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent); border-radius: var(--radius-md); background: transparent; color: var(--text); font: 600 var(--text-sm)/1.2 var(--ui); cursor: pointer; }
.poll-option-add:hover, .poll-option-add:focus-visible { border-color: var(--brand); color: var(--brand); outline: none; }
.poll-option-add .menu-icon svg { width: .95rem; height: .95rem; }
.poll-settings { display: grid; gap: .4rem; }
.poll-settings .settings-toggle { min-height: 3rem; }
.poll-settings .settings-toggle small::before { content: none; }
.poll-settings .settings-toggle > span:first-child { flex-direction: column; align-items: flex-start; gap: .1rem; }
.poll-segments { display: grid; grid-template-columns: repeat(4, 1fr); gap: .15rem; padding: .15rem; border-radius: var(--radius-md); background: color-mix(in srgb, var(--panel-hi) 55%, transparent); }
.poll-segment { position: relative; display: grid; place-items: center; min-height: 2.1rem; border-radius: calc(var(--radius-md) - .1rem); color: var(--muted); font: 600 var(--text-xs)/1 var(--ui); cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.poll-segment input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.poll-segment:hover { color: var(--text); }
.poll-segment:has(input:checked) { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }
.poll-segment:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }
.poll-actions { margin-top: .1rem; }
.poll-votes-card { display: grid; gap: .75rem; }
.poll-votes-body { display: grid; gap: .9rem; }
.poll-votes-question { margin: 0; color: var(--text); font: 700 var(--text-base)/1.35 var(--ui); overflow-wrap: anywhere; }
.poll-votes-body .poll-hint { margin: -.5rem 0 0; }
.poll-votes-option h3 { display: flex; align-items: center; gap: .4rem; margin: 0; padding-bottom: .35rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); font: 600 var(--text-sm)/1.3 var(--ui); }
.poll-votes-label { min-width: 0; overflow-wrap: anywhere; }
.poll-votes-count { margin-left: auto; color: var(--muted); font: 600 var(--text-xs)/1 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.poll-votes-option ul { display: grid; gap: .1rem; margin: .35rem 0 0; padding: 0; list-style: none; }
.poll-votes-option li { display: flex; align-items: center; gap: .55rem; min-height: 2.25rem; }
.poll-votes-option li img { width: 1.5rem; height: 1.5rem; border-radius: var(--radius-round); background: var(--avatar-fill); }
.poll-votes-name { flex: 1; min-width: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
.poll-votes-option time { color: var(--muted); font: var(--text-xs)/1 var(--ui); font-variant-numeric: tabular-nums; }
:root[data-theme="light"] .poll-voters img { box-shadow: 0 0 0 2px var(--bg); }
@media (max-width: 500px) {
  .poll-card-body { padding: .75rem .7rem .6rem; }
  .poll-option { padding-block: .6rem .65rem; }
}
@media (prefers-reduced-motion: reduce) { .poll-option, .poll-tick, .poll-bar > span, .poll-menu, .composer-plus-menu, .poll-segment, .poll-option-list .poll-draft-row { transition: none; animation: none; } }
.poll-draft-row .poll-option-input { flex: 1; min-width: 0; }
.poll-option-remove svg { width: .95rem; height: .95rem; }
.poll-dialog-card .pair-actions.poll-actions { justify-content: flex-end; }
/* On desktop the card starts where message avatars do, past the time gutter of .msg. On a phone it fills the column. */
@media (not (pointer: coarse)) and (min-width: 501px) { .poll-card { margin-left: calc(.35rem + 4.25rem + .6rem); } }
.poll-dialog-card .poll-votes-question { color: var(--text); }
/* Job cards: a bot's daily job digest, drawn on the poll card's frame. */
.job-card { width: min(100%, 36rem); }
.job-card .poll-by { overflow-wrap: anywhere; }
.job-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: .75rem 0 .35rem; }
.job-tabs button { padding: .3rem .65rem; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--muted); font: 650 var(--text-xs)/1 var(--ui); cursor: pointer; transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease; }
.job-tabs button:hover { color: var(--text); }
.job-tabs button.on { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.job-tabs button:focus-visible, .job-more:focus-visible, .job-row:focus-visible, .job-foot a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.job-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.job-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: .7rem; margin: 0 -.4rem; padding: .5rem .4rem; border-radius: var(--radius-md); color: inherit; text-decoration: none; transition: background-color var(--dur-fast) ease; }
.job-list li + li .job-row { box-shadow: 0 -1px 0 color-mix(in srgb, var(--line) 55%, transparent); }
.job-row:hover { background: color-mix(in srgb, var(--panel-hi) 55%, transparent); }
.job-logo { position: relative; display: grid; place-items: center; width: 2rem; height: 2rem; overflow: hidden; border-radius: var(--radius-sm); }
/* Logos are drawn for white; the letter tile under one shows when it fails to load. */
.job-logo img { position: absolute; inset: 0; width: 100%; height: 100%; background: #fff; object-fit: contain; }
.job-logo > span { display: grid; place-items: center; width: 100%; height: 100%; background: color-mix(in srgb, var(--brand) 22%, var(--panel-hi)); color: var(--text); font: 750 var(--text-sm)/1 var(--ui); }
.job-main { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.job-main strong { overflow: hidden; color: var(--text); font: 650 var(--text-sm)/1.25 var(--ui); text-overflow: ellipsis; white-space: nowrap; }
.job-main small { overflow: hidden; color: var(--muted); font: var(--text-xs)/1.2 var(--ui); text-overflow: ellipsis; white-space: nowrap; }
.job-pay { padding: .3rem .45rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--mine) 12%, transparent); color: var(--mine); font: 600 var(--text-xs)/1 var(--mono); white-space: nowrap; }
.job-pay.none { background: transparent; color: var(--muted); font-weight: 400; }
.job-more { margin: .35rem 0 0; padding: .35rem 0; border: 0; background: transparent; color: var(--brand); font: 650 var(--text-xs)/1 var(--ui); cursor: pointer; }
.job-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin-top: .55rem; padding-top: .6rem; border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); color: var(--muted); font: var(--text-xs)/1.3 var(--ui); }
.job-foot a { color: var(--mine); text-decoration: none; }
.job-foot > a { font-weight: 650; }
.job-foot a:hover { text-decoration: underline; }
@media (max-width: 500px) { .job-pay { padding-inline: .35rem; } }
@media (prefers-reduced-motion: reduce) { .job-tabs button, .job-row { transition: none; } }

