/* ==================================================================================================
   Messenger (chat) — owner: chat agent (C3). Scoped under .chat-app / .chat-tokens / .chat-* / .msg-*.

   Layout   ≥ 1024  three panes: list · conversation · info 360 (collapsible)
            768–1023 two panes: list + conversation; info is a sheet over the conversation
            < 768   stacked iOS navigation (list → conversation → info), edge-swipe back,
                    the tab bar hides inside a conversation and the composer takes its place.
   State    .chat-app[data-view="list|conversation|info"], [data-info-open], [data-has-conv],
            [data-wallpaper="calm|plain|doodles|dots|grid|waves|triangles|circles|topo"]
   Panes    overflow: clip (not hidden) — a hidden overflow is still programmatically scrollable,
            and scrollIntoView()/focus() used to shift the whole list sideways.
   Motion   transform/opacity only; decorative keyframes inside prefers-reduced-motion guards.
   ================================================================================================== */

/* -- Page frame ------------------------------------------------------------------------------------ */
.app__main:has(> .page.chat-page) {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  overflow: clip;
}
.page.chat-page {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  overflow: clip;
}
@media (max-width: 767px) {
  .app.has-tabbar .page.chat-page {
    padding: 0;
  }
  /* Inside a conversation the composer replaces the tab bar. */
  .app:has(.chat-app:not([data-view="list"])) .tabbar {
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }
  .app:has(.chat-app) .tabbar {
    transition:
      transform var(--dur-3) var(--ease-sheet),
      opacity var(--dur-2) ease;
  }
  /* The visible viewport (on-screen keyboard aware, see bindViewport in main.js). */
  .app__main:has(> .page.chat-page) {
    position: fixed;
    inset: 0;
    top: var(--chat-vv-top, 0px);
    height: var(--chat-vh, 100dvh);
  }
}

/* -- Tokens ---------------------------------------------------------------------------------------- */
.chat-app,
.chat-tokens {
  --chat-list-w: 320px;
  --chat-info-w: 360px;
  --chat-head-h: 64px; /* r4: Messages header — 32 px avatar centred over the name */
  --bubble-max: min(560px, 72%);
  --bubble-radius: 18px;
  --bubble-joint: 6px;
  --bubble-font: var(--fs-lg);
  /* r4 · 12.17 — iMessage: the outgoing bubble is one accent gradient over the whole viewport
     (background-attachment: fixed), lighter at the top, deeper at the bottom. Both stops sit a
     shade under the accent so white text stays ≥ 5.3:1, the 90 % white time ≥ 4.8:1 and the
     read ticks ≥ 4.5:1 on all 8 accents (light and dark; spec Appendix C). */
  --bubble-out-1: color-mix(in oklab, var(--accent) 92%, black);
  --bubble-out-2: color-mix(in oklab, var(--accent) 78%, black);
  --bubble-out: linear-gradient(180deg, var(--bubble-out-1), var(--bubble-out-2));
  --bubble-out-text: var(--text-on-accent);
  --bubble-out-meta: rgb(255 255 255 / 0.9);
  /* Incoming: iOS systemFill (--fill-2) laid over the wallpaper's base colour — opaque, so a
     patterned wallpaper never shows through (Messages' #e9e9eb / #262628). */
  --wall-solid: light-dark(var(--surface), var(--bg));
  --bubble-in: light-dark(
    color-mix(in srgb, var(--text) 9%, var(--wall-solid)),
    color-mix(in srgb, var(--text) 13%, var(--wall-solid))
  );
  --bubble-in-text: var(--text);
  --bubble-in-meta: var(--text-3-on-fill);
  --bubble-shadow: 0 0 0 transparent;
  /* Status ticks (WhatsApp): 🕓 sending → ✓ sent → ✓✓ delivered (muted) → ✓✓ read (coloured).
     On surfaces (list rows, menus, big-emoji pill): muted = --text-3, read = iOS blue / sky.
     On the accent bubble: muted = 70 % white, read = the global --tick-read token (app.css). */
  --tick: var(--text-3);
  --tick-read-surface: light-dark(
    color-mix(in oklab, var(--c-blue) 88%, var(--c-cyan)),
    color-mix(in oklab, var(--c-cyan) 75%, var(--c-blue))
  );
  --tick-out: rgb(255 255 255 / 0.7);
  --read-tick: var(--tick-read);
  /* Over a photo (the dark glass pill: ≥ 3:1 even over a white photo) and on the selected list row
     (solid accent; muted = 72 % white like the bubble). */
  --tick-scrim: color-mix(in srgb, var(--text-on-accent) 92%, transparent);
  --tick-read-scrim: var(--tick-read);
  --tick-row: rgb(255 255 255 / 0.72);
  --tick-read-row: var(--tick-read);
  /* Media inside bubbles: width cap and the tallest a single photo may get. */
  --media-w: 380px;
  --media-h: 420px;
  /* Wallpaper: Messages' plain canvas (white / black) with the faintest accent glow ("calm");
     patterns are an option in Chat settings. */
  --wall-base: var(--wall-solid);
  --wall-glow-1: light-dark(color-mix(in oklab, var(--accent) 4%, transparent), color-mix(in oklab, var(--accent) 7%, transparent));
  --wall-glow-2: transparent;
  --wall-ink: light-dark(
    color-mix(in oklab, var(--accent) 9%, rgb(0 0 0 / 0.035)),
    color-mix(in oklab, var(--accent) 12%, rgb(255 255 255 / 0.03))
  );
  /* Composer glyphs drawn with masks: (+) attach and Messages' ↑ send. */
  --chat-plus-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M8 2.5v11M2.5 8h11'/%3E%3C/svg%3E");
  --chat-arrow-up-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 15V3.5M4 8.5l5-5 5 5'/%3E%3C/svg%3E");
  --online: var(--c-green);
  --chat-row-active: var(--selection-bg);
  --chat-row-fg: var(--selection-fg);
}
.chat-app {
  position: relative;
  display: grid;
  flex: 1 1 0;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overflow: clip;
  background: var(--bg);
  color: var(--text);
  isolation: isolate;
}
@media (min-width: 768px) {
  .chat-app {
    grid-template-columns: var(--chat-list-w) minmax(0, 1fr);
  }
}
/* Three columns only when the conversation keeps ≥ ~500 px; narrower, info is a sheet. */
@media (min-width: 1280px) {
  .chat-app[data-info-open][data-has-conv] {
    grid-template-columns: var(--chat-list-w) minmax(0, 1fr) var(--chat-info-w);
  }
}
@media (min-width: 1280px) {
  .chat-app {
    --chat-list-w: 340px;
  }
}
@media (min-width: 1440px) {
  .chat-app {
    --chat-list-w: 360px;
  }
}
@media (max-width: 767px) {
  .chat-app,
  .chat-tokens {
    --chat-head-h: 62px;
    --bubble-max: 78%;
    --bubble-font: var(--type-body);
    --media-w: min(320px, 74vw);
    --media-h: 360px;
  }
}

/* -- Panes ------------------------------------------------------------------------------------------ */
.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overflow: clip;
}
.chat-list-pane {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  z-index: 2;
}
.chat-main {
  background: var(--wall-base);
  z-index: 3;
}
/* r4 · 12.17 / 10.7: the details are an inspector — a floating grouped panel (iOS "Contact info":
   grey ground, white groups) 8 px inside the window on desktop, a full page on phones. */
.chat-info-pane {
  display: none;
  background: var(--bg);
  z-index: 4;
}
@media (min-width: 1280px) {
  .chat-app[data-info-open][data-has-conv] .chat-info-pane {
    display: flex;
    margin: 8px 8px 8px 0;
    border-radius: var(--radius-panel);
    box-shadow:
      0 0 0 0.5px var(--card-ring),
      var(--shadow-lg);
  }
  .chat-app[data-info-open][data-has-conv] {
    background: var(--wall-solid);
  }
}

/* Phone: stacked navigation (iOS push / pop, the list parallaxes behind a dimming scrim). */
@media (max-width: 767px) {
  .chat-pane {
    grid-area: 1 / 1;
  }
  .chat-main,
  .chat-info-pane {
    transform: translate3d(100%, 0, 0);
    visibility: hidden;
    box-shadow: -12px 0 32px light-dark(rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.5));
  }
  .chat-info-pane {
    display: flex;
    border-left: 0;
  }
  .chat-app[data-view="conversation"] .chat-main,
  .chat-app[data-view="info"] .chat-main,
  .chat-app[data-view="info"] .chat-info-pane {
    transform: none;
    visibility: visible;
  }
  .chat-app[data-view="conversation"] .chat-list-pane,
  .chat-app[data-view="info"] .chat-list-pane {
    transform: translate3d(-28%, 0, 0);
  }
  .chat-app[data-view="info"] .chat-main {
    transform: translate3d(-28%, 0, 0);
  }
  /* r4 · 12.17: iOS push / pop on the smooth spring. */
  .chat-app.is-nav-anim .chat-pane {
    transition:
      transform var(--dur-4) var(--spring-smooth),
      visibility 0s linear 0s;
  }
  .chat-app.is-nav-anim .chat-list-pane::after,
  .chat-app.is-nav-anim .chat-main::after {
    transition: opacity var(--dur-4) var(--spring-smooth);
  }
  .chat-list-pane::after,
  .chat-main::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / 0.18);
    opacity: 0;
    pointer-events: none;
    z-index: 50;
  }
  .chat-app[data-view="conversation"] .chat-list-pane::after,
  .chat-app[data-view="info"] .chat-list-pane::after,
  .chat-app[data-view="info"] .chat-main::after {
    opacity: 1;
  }
  .chat-app.is-dragging .chat-pane {
    transition: none !important;
  }
}
/* Tablet / small laptop: info panel is a sheet over the conversation. */
@media (min-width: 768px) and (max-width: 1279px) {
  .chat-info-pane {
    position: absolute;
    inset: 8px 8px 8px auto;
    display: flex;
    width: min(var(--chat-info-w), 90%);
    border-radius: var(--radius-panel);
    box-shadow:
      0 0 0 0.5px var(--card-ring),
      var(--shadow-xl);
    transform: translate3d(105%, 0, 0);
    visibility: hidden;
    transition:
      transform var(--dur-3) var(--ease-sheet),
      visibility 0s linear var(--dur-3);
  }
  .chat-app[data-info-open][data-has-conv] .chat-info-pane {
    transform: none;
    visibility: visible;
    transition:
      transform var(--dur-3) var(--ease-sheet),
      visibility 0s;
  }
}

/* -- Conversation list: header ---------------------------------------------------------------------- */
.chat-list-head {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  padding: calc(10px + var(--safe-top)) 14px 10px max(14px, var(--safe-left));
  background: var(--bg-sidebar);
  transition:
    background-color var(--dur-2) ease,
    box-shadow var(--dur-2) ease;
}
/* r4 · 8.5 scroll edge: rows slide under a chrome-glass header once the list scrolls. */
.chat-list-pane.is-scrolled .chat-list-head {
  background: var(--mat-chrome);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
}
.chat-list-head__row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
}
.chat-list-head__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: var(--fs-title-2); /* r4 · 12.17: 22 px 700 (phones: 34 px large title) */
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform-origin: left center;
  transition: transform var(--dur-2) var(--ease-out);
}
@media (max-width: 767px) {
  .chat-list-head__title {
    font-size: var(--fs-large);
  }
  .chat-list-pane.is-scrolled .chat-list-head__title {
    transform: scale(0.62) translateY(4px);
  }
}
.chat-list-head .btn--icon {
  border-radius: 50%;
}
/* Light/dark switch (the chat has no app topbar). Phones keep the header calm: the Menu sheet
   has the Appearance control. */
@media (max-width: 767px) {
  .chat-list-head .chat-list-head__theme {
    display: none;
  }
}
.chat-list-head__menu {
  display: none;
}
@media (min-width: 768px) and (max-width: 1023px) {
  .chat-list-head__menu {
    display: inline-flex;
  }
}
/* macOS: quiet toolbar glyphs; iOS: nav-bar buttons take the accent tint. */
.chat-list-head .btn--icon {
  color: var(--text-2);
}
@media (max-width: 767px) {
  .chat-list-head .btn--icon {
    color: var(--accent-ink);
  }
}
.chat-new-btn {
  color: var(--accent-ink);
}

/* Search field (list, in-chat search, emoji picker, modals) */
.chat-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 8px;
}
/* r4 · 9.2: the shared .search-field look — a 36 px --fill-2 capsule. */
.chat-search > .icon {
  position: absolute;
  z-index: 1;
  left: 11px;
  color: var(--text-3-on-fill);
  pointer-events: none;
}
.chat-search__input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 33px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  color: var(--text);
  font: inherit;
  font-size: var(--type-body);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background-color var(--dur-1) ease,
    box-shadow var(--dur-2) ease;
}
.chat-search__input::placeholder {
  color: var(--text-3-on-fill);
}
.chat-search__input:hover {
  background: var(--fill-3);
}
.chat-search__input:focus {
  background: var(--fill-2);
  box-shadow: 0 0 0 3.5px var(--focus-ring);
}
.chat-search__input::-webkit-search-cancel-button {
  display: none;
}
.chat-search__clear {
  position: absolute;
  right: 7px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--fill-3);
  color: var(--surface);
  cursor: pointer;
}
.chat-search__clear[hidden] {
  display: none;
}
@media (pointer: coarse), (max-width: 767px) {
  .chat-search__input {
    height: 38px;
    font-size: max(16px, var(--type-body));
  }
}

/* Filters: a horizontally scrolling pill row that fades out at the edges (long ky/ru labels). */
.chat-filters {
  display: flex;
  gap: 6px;
  margin: 10px -14px 0;
  padding: 0 14px 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-padding-inline: 14px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, black var(--fade-l, 0px), black calc(100% - var(--fade-r, 0px)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, black var(--fade-l, 0px), black calc(100% - var(--fade-r, 0px)), transparent 100%);
}
.chat-filters.has-more-right {
  --fade-r: 44px;
}
.chat-filters.has-more-left {
  --fade-l: 44px;
}
.chat-filters::-webkit-scrollbar {
  display: none;
}
/* The pills themselves: core .filter-pill (+ __count) — static/css/core/toolbar.css. */

/* -- Conversation list: scroller & rows ------------------------------------------------------------- */
.chat-list-scroll {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  padding: 2px 8px calc(16px + var(--safe-bottom)) max(8px, var(--safe-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--fill-3) transparent;
}
@media (max-width: 767px) {
  .chat-list-scroll {
    padding-inline: 0;
    padding-bottom: calc(var(--tabbar-h) + max(var(--safe-bottom), 10px) + 28px);
  }
}
.chat-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.chat-list > li {
  position: relative;
}

/* Archived entry */
.chat-archived-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-weight: var(--fw-semibold);
  text-align: left;
  cursor: pointer;
}
.chat-archived-link:hover {
  background: var(--fill-1);
}
.chat-archived-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.chat-archived-link__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 40px;
  color: var(--text-3);
}
.chat-archived-link .badge {
  margin-left: auto;
}

/* Row — r4 · 12.17 (Messages): 48 px avatar, 15 px 600 name, a two-line 14 px preview, 12 px time;
   unread = a blue dot in the left gutter + a bolder name; the open chat = the macOS selection
   (--selection-bg / -fg: accent + white, grey when the window loses focus). The row stays opaque —
   swipe actions sit underneath it on phones. */
.conv {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 10px 10px 18px;
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  background: var(--bg-sidebar);
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-1) ease,
    transform var(--dur-2) var(--ease-out);
  touch-action: pan-y;
}
.conv .chat-avatar:not(.chat-avatar--sm, .chat-avatar--xs, .chat-avatar--lg) {
  --size: 48px;
}
@media (hover: hover) {
  .conv:hover {
    background: color-mix(in srgb, var(--bg-sidebar), var(--text) 4.5%);
  }
}
.conv:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus-outline);
}
.conv:active {
  transform: scale(0.985);
}
/* Unread: Messages' blue dot in the gutter (muted chats: grey). */
.conv.is-unread::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  width: 9px;
  height: 9px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
}
.conv.is-muted.is-unread::before {
  background: var(--text-3);
}
.conv.is-unread .conv__name {
  font-weight: var(--fw-bold);
}
.conv[aria-current="page"] {
  background: var(--chat-row-active);
  color: var(--chat-row-fg);
}
/* Solid colour on the selected row: any transparency drops below 4.5:1 on the dark accents. */
.conv[aria-current="page"] :is(.conv__time, .conv__preview, .conv__sender, .conv__icons .icon, .conv__draft, .conv__typing, .conv__kind) {
  color: var(--chat-row-fg) !important;
}
.conv[aria-current="page"].is-unread::before {
  background: var(--chat-row-fg);
}
.conv[aria-current="page"] .conv__badge {
  background: color-mix(in srgb, var(--chat-row-fg) 24%, transparent);
  color: var(--chat-row-fg);
}
.conv[aria-current="page"] .conv__badge--mention {
  background: var(--chat-row-fg);
  color: var(--chat-row-active);
}
.conv[aria-current="page"] .chat-avatar__dot {
  box-shadow: 0 0 0 2.5px var(--chat-row-active);
}
.conv[aria-current="page"] .chat-avatar__collage {
  --collage-ring: var(--chat-row-active);
}
@media (max-width: 767px) {
  .conv[aria-current="page"] {
    background: var(--bg-sidebar);
    color: inherit;
  }
  .conv[aria-current="page"] :is(.conv__time, .conv__preview, .conv__icons .icon, .conv__kind) {
    color: var(--text-2) !important;
  }
  .conv[aria-current="page"] .conv__sender {
    color: var(--text) !important;
  }
  .conv[aria-current="page"].is-unread::before {
    background: var(--accent);
  }
  .conv[aria-current="page"] .conv__badge {
    background: var(--fill-2);
    color: var(--text-2);
  }
  .conv[aria-current="page"] .conv__badge--mention {
    background: var(--accent);
    color: var(--text-on-accent);
  }
  .conv[aria-current="page"] .chat-avatar__dot {
    box-shadow: 0 0 0 2.5px var(--bg-sidebar);
  }
  .conv[aria-current="page"] .chat-avatar__collage {
    --collage-ring: var(--bg-sidebar);
  }
}
.conv__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 1px;
  min-width: 0;
}
.conv__title {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
}
.conv__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv__kind {
  flex-shrink: 0;
  color: var(--text-3);
}
.conv__time {
  align-self: center;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.conv__preview {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: 1.33;
  overflow-wrap: anywhere;
}
.conv__preview .icon {
  vertical-align: -2px;
  margin-right: 3px;
}
.conv__sender {
  color: var(--text);
  font-weight: var(--fw-medium);
}
.conv__draft {
  color: var(--danger-ink);
  font-weight: var(--fw-medium);
}
.conv__typing {
  color: var(--accent-ink);
}
/* Phones (iOS Messages): edge-to-edge rows, 17 px names, hairlines inset to the text. */
@media (max-width: 767px) {
  .conv {
    min-height: 76px;
    padding: 10px 16px 10px 22px;
    border-radius: 0;
  }
  .conv.is-unread::before {
    left: 7px;
  }
  .conv__title {
    font-size: var(--type-headline);
  }
  .conv__preview {
    font-size: var(--type-subhead);
  }
  .conv__time {
    font-size: var(--type-subhead);
  }
  .chat-list > li[data-conv] + li[data-conv] > .conv::after,
  .chat-list > li[data-static] + li[data-static] > .conv::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: calc(22px + 48px + 12px);
    height: 0.5px;
    background: var(--line);
    pointer-events: none;
  }
}
/* My last message: its status ticks lead the preview (WhatsApp); colours: "Status ticks" below. */
.conv__ticks {
  vertical-align: -1px;
  margin-right: 4px;
}
@media (min-width: 768px) {
  .conv[aria-current="page"] .conv__ticks {
    --_tick: var(--tick-row);
    --_tick-read: var(--tick-read-row);
  }
  /* Window in the background: the selection turns grey (--selection-muted), so do the ticks. */
  :root.is-window-inactive .conv[aria-current="page"] .conv__ticks {
    --_tick: var(--tick);
    --_tick-read: var(--tick-read-surface);
  }
}
.conv__icons {
  display: flex;
  align-self: start;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-height: 20px;
  padding-top: 2px;
}
.conv__icons .icon {
  color: var(--text-3);
}
/* The blue dot is the unread signal; the count is a quiet grey capsule beside it (iOS Mail),
   mentions stay accent. */
.conv__badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
/* "Marked as unread": the gutter dot says it — the badge stays for screen readers only. */
.conv__badge:not(.conv__badge--mention):has(> .sr-only:only-child) {
  position: absolute;
  width: 1px;
  min-width: 0;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.conv.is-muted .conv__badge {
  background: var(--fill-2);
  color: var(--text-3);
}
.conv__badge--mention,
.conv.is-muted .conv__badge--mention {
  width: 20px;
  padding: 0;
  background: var(--accent);
  color: var(--text-on-accent);
}

@media (prefers-reduced-motion: no-preference) {
  .conv__badge.is-bump {
    animation: chat-pop 420ms var(--ease-spring);
  }
}

/* Pinned chats (desktop, r4 · 12.17): Messages' grid of 56 px avatars above the list. Phones keep
   them as the first rows (swipe actions need a full-width row); searching shows plain rows. */
@media (hover: hover) and (pointer: fine) {
  .chat-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    column-gap: 2px;
  }
  .chat-list > li {
    grid-column: 1 / -1;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] {
    grid-column: auto;
    min-width: 0;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] > .conv {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    align-content: start;
    gap: 6px;
    min-height: 0;
    padding: 10px 4px 8px;
    text-align: center;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] > .conv .chat-avatar:not(.chat-avatar--sm, .chat-avatar--xs, .chat-avatar--lg) {
    --size: 56px;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] .conv__body {
    display: block;
    width: 100%;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] :is(.conv__time, .conv__preview, [data-pin-icon]) {
    display: none;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] .conv__title {
    justify-content: center;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    line-height: 1.25;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] .conv__icons {
    position: absolute;
    top: 6px;
    left: calc(50% + 14px);
    padding: 0;
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] .conv__badge {
    background: var(--accent);
    color: var(--text-on-accent);
    box-shadow: 0 0 0 2px var(--bg-sidebar);
  }
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] .conv.is-unread::before {
    top: 12px;
    left: calc(50% - 31px);
    margin-top: 0;
    box-shadow: 0 0 0 2px var(--bg-sidebar);
  }
  /* The last pinned tile closes the grid with a hairline before the ordinary rows. */
  .chat-list-scroll:not(:has(> .chat-results:not([hidden]))) .chat-list > li[data-pinned] + li:not([data-pinned])::before {
    content: "";
    display: block;
    height: 0.5px;
    margin: 4px 10px 6px;
    background: var(--line);
  }
}

/* Swipe actions (phones) */
.conv-swipe {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  overflow: hidden;
  border-radius: var(--radius-lg);
  pointer-events: none;
}
.conv-swipe__side {
  display: flex;
}
.conv-swipe__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 76px;
  border: 0;
  color: var(--text-on-accent);
  font: inherit;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  pointer-events: auto;
}
.conv-swipe__btn span {
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-swipe__btn[data-tone="blue"] { background: var(--c-blue); }
.conv-swipe__btn[data-tone="orange"] { background: var(--c-orange); }
.conv-swipe__btn[data-tone="gray"] { background: var(--c-gray); }
.conv-swipe__btn[data-tone="indigo"] { background: var(--c-indigo); }
li.is-swiping .conv,
li.is-swiped .conv {
  border-radius: 0;
  transition: none;
}
li.is-swiped .conv {
  transition: transform var(--dur-3) var(--ease-sheet);
}

/* FLIP reorder + new rows */
.chat-list > li.is-flipping {
  z-index: 2;
  transition: transform 420ms var(--ease-sheet);
}
@media (prefers-reduced-motion: no-preference) {
  .chat-list > li.is-new {
    animation: chat-row-in 360ms var(--ease-out);
  }
}

.chat-list-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 20px;
  color: var(--text-2);
  text-align: center;
}
.chat-list-empty .icon {
  color: var(--text-3);
}
.chat-list-empty strong {
  color: var(--text);
}

/* Searching: when messages match, "no chats match" is noise — the message hits answer it. */
.chat-list-scroll:has(.chat-results:not([hidden]) .chat-result) .chat-list-empty--search {
  display: none;
}
.chat-list-section {
  margin: 14px 10px 4px;
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* Skeleton rows while a filter / search reloads the list. */
.chat-list.is-loading > li[data-conv] {
  opacity: 0.55;
  transition: opacity var(--dur-2) ease;
}

/* -- Avatars (person, group collage, channel tile) -------------------------------------------------- */
.chat-avatar {
  --size: 52px;
  --chat-av: var(--size);
  position: relative;
  display: inline-grid;
  flex-shrink: 0;
  width: var(--size);
  height: var(--size);
}
.chat-avatar > .avatar {
  --size: inherit;
  width: 100%;
  height: 100%;
  font-size: calc(var(--chat-av) * 0.36);
}
.chat-avatar--sm {
  --size: 38px;
}
.chat-avatar--xs {
  --size: 28px;
}
.chat-avatar--lg {
  --size: 88px;
}
.chat-avatar__tile {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(160deg, color-mix(in oklab, var(--tone-solid) 82%, white), var(--tone-solid));
  color: var(--tone-on, var(--text-on-accent));
}
.chat-avatar--rounded .chat-avatar__tile {
  border-radius: 30%;
}
.chat-avatar__collage {
  position: relative;
  width: 100%;
  height: 100%;
}
.chat-avatar__collage > .avatar {
  position: absolute;
  width: 66%;
  height: 66%;
  /* readable initials: size from the outer avatar, not the inner "sm" avatar */
  font-size: calc(var(--chat-av) * 0.25);
  font-weight: var(--fw-semibold);
  box-shadow: 0 0 0 2px var(--collage-ring, var(--bg-sidebar));
}
.conv-head .chat-avatar__collage,
.info .chat-avatar__collage,
.pick-item .chat-avatar__collage,
.palette .chat-avatar__collage {
  --collage-ring: var(--surface);
}
.chat-avatar__collage > .avatar:nth-child(1) {
  top: 0;
  left: 0;
}
.chat-avatar__collage > .avatar:nth-child(2) {
  right: 0;
  bottom: 0;
  z-index: 1;
}
.chat-avatar__collage > .avatar:nth-child(3) {
  display: none;
}
.chat-avatar__collage[data-count="3"] > .avatar:nth-child(1) {
  top: 2%;
  left: 0;
  width: 54%;
  height: 54%;
}
.chat-avatar__collage[data-count="3"] > .avatar:nth-child(2) {
  right: 0;
  bottom: 0;
  width: 54%;
  height: 54%;
}
.chat-avatar__collage[data-count="3"] > .avatar:nth-child(3) {
  display: grid;
  top: 0;
  right: 4%;
  width: 42%;
  height: 42%;
}
.chat-avatar--xs .chat-avatar__collage > .avatar,
.chat-avatar--sm .chat-avatar__collage > .avatar {
  box-shadow: 0 0 0 1.5px var(--collage-ring, var(--bg-sidebar));
}
.chat-avatar__dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: calc(var(--chat-av) * 0.26);
  height: calc(var(--chat-av) * 0.26);
  min-width: 10px;
  min-height: 10px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 2.5px var(--bg-sidebar);
  transform: scale(0);
  transition: transform var(--dur-3) var(--ease-spring);
}
.chat-avatar.is-online .chat-avatar__dot {
  transform: scale(1);
}
.conv-head .chat-avatar__dot,
.info .chat-avatar__dot,
.pick-item .chat-avatar__dot {
  box-shadow: 0 0 0 2px var(--surface);
}

/* -- Main pane without a conversation --------------------------------------------------------------- */
.chat-empty {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}
.chat-empty__card {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 28px 28px 24px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-2xl);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.chat-empty__art {
  position: relative;
  width: 112px;
  height: 84px;
  margin-bottom: 6px;
}
.chat-empty__bubble {
  position: absolute;
  height: 34px;
  border-radius: 17px;
  box-shadow: var(--shadow-sm);
}
.chat-empty__bubble:nth-child(1) {
  top: 0;
  left: 0;
  width: 78px;
  background: var(--bubble-in);
  border-bottom-left-radius: 6px;
}
.chat-empty__bubble:nth-child(2) {
  right: 0;
  bottom: 18px;
  width: 64px;
  background: var(--bubble-out);
  border-bottom-right-radius: 6px;
}
.chat-empty__bubble:nth-child(3) {
  bottom: 0;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 22px;
  background: var(--bubble-in);
}
.chat-empty__bubble:nth-child(3) i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-3);
}
@media (prefers-reduced-motion: no-preference) {
  .chat-empty__bubble:nth-child(1) { animation: chat-float 5s var(--ease-in-out) infinite; }
  .chat-empty__bubble:nth-child(2) { animation: chat-float 5s var(--ease-in-out) -1.6s infinite; }
  .chat-empty__bubble:nth-child(3) i { animation: chat-typing 1.2s var(--ease-in-out) infinite; }
  .chat-empty__bubble:nth-child(3) i:nth-child(2) { animation-delay: 0.15s; }
  .chat-empty__bubble:nth-child(3) i:nth-child(3) { animation-delay: 0.3s; }
}
.chat-empty__title {
  margin: 0;
  font-size: var(--fs-title-3);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}
.chat-empty__text {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: 1.45;
  text-wrap: pretty;
}
.chat-empty__hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
@media (pointer: coarse) {
  .chat-empty__hint {
    display: none;
  }
}
/* Error pane (a chat that didn't load / no longer exists) */
.conv-error__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: var(--fill-1);
  color: var(--text-2);
}
.conv-head--bare {
  border-bottom: 0 !important;
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
@media (min-width: 768px) {
  .conv-head--bare {
    display: none !important;
  }
}

/* -- Wallpaper: calm by default (soft, theme-aware light), patterns optional ----------------------- */
.chat-wall {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(70% 55% at 12% 0%, var(--wall-glow-1), transparent 72%),
    radial-gradient(60% 50% at 95% 100%, var(--wall-glow-2), transparent 72%),
    var(--wall-base);
  pointer-events: none;
}
.chat-wall::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--wall-ink);
  -webkit-mask-image: var(--wall-pattern);
  mask-image: var(--wall-pattern);
  -webkit-mask-size: var(--wall-size, 240px);
  mask-size: var(--wall-size, 240px);
}
:is(.chat-app, .chat-tokens, .wall-swatch),
:is(.chat-app, .wall-swatch)[data-wallpaper="calm"],
:is(.chat-app, .wall-swatch)[data-wallpaper="plain"] {
  --wall-pattern: none;
}
:is(.chat-app, .wall-swatch)[data-wallpaper="calm"] .chat-wall::before,
:is(.chat-app, .wall-swatch)[data-wallpaper="plain"] .chat-wall::before,
.chat-app:not([data-wallpaper]) .chat-wall::before,
.wall-swatch:is([data-wallpaper="calm"], [data-wallpaper="plain"])::before {
  display: none;
}
/* "Plain": one flat color, no glow. */
.chat-app[data-wallpaper="plain"] .chat-wall,
.wall-swatch[data-wallpaper="plain"] {
  background: var(--wall-solid);
}
:is(.chat-app, .wall-swatch)[data-wallpaper="doodles"] {
  --wall-size: 260px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 30h34a8 8 0 0 1 8 8v16a8 8 0 0 1-8 8H34l-10 8v-8h-4a8 8 0 0 1-8-8V38a8 8 0 0 1 8-8z'/%3E%3Ccircle cx='170' cy='40' r='12'/%3E%3Cpath d='M164 40l4 4 8-8'/%3E%3Cpath d='M110 110l6 12 13 2-9 9 2 13-12-6-12 6 2-13-9-9 13-2z'/%3E%3Cpath d='M210 120c0-7 9-10 13-4 4-6 13-3 13 4 0 9-13 16-13 16s-13-7-13-16z'/%3E%3Crect x='30' y='150' width='34' height='26' rx='5'/%3E%3Cpath d='M30 158l17 10 17-10'/%3E%3Cpath d='M150 200l18-10 18 10v18l-18 10-18-10z'/%3E%3Cpath d='M86 210c6-10 16-10 22 0s16 10 22 0'/%3E%3Ccircle cx='230' cy='220' r='3'/%3E%3Ccircle cx='96' cy='40' r='3'/%3E%3Ccircle cx='60' cy='110' r='2.5'/%3E%3Cpath d='M220 60v14M213 67h14'/%3E%3Cpath d='M40 236l8-8 8 8'/%3E%3Cpath d='M128 18l4 8M240 170l-8 4'/%3E%3C/svg%3E");
}
:is(.chat-app, .wall-swatch)[data-wallpaper="dots"] {
  --wall-size: 22px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='11' cy='11' r='1.4'/%3E%3C/svg%3E");
}
:is(.chat-app, .wall-swatch)[data-wallpaper="grid"] {
  --wall-size: 32px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='none' stroke='black'%3E%3Cpath d='M32 .5H.5V32' stroke-width='1'/%3E%3C/svg%3E");
}
:is(.chat-app, .wall-swatch)[data-wallpaper="waves"] {
  --wall-size: 120px 40px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40' fill='none' stroke='black' stroke-width='1.5'%3E%3Cpath d='M0 20c15-14 45-14 60 0s45 14 60 0'/%3E%3C/svg%3E");
}
:is(.chat-app, .wall-swatch)[data-wallpaper="triangles"] {
  --wall-size: 60px 52px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='52' fill='none' stroke='black' stroke-width='1.2' stroke-linejoin='round'%3E%3Cpath d='M30 6l20 34H10z'/%3E%3C/svg%3E");
}
:is(.chat-app, .wall-swatch)[data-wallpaper="circles"] {
  --wall-size: 90px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90' fill='none' stroke='black' stroke-width='1.2'%3E%3Ccircle cx='45' cy='45' r='18'/%3E%3Ccircle cx='0' cy='0' r='18'/%3E%3Ccircle cx='90' cy='0' r='18'/%3E%3Ccircle cx='0' cy='90' r='18'/%3E%3Ccircle cx='90' cy='90' r='18'/%3E%3C/svg%3E");
}
:is(.chat-app, .wall-swatch)[data-wallpaper="topo"] {
  --wall-size: 200px;
  --wall-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' fill='none' stroke='black' stroke-width='1.2'%3E%3Cpath d='M0 40c40-20 60 20 100 0s60-20 100 0M0 90c30-25 70 15 100-5s70-25 100 5M0 140c40-10 60 25 100 5s60-20 100-5M0 185c35-15 65 10 100 0s65-15 100 0'/%3E%3C/svg%3E");
}

/* -- Conversation pane: header ---------------------------------------------------------------------- */
.conv-pane {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
}
.conv-pane > :not(.chat-wall) {
  position: relative;
  z-index: 1;
}
/* r4 · 12.17 — Messages: a chrome-glass bar, the 32 px avatar centred over a 12 px name (tap →
   details); ‹ back on phones, round glass buttons on the right. Three columns keep the identity
   centred whatever sits on either side. */
.conv-head {
  position: absolute !important;
  top: 0;
  right: 0;
  left: 0;
  z-index: 6 !important;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, max-content) minmax(max-content, 1fr);
  align-items: center;
  column-gap: 8px;
  height: calc(var(--chat-head-h) + var(--safe-top));
  padding: var(--safe-top) 10px 0 max(10px, var(--safe-left));
  background: var(--mat-chrome);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
}
.conv-head > .conv-head__back {
  grid-column: 1;
  justify-self: start;
}
.conv-head > .conv-head__ident {
  grid-column: 2;
}
.conv-head > .conv-head__actions {
  grid-column: 3;
  justify-self: end;
}
.conv-head__back {
  display: none;
  color: var(--accent-ink);
}
.conv-head__back-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}
.conv-head__back-badge:empty {
  display: none;
}
@media (max-width: 767px) {
  .conv-head__back {
    display: inline-flex;
    width: auto;
    min-width: 40px;
    gap: 2px;
    padding: 0 6px 0 2px;
  }
}
.conv-head__ident {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  padding: 4px 8px 3px;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.conv-pane.is-shell .conv-head__ident {
  cursor: default;
}
.conv-head__ident:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: -2px;
}
.conv-head__ident:active .chat-avatar {
  transform: scale(0.94);
}
.conv-head__ident .chat-avatar {
  --size: 32px;
  view-transition-name: chat-avatar;
  transition: transform var(--dur-2) var(--spring-snappy);
}
.conv-head__ident .chat-avatar > .avatar,
.conv-head__ident .chat-avatar__tile {
  font-size: 12px;
}
.conv-head__ident .chat-avatar__tile .icon {
  width: 16px;
  height: 16px;
}
.conv-head__text {
  display: grid;
  justify-items: center;
  min-width: 0;
  max-width: 100%;
}
.conv-head__title {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 15px;
}
/* "Name ›" — the chevron says the name opens the details (Messages). */
.conv-head__title::after {
  content: "";
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  margin-left: 1px;
  background: var(--text-3);
  -webkit-mask: var(--chevron-mask) center / contain no-repeat;
  mask: var(--chevron-mask) center / contain no-repeat;
}
.conv-pane.is-shell .conv-head__title::after {
  visibility: hidden;
}
.conv-head__title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-head__title .conv__kind {
  width: 11px;
  height: 11px;
}
.conv-head__status {
  position: relative;
  max-width: 100%;
  height: 13px;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-2xs);
  line-height: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.conv-head__status:empty {
  display: none;
}
.conv-head__status .skeleton {
  display: inline-block;
  width: 72px;
  height: 8px;
  vertical-align: 1px;
}
.conv-head__status.is-online,
.conv-head__status.is-typing {
  color: var(--accent-ink);
}
@media (prefers-reduced-motion: no-preference) {
  .conv-head__status.is-changing {
    animation: chat-status-in var(--dur-3) var(--ease-out);
  }
}
.conv-head__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Round glass buttons (iOS 26 toolbar items). */
.conv-head__actions .btn--icon {
  width: 34px;
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--mat-regular);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-xs);
  color: var(--text);
}
.conv-head__actions .btn--icon:hover {
  background: var(--mat-thick);
  color: var(--text);
}
.conv-head__actions .btn--icon[aria-pressed="true"] {
  background: var(--accent);
  box-shadow: none;
  color: var(--text-on-accent);
}
@media (pointer: coarse) {
  .conv-head__actions .btn--icon {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }
}

/* Typing dots (header, list preview, typing bubble) */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 4px;
  vertical-align: 1px;
}
.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
@media (prefers-reduced-motion: no-preference) {
  .typing-dots i {
    animation: chat-typing 1.2s var(--ease-in-out) infinite;
  }
  .typing-dots i:nth-child(2) {
    animation-delay: 0.15s;
  }
  .typing-dots i:nth-child(3) {
    animation-delay: 0.3s;
  }
}

/* Pinned bar */
.conv-pinned {
  position: absolute !important;
  top: calc(var(--chat-head-h) + var(--safe-top));
  right: 0;
  left: 0;
  z-index: 5 !important;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 8px 0 max(14px, var(--safe-left));
  background: var(--mat-chrome);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
  transition:
    transform var(--dur-3) var(--ease-sheet),
    opacity var(--dur-2) ease;
}
.conv-pinned[hidden] {
  display: flex !important;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.conv-pinned__bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: stretch;
  justify-content: center;
  width: 3px;
  padding: 8px 0;
}
.conv-pinned__bars i {
  flex: 1;
  border-radius: 2px;
  background: var(--accent-soft);
  transition: background-color var(--dur-2) ease;
}
.conv-pinned__bars i.is-active {
  background: var(--accent);
}
.conv-pinned__main {
  display: grid;
  flex: 1;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.conv-pinned__main:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.conv-pinned__label {
  color: var(--accent-ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}
.conv-pinned__text {
  overflow: hidden;
  color: var(--text);
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (prefers-reduced-motion: no-preference) {
  .conv-pinned__text.is-changing {
    animation: chat-pin-roll var(--dur-3) var(--ease-out);
  }
}

/* In-chat search bar */
.conv-search {
  position: absolute !important;
  top: 0;
  right: 0;
  left: 0;
  z-index: 7 !important;
  display: flex;
  align-items: center;
  gap: 6px;
  height: calc(var(--chat-head-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0 max(12px, var(--safe-left));
  background: var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
  transition:
    transform var(--dur-3) var(--ease-sheet),
    opacity var(--dur-2) ease;
}
.conv-search[hidden] {
  display: flex !important;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.conv-search .chat-search {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.conv-search__count {
  min-width: 48px;
  color: var(--text-2);
  font-size: var(--fs-xs);
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.conv-search .btn--icon {
  border-radius: 50%;
}
@media (max-width: 479px) {
  .conv-search__count:empty {
    display: none;
  }
}

/* -- Timeline --------------------------------------------------------------------------------------- */
.timeline {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent;
  -webkit-overflow-scrolling: touch;
  contain: strict;
  outline: none;
}
.timeline:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}
.timeline__inner {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100%;
  padding: calc(var(--chat-head-h) + var(--safe-top) + 10px) max(10px, var(--safe-right)) calc(var(--composer-h, 64px) + 10px) max(10px, var(--safe-left));
}
.conv-pane.has-pinned .timeline__inner {
  padding-top: calc(var(--chat-head-h) + var(--safe-top) + 58px);
}
@media (min-width: 768px) {
  .timeline__inner {
    padding-inline: clamp(14px, 3.5%, 56px);
  }
}
.timeline__edge {
  display: grid;
  place-items: center;
  height: 44px;
  color: var(--text-3);
}
.timeline__edge[hidden] {
  display: none;
}
.timeline__start {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 8px auto 18px;
  max-width: 340px;
  padding: 18px 20px;
  border-radius: var(--radius-xl);
  background: var(--mat-regular);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: center;
  text-wrap: pretty;
  box-shadow: var(--shadow-sm);
}
.timeline__start strong {
  color: var(--text);
  font-size: var(--fs-lg);
}
.timeline__start[hidden] {
  display: none;
}

/* Day sections with sticky separators (Telegram-style floating date while scrolling) */
.day {
  position: relative;
}
.day__sep {
  position: sticky;
  top: calc(var(--chat-head-h) + var(--safe-top) + 8px);
  z-index: 3;
  display: flex;
  justify-content: center;
  height: 0;
  margin: 26px 0 24px;
  pointer-events: none;
}
.conv-pane.has-pinned .day__sep {
  top: calc(var(--chat-head-h) + var(--safe-top) + 56px);
}
/* Messages: the day, centred in 11 px grey — on a small glass capsule here because it floats over
   the bubbles while scrolling. */
.day__sep span {
  height: 22px;
  margin-top: -11px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--mat-regular);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: 22px;
  white-space: nowrap;
  transition: opacity var(--dur-3) ease;
}
.timeline.is-idle .day__sep.is-stuck span {
  opacity: 0;
  transition-duration: var(--dur-4);
}

.unread-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px -6px;
  color: var(--accent-ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}
.unread-sep::before,
.unread-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 38%, transparent);
}
.unread-sep span {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--mat-regular);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
}

.system-msg {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}
.system-msg span {
  max-width: min(80%, 460px);
  padding: 4px 12px;
  border-radius: var(--radius-lg);
  background: var(--mat-regular);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  color: var(--text-2);
  font-size: var(--fs-xs);
  text-align: center;
  text-wrap: pretty;
}

/* -- Message rows & bubbles ------------------------------------------------------------------------ */
.msg {
  --gap: 2px;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: var(--gap);
  outline: none;
  touch-action: pan-y;
  -webkit-touch-callout: none;
}
.msg.is-first {
  --gap: 8px;
}
.msg.is-out {
  flex-direction: row-reverse;
}
.msg:focus-visible .bubble {
  box-shadow:
    0 0 0 2px var(--focus-ring),
    var(--bubble-shadow);
}
.msg__avatar {
  flex-shrink: 0;
  width: 32px;
  align-self: flex-end;
}
.msg__avatar > .avatar {
  --size: 32px;
  width: 32px;
  height: 32px;
  font-size: 12px;
  cursor: pointer;
}
.msg:not(.is-last) .msg__avatar > * {
  visibility: hidden;
}
.timeline.is-dm .msg__avatar,
.msg.is-out .msg__avatar {
  display: none;
}
.msg__col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: var(--bubble-max);
  min-width: 0;
}
.msg.is-out .msg__col {
  align-items: flex-end;
}

/* r4 · 12.17 — iMessage bubbles: radius 18, 8/12 padding, no shadow; mine = the fixed accent
   gradient + white, theirs = the opaque --fill-2 grey + --text. */
.bubble {
  position: relative;
  min-width: 64px;
  max-width: 100%;
  padding: 7px 12px 8px;
  border-radius: var(--bubble-radius);
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  box-shadow: var(--bubble-shadow);
  font-size: var(--bubble-font);
  line-height: 1.38;
  overflow-wrap: anywhere;
  word-break: break-word;
  transform-origin: bottom left;
  user-select: text;
  -webkit-user-select: text;
}
.msg.is-out .bubble {
  background: var(--bubble-out);
  background-attachment: fixed;
  color: var(--bubble-out-text);
  transform-origin: bottom right;
}
/* Grouped corners: the side facing the gutter is tighter between consecutive bubbles. */
.msg.is-in:not(.is-first) .bubble {
  border-top-left-radius: var(--bubble-joint);
}
.msg.is-in:not(.is-last) .bubble {
  border-bottom-left-radius: var(--bubble-joint);
}
.msg.is-out:not(.is-first) .bubble {
  border-top-right-radius: var(--bubble-joint);
}
.msg.is-out:not(.is-last) .bubble {
  border-bottom-right-radius: var(--bubble-joint);
}
/* Tail (last of a group) */
.msg.is-last:not(.is-bare) .bubble::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 14px;
  height: 18px;
  background: inherit;
  background-attachment: inherit;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18'%3E%3Cpath d='M14 0v18H0c5.5-1.4 8.6-4.4 10.4-8.8C11.8 5.7 12.6 2.6 14 0z'/%3E%3C/svg%3E") no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18'%3E%3Cpath d='M14 0v18H0c5.5-1.4 8.6-4.4 10.4-8.8C11.8 5.7 12.6 2.6 14 0z'/%3E%3C/svg%3E") no-repeat;
}
.msg.is-in.is-last:not(.is-bare) .bubble {
  border-bottom-left-radius: 4px;
}
.msg.is-in.is-last:not(.is-bare) .bubble::before {
  left: -6px;
}
.msg.is-out.is-last:not(.is-bare) .bubble {
  border-bottom-right-radius: 4px;
}
.msg.is-out.is-last:not(.is-bare) .bubble::before {
  right: -6px;
  transform: scaleX(-1);
}
.bubble__sender {
  display: block;
  margin-bottom: 1px;
  overflow: hidden;
  color: var(--tone-ink, var(--accent-ink));
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.bubble__sender:hover {
  text-decoration: underline;
}
.msg:not(.is-first) .bubble__sender,
.timeline.is-dm .bubble__sender,
.msg.is-out .bubble__sender {
  display: none;
}
.bubble__forwarded {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  color: var(--bubble-in-meta);
  font-size: var(--fs-xs);
  font-style: italic;
}
.msg.is-out .bubble__forwarded {
  color: var(--bubble-out-meta);
}

/* Text + meta wrap: an inline spacer reserves room for the absolutely placed meta. */
.bubble__text {
  white-space: normal;
}
.bubble__text .task-ref {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.bubble__text > :first-child {
  margin-top: 0;
}
.bubble__text > :last-child {
  margin-bottom: 0;
}
.bubble__text p {
  margin: 0 0 0.4em;
}
.bubble__text a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 2px;
}
.msg.is-out .bubble__text a {
  color: inherit;
}
.bubble__text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--fill-1);
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.msg.is-out .bubble__text code,
.msg.is-out .bubble__text pre {
  background: rgb(0 0 0 / 0.16);
}
.bubble__text pre {
  margin: 4px 0;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--fill-1);
  font-size: var(--fs-sm);
  white-space: pre;
}
.bubble__text pre code,
.msg.is-out .bubble__text pre code {
  padding: 0;
  background: none;
}
.bubble__text blockquote {
  margin: 0 0 4px;
  padding-left: 8px;
  border-left: 3px solid currentColor;
  opacity: 0.85;
}
.bubble__text ul,
.bubble__text ol {
  margin: 2px 0 4px;
  padding-left: 20px;
}
.bubble__text .mention {
  color: var(--accent-ink);
  font-weight: var(--fw-semibold);
  text-decoration: none;
}
.msg.is-out .bubble__text .mention {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgb(255 255 255 / 0.5);
  text-underline-offset: 2px;
}
.bubble__text .mention.is-me {
  padding: 0 3px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--c-yellow) 30%, transparent);
}
.bubble__spacer {
  display: inline-block;
  width: var(--meta-w, 58px);
  height: 1em;
  vertical-align: bottom;
}
.bubble__meta {
  position: absolute;
  right: 10px;
  bottom: 5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--bubble-in-meta);
  font-size: var(--fs-2xs);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
.msg.is-out .bubble__meta {
  color: var(--bubble-out-meta);
}
.bubble__meta .bubble__edited {
  font-style: italic;
}
.bubble__meta .icon {
  width: 12px;
  height: 12px;
}

/* -- Media inside bubbles: the grid sizes the bubble (captions wrap at the photo's width) ---------- */
.bubble.has-media {
  --grid-w: var(--media-w);
  width: calc(var(--grid-w) + 6px);
  max-width: 100%;
  padding: 3px 3px 6px;
}
.bubble.has-media[data-media="1"] {
  /* one photo: as wide as its aspect ratio allows under --media-h (no letterbox gaps) */
  --grid-w: clamp(200px, calc(var(--media-h) * var(--ratio, 1.333)), var(--media-w));
}
.bubble.has-media.is-media-only {
  padding: 3px;
}
.bubble.has-media > :is(.bubble__sender, .bubble__forwarded, .quote, .bubble__text, .file, .tcard, .reactions) {
  margin-inline: 8px;
}
.bubble.has-media > .bubble__sender {
  margin-top: 4px;
}
.bubble.has-media > .quote {
  width: auto;
  margin-top: 4px;
}
.bubble.has-media > .media-grid + .bubble__text {
  margin-top: 6px;
}
.bubble.has-media > .media-grid:first-child {
  margin-top: 0;
}
.media-grid {
  display: grid;
  gap: 2px;
  width: 100%;
  overflow: hidden;
  border-radius: calc(var(--bubble-radius) - 4px);
}
.bubble.has-media > .bubble__sender + .media-grid,
.bubble.has-media > .bubble__forwarded + .media-grid,
.bubble.has-media > .quote + .media-grid {
  margin-top: 4px;
}
.media-grid[data-n="1"] {
  grid-template-columns: 1fr;
}
.media-grid[data-n="2"] {
  grid-template-columns: 1fr 1fr;
}
.media-grid[data-n="3"] {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.media-grid[data-n="3"] > :first-child {
  grid-row: span 2;
}
.media-grid[data-n="4"],
.media-grid[data-n="many"] {
  grid-template-columns: 1fr 1fr;
}
.media-grid[data-n="many"] > :nth-child(n + 5) {
  display: none;
}
.media {
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: var(--fill-2);
  cursor: zoom-in;
}
.media:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.media-grid[data-n="1"] .media {
  aspect-ratio: var(--ar, 4 / 3);
  max-height: var(--media-h);
}
.media-grid:not([data-n="1"]) .media {
  aspect-ratio: 1;
}
.media-grid[data-n="3"] .media:first-child {
  aspect-ratio: auto;
}
.media img,
.media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform var(--dur-3) var(--ease-out),
    opacity var(--dur-3) ease;
}
.media img:not(.is-loaded) {
  opacity: 0;
}
@media (hover: hover) {
  .media:hover img {
    transform: scale(1.025);
  }
}
.media__more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.45);
  color: var(--text-on-accent);
  font-size: var(--fs-title-2);
  font-weight: var(--fw-bold);
}
.media__play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.45);
  color: var(--text-on-accent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.media__progress,
.file__progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.32);
}
.ring {
  --chat-p: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, rgb(0 0 0 / 0.35) 78%, transparent 80% 100%),
    conic-gradient(var(--text-on-accent) calc(var(--chat-p) * 1%), rgb(255 255 255 / 0.25) 0);
  transition: --chat-p var(--dur-2) linear;
}
/* Meta over media without a caption */
.bubble.is-media-only .bubble__meta {
  right: 10px;
  bottom: 10px;
  padding: 3px 7px;
  border-radius: var(--radius-full);
  background: rgb(0 0 0 / 0.45);
  color: var(--text-on-accent);
  /* Dimmed glass: the time and the read ticks stay legible (≥ 3:1) even over a white photo. */
  -webkit-backdrop-filter: blur(8px) brightness(0.72);
  backdrop-filter: blur(8px) brightness(0.72);
}

/* Big emoji (1–3 emoji only, no bubble) */
.msg.is-bare .bubble {
  min-width: 0;
  padding: 0 0 20px;
  background: none;
  box-shadow: none;
}
.msg.is-bare .bubble__text {
  font-size: 44px;
  line-height: 1.15;
  letter-spacing: 2px;
}
.msg.is-bare[data-emoji="1"] .bubble__text {
  font-size: 64px;
}
.msg.is-bare .bubble__meta {
  right: 2px;
  bottom: 0;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--text-2);
}
@media (prefers-reduced-motion: no-preference) {
  .msg.is-bare.is-entering .bubble__text {
    animation: chat-emoji-in 620ms var(--ease-spring);
  }
}

/* Deleted */
.msg.is-deleted .bubble__text {
  color: var(--bubble-in-meta);
  font-style: italic;
}
.msg.is-out.is-deleted .bubble__text {
  color: var(--bubble-out-meta);
}
.msg.is-deleted .bubble__text .icon {
  vertical-align: -2px;
  margin-right: 4px;
}

/* -- Status ticks (WhatsApp): 🕓 sending → ✓ sent → ✓✓ delivered → blue ✓✓ read -----------------
   One 16×11 glyph for every state (core.js TICKS = templates/chat/partials/ticks.html): its box
   never changes, so the meta — and the room fitMeta reserves for it — never jumps. Colours come
   from --_tick / --_tick-read, set per background below (tokens at the top of this file). The
   checks draw in (pathLength 1 dash offsets), "read" pops once (.is-pop from core.js setTicks),
   the sending clock's hands turn. */
.ticks {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 16px;
  height: 11px;
  color: var(--_tick, var(--tick));
  transition: color var(--dur-3) ease;
}
/* Read: coloured and a hair bolder, so it never reads as the muted delivered ✓✓. */
.ticks[data-state="read"],
.conv__ticks.is-read {
  color: var(--_tick-read, var(--tick-read-surface, var(--accent-ink)));
}
.ticks[data-state="read"] :is(.t1, .t2) {
  stroke-width: 1.75;
}
.ticks svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.ticks path,
.ticks circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ticks .clock :is(circle, path) {
  stroke-width: 1.3;
}
.ticks .clock {
  opacity: 0;
  transform-origin: 5.8px 5.5px;
  transform: scale(0.5);
  transition:
    opacity var(--dur-2) ease,
    transform var(--dur-2) var(--ease-out);
}
.ticks[data-state="sending"] .clock {
  opacity: 1;
  transform: none;
}
.ticks .t1,
.ticks .t2 {
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1.05;
  opacity: 0;
  transition:
    stroke-dashoffset var(--dur-3) var(--ease-out),
    opacity var(--dur-1) ease;
}
.ticks:is([data-state="sent"], [data-state="saved"], [data-state="delivered"], [data-state="read"]) .t1,
.ticks:is([data-state="delivered"], [data-state="read"]) .t2 {
  stroke-dashoffset: 0;
  opacity: 1;
}
/* 🕓 → ✓: the clock shrinks away first; ✓ → ✓✓: the second check follows the first. */
.ticks:not([data-state="sending"]) .t1 {
  transition-delay: 60ms;
}
.ticks:is([data-state="delivered"], [data-state="read"]) .t2 {
  transition-delay: 140ms;
}
/* Backgrounds: the outgoing bubble (deep accent), a photo (dark glass pill), big emoji (no bubble). */
.msg.is-out .bubble__meta {
  --_tick: var(--tick-out);
  --_tick-read: var(--read-tick);
}
.msg.is-out .bubble.is-media-only .bubble__meta {
  --_tick: var(--tick-scrim);
  --_tick-read: var(--tick-read-scrim);
}
.msg.is-out.is-bare .bubble__meta {
  --_tick: var(--tick);
  --_tick-read: var(--tick-read-surface);
}
/* The state shows as a tooltip (title); the meta itself lets clicks through to the bubble. */
.bubble__meta .ticks {
  pointer-events: auto;
}
.msg.is-in .ticks {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .ticks[data-state="sending"] .clock-min {
    transform-origin: 5.8px 5.5px;
    animation: chat-spin 1.6s linear infinite;
  }
  .ticks[data-state="sending"] .clock-hour {
    transform-origin: 5.8px 5.5px;
    animation: chat-spin 19.2s linear infinite;
  }
  .ticks.is-pop {
    animation: chat-tick-read 460ms var(--ease-out);
  }
}
.msg.is-pending .bubble {
  opacity: 0.94;
}
.msg.is-failed .bubble {
  opacity: 0.9;
}
.msg__retry {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 4px;
  height: 28px;
  margin: 0 6px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger-ink);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.msg__retry:hover {
  background: color-mix(in srgb, var(--danger) 22%, var(--surface));
}

/* Reply quote */
.quote {
  --tone: var(--accent);
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 2px 0 5px;
  padding: 5px 10px 5px 11px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-1) ease;
}
.quote::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone);
}
.msg.is-out .quote {
  --tone: var(--text-on-accent);
  background: rgb(255 255 255 / 0.16);
}
.quote__body {
  display: grid;
  flex: 1;
  min-width: 0;
}
.quote__name {
  overflow: hidden;
  color: var(--tone-ink, var(--accent-ink));
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.is-out .quote__name {
  color: var(--text-on-accent);
}
.quote__text {
  overflow: hidden;
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.86;
}
.quote__text .icon {
  vertical-align: -2px;
  margin-right: 3px;
}
.quote__thumb {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
}
button.quote:hover {
  background: color-mix(in srgb, var(--tone) 18%, transparent);
}
.msg.is-out button.quote:hover {
  background: rgb(255 255 255 / 0.22);
}
button.quote:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* Reactions — r4 · 12.17 tapbacks: they hang on the bubble's top corner on the side away from
   the sender (theirs: top-right, mine: top-left) as 22 px glass capsules ringed in the wallpaper
   colour. The bubble turns into a flex column only to lift them there (order: -1, negative
   margins cancel their height); `contain: inline-size` keeps them from widening the bubble. */
.bubble:has(> .reactions) {
  --_rx-pt: 7px;
  --_rx-px: 12px;
  display: flex;
  flex-direction: column;
}
.bubble.has-media:has(> .reactions) {
  --_rx-pt: 3px;
  --_rx-px: 3px;
}
.msg.is-bare .bubble:has(> .reactions) {
  --_rx-pt: 0px;
  --_rx-px: 0px;
}
.msg:has(> .msg__col > .bubble > .reactions) {
  padding-top: calc(var(--gap) + 18px);
}
.bubble > .reactions.reactions {
  position: relative;
  z-index: 1;
  order: -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: calc(-18px - var(--_rx-pt)) calc(-10px - var(--_rx-px)) calc(var(--_rx-pt) - 4px) 0;
  padding: 0;
  contain: inline-size;
  pointer-events: none;
}
.bubble > .reactions.reactions:has(.reaction__avatars) {
  margin-bottom: calc(var(--_rx-pt) - 6px);
}
.msg.is-out .bubble > .reactions.reactions {
  justify-content: flex-start;
  margin-right: 0;
  margin-left: calc(-10px - var(--_rx-px));
}
.reactions__spacer {
  display: none;
}
/* Text keeps room for the time whether or not it was rendered with reactions (live updates only
   swap the .reactions node). */
.msg:not(.is-bare) .bubble > .bubble__text:not(:has(> .bubble__spacer))::after {
  content: "";
  display: inline-block;
  width: var(--meta-w, 58px);
  height: 1em;
  vertical-align: bottom;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 7px 0 5px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow:
    0 0 0 2px var(--wall-solid),
    var(--shadow-sm);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  transition:
    background-color var(--dur-1) ease,
    transform var(--dur-2) var(--spring-snappy);
}
.reaction:hover {
  background: var(--surface-elevated);
}
.reaction:active {
  transform: scale(0.9);
}
.reaction:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
}
.reaction__emoji {
  font-size: 13px;
  line-height: 1;
}
.reaction__count {
  position: relative;
  display: inline-block;
  height: 14px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  line-height: 14px;
}
/* Mine: the accent tapback (Messages). */
.reaction.is-mine {
  background: var(--accent);
  color: var(--text-on-accent);
}
.reaction.is-mine:hover {
  background: var(--accent-hover);
}
/* Reactor avatars stay 20 px: core.js sizes stacked initials for exactly that (stackedInitialsFont),
   so the capsule grows to 24 px when it carries them. */
.reaction:has(> .reaction__avatars) {
  height: 24px;
  padding-right: 3px;
}
.reaction .avatar {
  --size: 20px;
  width: 20px;
  height: 20px;
  font-size: 8px;
  letter-spacing: 0;
  white-space: nowrap;
}
/* Up to three reactors: the shared .avatar-stack (core/content.css) — a 20% overlap, initials
   centred in the part that shows so they are never cut — with a slim ring in the chip's colour. */
.reaction__avatars {
  --avatar-ring: var(--surface-elevated);
  display: inline-flex;
}
.reaction.is-mine .reaction__avatars {
  --avatar-ring: var(--accent);
}
.reaction .reaction__avatars > .avatar {
  --stack-ring: 1.5px;
}
@media (prefers-reduced-motion: no-preference) {
  .reaction.is-new {
    animation: chat-pop 480ms var(--spring-bouncy);
  }
  .reaction.is-new .reaction__emoji {
    animation: chat-emoji-bounce 600ms var(--spring-bouncy);
  }
  .reaction__count.is-rolling-up > span {
    animation: chat-roll-up var(--dur-3) var(--ease-out);
  }
  .reaction__count.is-rolling-down > span {
    animation: chat-roll-down var(--dur-3) var(--ease-out);
  }
}
.burst {
  position: fixed;
  z-index: var(--z-tooltip);
  width: 0;
  height: 0;
  pointer-events: none;
}
.burst i {
  position: absolute;
  left: -8px;
  top: -8px;
  font-size: 16px;
  font-style: normal;
  line-height: 1;
  animation: chat-burst 900ms var(--ease-out) forwards;
}

/* Highlight when jumping to a message; search hits */
.msg.is-highlight .bubble {
  animation: chat-highlight 1.6s var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .msg.is-highlight .bubble {
    animation: none;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}
.msg.is-search-hit .bubble__text mark {
  border-radius: 3px;
  background: color-mix(in srgb, var(--c-yellow) 55%, transparent);
  color: inherit;
}
.msg.is-out.is-search-hit .bubble__text mark {
  background: rgb(255 255 255 / 0.32);
}

/* Hover actions (desktop): one toolbar moved into the hovered row */
.msg__actions {
  display: flex;
  align-self: center;
  gap: 2px;
  margin: 0 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-1) ease;
}
.msg__actions button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--glass-sheen), var(--mat-thick);
  color: var(--text-2);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-sm);
  cursor: pointer;
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  transition:
    color var(--dur-1) ease,
    transform var(--dur-2) var(--spring-snappy);
}
.msg__actions button:hover {
  color: var(--accent-ink);
}
.msg__actions button:active {
  transform: scale(0.9);
}
@media (hover: hover) and (pointer: fine) {
  .msg:hover .msg__actions,
  .msg:focus-within .msg__actions {
    opacity: 1;
    pointer-events: auto;
  }
}
@media (hover: none), (pointer: coarse) {
  .msg__actions {
    display: none;
  }
}
.timeline.is-selecting .msg__actions,
.msg.is-pending .msg__actions,
.msg.is-failed .msg__actions {
  display: none;
}

/* Swipe-to-reply affordance */
.msg__swipe {
  position: absolute;
  top: 50%;
  left: -38px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}
.msg.is-swiping {
  transition: none;
}
.msg.is-swipe-armed .msg__swipe {
  color: var(--accent);
}
.msg.is-swipe-release {
  transition: transform var(--dur-3) var(--ease-spring);
}

/* Entering animations: own messages spring up from the composer, others rise and fade in. */
@media (prefers-reduced-motion: no-preference) {
  .msg.is-entering.is-out .bubble {
    animation: chat-send 380ms var(--ease-spring);
  }
  .msg.is-entering.is-in .bubble {
    animation: chat-receive 320ms var(--ease-out);
  }
  .msg.is-entering .msg__avatar > * {
    animation: chat-fade 300ms ease;
  }
  .conv-pane.is-arriving .timeline__inner {
    animation: chat-fade 200ms var(--ease-out);
  }
}

/* Selection mode */
.msg__select {
  display: none;
  flex-shrink: 0;
  align-self: center;
  width: 22px;
  height: 22px;
  margin: 0 4px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  transition:
    background-color var(--dur-1) ease,
    border-color var(--dur-1) ease;
}
.timeline.is-selecting .msg__select {
  display: grid;
  place-items: center;
}
.msg.is-selected .msg__select {
  border-color: var(--accent);
  background: var(--accent);
}
.msg.is-selected .msg__select::after {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--text-on-accent);
  -webkit-mask: var(--check-mask) center / contain no-repeat;
  mask: var(--check-mask) center / contain no-repeat;
}
.timeline.is-selecting .msg {
  cursor: pointer;
}
.timeline.is-selecting .msg .bubble {
  user-select: none;
  -webkit-user-select: none;
}
.timeline.is-selecting .msg.is-selected {
  border-radius: var(--radius-md);
  background: var(--accent-softer);
}

/* Files */
.file {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 260px;
  max-width: 100%;
  margin: 2px 0 4px;
  color: inherit;
  text-decoration: none;
}
.file + .file {
  margin-top: 6px;
}
.file__icon {
  position: relative;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--tone-solid, var(--accent));
  color: var(--text-on-accent);
  overflow: hidden;
}
.msg.is-out .file__icon {
  background: rgb(255 255 255 / 0.22);
}
.file__ext {
  position: absolute;
  bottom: 4px;
  font-size: 8.5px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.file__body {
  display: grid;
  min-width: 0;
}
.file__name {
  overflow: hidden;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file__size {
  color: var(--bubble-in-meta);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.msg.is-out .file__size {
  color: var(--bubble-out-meta);
}
.file:hover .file__name {
  text-decoration: underline;
}
.file:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 12px;
}

/* Voice message */
.voice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 300px;
  max-width: 100%;
  padding: 2px 0;
}
.voice__play {
  position: relative;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-on-accent);
  cursor: pointer;
  transition: transform var(--dur-1) ease;
}
.voice__play:active {
  transform: scale(0.92);
}
.voice__play:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.msg.is-out .voice__play {
  background: var(--text-on-accent);
  color: var(--accent);
}
.voice__play .icon {
  transition:
    transform var(--dur-2) var(--ease-spring),
    opacity var(--dur-1) ease;
}
.voice__play .i-pause,
.voice.is-playing .voice__play .i-play {
  position: absolute;
  opacity: 0;
  transform: scale(0.4) rotate(-90deg);
}
.voice.is-playing .voice__play .i-pause {
  position: static;
  opacity: 1;
  transform: none;
}
.voice__main {
  display: grid;
  flex: 1;
  gap: 3px;
  min-width: 0;
}
.wave {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  overflow: hidden; /* narrow columns: bars never push the bubble wider */
  border-radius: 4px;
  cursor: pointer;
  touch-action: none;
}
.wave:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.wave i {
  flex: 1;
  min-width: 2px;
  max-width: 3px;
  height: calc(var(--h, 0.2) * 100%);
  min-height: 3px;
  border-radius: 2px;
  background: color-mix(in srgb, currentColor 30%, transparent);
  transition: background-color var(--dur-1) linear;
}
.wave i.is-played {
  background: var(--accent);
}
.msg.is-out .wave i {
  background: rgb(255 255 255 / 0.42);
}
.msg.is-out .wave i.is-played {
  background: var(--text-on-accent);
}
.voice__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--bubble-in-meta);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.msg.is-out .voice__meta {
  color: var(--bubble-out-meta);
}
.voice__unheard {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.voice__speed {
  min-width: 32px;
  height: 20px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--fill-2);
  color: inherit;
  font: inherit;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  cursor: pointer;
}
.msg.is-out .voice__speed {
  background: rgb(255 255 255 / 0.22);
}
.voice__speed[hidden] {
  display: none;
}

/* Task / info-card embeds */
.tcard {
  --tone: var(--accent);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  margin: 6px 0 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--text);
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition:
    transform var(--dur-1) ease,
    box-shadow var(--dur-1) ease;
}
.bubble .tcard {
  background: var(--surface-2);
}
.msg.is-out .tcard {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  box-shadow: none;
}
.tcard:hover {
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-sm);
}
.tcard:active {
  transform: scale(0.985);
}
.tcard:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.tcard__tile {
  grid-row: span 2;
}
.tcard__title {
  display: flex;
  gap: 6px;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
}
.tcard__title span:last-child {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.tcard__key {
  flex-shrink: 0;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
}
.tcard__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.tcard.is-done .tcard__title span:last-child {
  color: var(--text-2);
  text-decoration: line-through;
}
.task-key-link {
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-weight: var(--fw-semibold);
}

/* -- Typing bubble --------------------------------------------------------------------------------- */
.typing-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 0;
  padding-top: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    height var(--dur-3) var(--ease-out),
    padding var(--dur-3) var(--ease-out),
    opacity var(--dur-2) ease;
}
.typing-row.is-visible {
  height: 44px;
  padding-top: 8px;
  opacity: 1;
}
.timeline.is-dm .typing-row__avatar {
  display: none;
}
.typing-row .bubble {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  height: 36px;
  padding: 0 14px;
  border-bottom-left-radius: 4px;
  color: var(--text-3);
}
.typing-row .typing-dots i {
  width: 7px;
  height: 7px;
}
.typing-row .typing-dots {
  gap: 4px;
  margin: 0;
}

/* -- Jump to bottom (+ unread count) --------------------------------------------------------------- */
.jump-bottom {
  position: absolute !important;
  right: max(16px, var(--safe-right));
  bottom: calc(var(--composer-h, 64px) + 14px);
  z-index: 6 !important;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--glass-sheen), var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  color: var(--text-2);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-md);
  cursor: pointer;
  transition:
    transform var(--dur-3) var(--ease-spring),
    opacity var(--dur-2) ease,
    color var(--dur-1) ease;
}
.jump-bottom:hover {
  color: var(--text);
}
.jump-bottom:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.jump-bottom[hidden] {
  display: grid !important;
  transform: translateY(20px) scale(0.6);
  opacity: 0;
  pointer-events: none;
}
.jump-bottom__badge {
  position: absolute;
  top: -8px;
  left: 50%;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  line-height: 22px;
  text-align: center;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--wall-base);
}
.jump-bottom__badge:empty {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .jump-bottom__badge.is-bump {
    animation: chat-pop-centered 420ms var(--ease-spring);
  }
}
.jump-mention {
  bottom: calc(var(--composer-h, 64px) + 66px);
  color: var(--accent-ink);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
}

/* -- Composer -------------------------------------------------------------------------------------- */
/* r4 · 12.17 — Messages: (+) on the left, a capsule field in the middle, and on the right the
   microphone while it's empty / the accent ↑ once there's text (the round fill springs in from
   scale .5). The bar is chrome glass the timeline scrolls under. */
.composer {
  position: absolute !important;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6 !important;
  padding: 8px max(10px, var(--safe-right)) calc(8px + var(--safe-bottom)) max(10px, var(--safe-left));
  background: var(--mat-chrome);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 -0.5px 0 var(--line);
}
@media (min-width: 768px) {
  .composer {
    padding-inline: clamp(10px, 3%, 48px);
  }
}
.composer__ctx {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-3) var(--ease-sheet);
}
.composer__ctx.is-open {
  grid-template-rows: 1fr;
}
.composer__ctx > div {
  min-height: 0;
  overflow: hidden;
}
.composer__ctx-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 8px;
}
.composer__ctx-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  color: var(--accent-ink);
}
.composer__ctx .quote {
  flex: 1;
  margin: 0;
}
.composer__ctx .quote::before {
  border-radius: 2px;
}
.composer__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer__btn {
  position: relative;
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-1) ease,
    color var(--dur-1) ease,
    transform var(--dur-2) var(--spring-snappy);
}
.composer__btn:hover {
  background: var(--fill-1);
  color: var(--text);
}
.composer__btn:active {
  transform: scale(0.9);
}
.composer__btn:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}
.composer__btn[aria-expanded="true"] {
  color: var(--accent-ink);
}
/* (+) — a 32 px --fill-2 circle (the attach menu). The sprite's paperclip gives way to a plus. */
.composer__attach {
  width: 32px;
  height: 32px;
  margin-bottom: 2px;
  background: var(--fill-2);
  color: var(--text-2);
}
.composer__attach:hover {
  background: var(--fill-3);
}
.composer__attach > .icon {
  display: none;
}
.composer__attach::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: var(--chat-plus-mask) center / contain no-repeat;
  mask: var(--chat-plus-mask) center / contain no-repeat;
  transition: transform var(--dur-3) var(--spring-bouncy);
}
.composer__attach[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.composer__attach[aria-expanded="true"]::before {
  transform: rotate(45deg);
}
.composer__field {
  position: relative;
  display: flex;
  flex: 1;
  align-items: flex-end;
  min-width: 0;
  min-height: 36px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: inset 0 0 0 0.5px var(--line-strong);
  transition: box-shadow var(--dur-1) ease;
}
/* Always-focused field: a calm accent hairline, not a heavy focus ring. */
.composer__field:focus-within {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, var(--line-strong)),
    0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.composer__input {
  flex: 1;
  min-width: 0;
  max-height: calc(8 * 1.38em + 16px);
  min-height: 36px;
  margin: 0;
  padding: 8px 4px 8px 14px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--bubble-font);
  line-height: 1.38;
  resize: none;
  outline: none;
  overflow-y: auto;
  field-sizing: content;
  scrollbar-width: thin;
}
.composer__input::placeholder {
  color: var(--text-3);
}
@media (pointer: coarse) {
  .composer__input {
    font-size: max(16px, var(--bubble-font));
  }
}
.composer__field .composer__btn {
  width: 32px;
  height: 32px;
  margin: 2px 3px 2px 0;
}
/* Send: an empty button with the mic glyph; text in the field → the accent disc springs in
   (scale .5 → 1, --spring-bouncy) with a white ↑. Editing → ✓ and recording → mic on the same disc. */
.composer__send {
  isolation: isolate;
  color: var(--text-2);
}
.composer__send::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: scale(0.5);
  transition:
    transform var(--dur-bouncy) var(--spring-bouncy),
    opacity var(--dur-2) ease,
    background-color var(--dur-1) ease;
}
.composer:is(.has-text, .is-editing, .is-recording) .composer__send {
  color: var(--text-on-accent);
}
.composer:is(.has-text, .is-editing) .composer__send:hover {
  background: none;
  color: var(--text-on-accent);
}
.composer:is(.has-text, .is-editing, .is-recording) .composer__send::before {
  opacity: 1;
  transform: none;
}
.composer:is(.has-text, .is-editing) .composer__send:hover::before {
  background: var(--accent-hover);
}
.composer__send .icon {
  position: absolute;
  transition:
    transform var(--dur-bouncy) var(--spring-bouncy),
    opacity var(--dur-2) ease;
}
/* The sprite's paper plane gives way to Messages' ↑ (a masked glyph in the same slot). */
.composer__send .i-send {
  opacity: 0;
  transform: scale(0.3);
  visibility: hidden;
}
.composer__send::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--chat-arrow-up-mask) center / contain no-repeat;
  mask: var(--chat-arrow-up-mask) center / contain no-repeat;
  opacity: 0;
  transform: translateY(6px) scale(0.4);
  transition:
    transform var(--dur-bouncy) var(--spring-bouncy),
    opacity var(--dur-2) ease;
}
.composer.has-text:not(.is-editing, .is-recording) .composer__send::after,
.composer.is-recording.is-locked .composer__send::after {
  opacity: 1;
  transform: none;
}
.composer.is-editing .composer__send .i-check {
  opacity: 1;
  transform: none;
}
.composer:is(.has-text, .is-editing) .composer__send .i-mic {
  opacity: 0;
  transform: scale(0.3);
}
.composer__send .i-check {
  opacity: 0;
  transform: scale(0.3);
}
.composer.is-readonly .composer__row {
  display: none;
}
.composer__readonly {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: center;
}
.composer.is-readonly .composer__readonly {
  display: flex;
}
/* Shell composer (while the conversation loads): same height, inert */
.composer.is-shell .composer__field {
  box-shadow: inset 0 0 0 0.5px var(--line);
}
.composer.is-shell .composer__send {
  opacity: 0.55;
}
.composer.is-shell .composer__row > .composer__btn:first-child {
  width: 32px;
  height: 32px;
  margin-bottom: 2px;
  background: var(--fill-2);
}

/* Recording UI (replaces the row) */
.recorder {
  position: absolute;
  inset: 8px calc(max(10px, var(--safe-right)) + 46px) calc(8px + var(--safe-bottom)) max(10px, var(--safe-left));
  display: none;
  align-items: center;
  gap: 10px;
}
@media (min-width: 768px) {
  .recorder {
    inset-inline: clamp(10px, 3%, 48px) calc(clamp(10px, 3%, 48px) + 46px);
  }
}
.composer.is-recording .composer__row > :not(.composer__send) {
  visibility: hidden;
}
.composer.is-recording .recorder {
  display: flex;
}
.recorder__dot {
  width: 10px;
  height: 10px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--danger);
}
@media (prefers-reduced-motion: no-preference) {
  .recorder__dot {
    animation: chat-blink 1s ease-in-out infinite;
  }
}
.recorder__time {
  min-width: 44px;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.recorder__wave {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  height: 32px;
  min-width: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, black 24%);
  mask-image: linear-gradient(90deg, transparent, black 24%);
}
.recorder__wave i {
  flex: 0 0 3px;
  height: calc(var(--h, 0.1) * 100%);
  min-height: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.recorder__hint {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  white-space: nowrap;
  transition:
    transform var(--dur-1) linear,
    opacity var(--dur-1) linear;
}
@media (prefers-reduced-motion: no-preference) {
  .recorder__hint span {
    background: linear-gradient(90deg, var(--text-3) 30%, var(--text) 50%, var(--text-3) 70%) 0 0 / 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: chat-shimmer 2.2s linear infinite;
  }
}
.recorder__cancel,
.recorder__stop {
  display: none;
}
.composer.is-locked .recorder__hint {
  display: none;
}
.composer.is-locked .recorder__cancel,
.composer.is-locked .recorder__stop {
  display: grid;
}
.recorder__cancel {
  color: var(--danger-ink);
}
.composer.is-recording .composer__send {
  z-index: 2;
  background: var(--accent);
}
.composer.is-recording:not(.is-locked) .composer__send {
  transform: scale(1.6);
  box-shadow: 0 0 0 calc(var(--level, 0) * 26px) color-mix(in srgb, var(--accent) 22%, transparent);
  transition:
    box-shadow 90ms linear,
    transform var(--dur-3) var(--ease-spring);
}
.composer.is-recording .composer__send .i-mic {
  opacity: 1;
  transform: none;
}
.composer.is-locked .composer__send .i-mic {
  opacity: 0;
}
.composer.is-locked .composer__send .i-send {
  opacity: 1;
  transform: none;
}
.recorder__lock {
  position: absolute;
  right: -46px;
  bottom: 74px;
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 40px;
  padding: 10px 0 8px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-full);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  color: var(--text-2);
  box-shadow: var(--shadow-lg);
  transform: translateY(var(--lock-y, 0px));
  transition: opacity var(--dur-2) ease;
}
.composer.is-locked .recorder__lock {
  opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .composer.is-recording:not(.is-locked) .recorder__lock .icon:last-child {
    animation: chat-nudge-up 1.4s var(--ease-in-out) infinite;
  }
  .composer.is-recording .recorder {
    animation: chat-fade 200ms ease;
  }
}
.composer.is-recording.is-cancelling .recorder__dot {
  background: var(--text-3);
}

/* Attachment tray (preview before sending) */
.tray {
  display: flex;
  gap: 8px;
  padding: 2px 2px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tray[hidden] {
  display: none;
}
.tray__item {
  position: relative;
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--fill-2);
  box-shadow: var(--shadow-sm);
}
.tray__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tray__item--file {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  width: 140px;
  padding: 8px;
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.tray__item--file span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tray__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  color: var(--text-on-accent);
  cursor: pointer;
}
@media (pointer: coarse) {
  .tray__remove {
    top: 2px;
    right: 2px;
    width: 28px;
    height: 28px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .tray__item {
    animation: chat-pop 320ms var(--ease-spring);
  }
}

/* Drop zone */
.conv-pane .dropzone {
  position: absolute !important;
  inset: 8px;
  z-index: 9 !important;
  display: grid;
  place-items: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: var(--radius-2xl);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--accent-ink);
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-2) ease;
}
.conv-pane .dropzone > div {
  display: grid;
  justify-items: center;
  gap: 10px;
  transform: scale(0.94);
  transition: transform var(--dur-3) var(--ease-spring);
}
.conv-pane.is-dragover .dropzone {
  opacity: 1;
}
.conv-pane.is-dragover .dropzone > div {
  transform: none;
}

/* Autocomplete (@ people, # tasks, : emoji) */
.autocomplete {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 6px);
  left: 8px;
  max-height: 264px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-elevated); /* opaque: nested backdrop-filter can't blur through the composer */
  box-shadow: var(--shadow-xl);
  transform-origin: bottom center;
}
.autocomplete[hidden] {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .autocomplete:not([hidden]) {
    animation: chat-menu-in var(--dur-2) var(--ease-out);
  }
}
@media (min-width: 768px) {
  .autocomplete {
    right: auto;
    left: clamp(52px, 3%, 96px);
    width: 340px;
  }
}
.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ac-item:hover {
  background: var(--fill-1);
}
.ac-item[aria-selected="true"] {
  background: var(--accent);
  color: var(--text-on-accent);
}
.ac-item[aria-selected="true"] .ac-item__sub {
  color: var(--text-on-accent);
}
.ac-item__emoji {
  width: 28px;
  font-size: 22px;
  line-height: 1;
  text-align: center;
}
.ac-item__body {
  display: grid;
  min-width: 0;
}
.ac-item__title {
  overflow: hidden;
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-item__sub {
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -- Emoji picker ---------------------------------------------------------------------------------- */
.emoji-picker {
  position: fixed;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  width: min(352px, calc(100vw - 16px));
  height: min(420px, calc(100dvh - 120px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--glass-sheen), var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter-strong);
  backdrop-filter: var(--mat-filter-strong);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-xl);
  color: var(--text);
  inset: auto;
}
.emoji-picker:not(:popover-open) {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .emoji-picker:popover-open {
    animation: chat-menu-in var(--dur-2) var(--ease-out);
  }
}
@media (max-width: 639px) {
  .emoji-picker {
    right: 0;
    bottom: 0;
    left: 0 !important;
    top: auto !important;
    width: 100%;
    height: min(380px, 55dvh);
    padding-bottom: var(--safe-bottom);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }
}
.emoji-picker__head {
  padding: 10px 10px 6px;
}
.emoji-picker__head .chat-search {
  margin: 0;
}
.emoji-picker__tabs {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  padding: 0 8px 4px;
  border-bottom: 1px solid var(--line);
}
.emoji-picker__tab {
  display: grid;
  place-items: center;
  width: 34px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-3);
  cursor: pointer;
}
.emoji-picker__tab:hover {
  color: var(--text);
}
.emoji-picker__tab[aria-selected="true"] {
  background: var(--fill-2);
  color: var(--accent-ink);
}
.emoji-picker__body {
  flex: 1;
  min-height: 0;
  padding: 4px 8px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.emoji-picker__label {
  position: sticky;
  top: -4px;
  z-index: 1;
  margin: 0 -8px;
  padding: 8px 12px 4px;
  background: linear-gradient(var(--mat-thick) 70%, transparent);
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}
.emoji-btn {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--dur-1) ease;
}
.emoji-btn:hover,
.emoji-btn:focus-visible {
  background: var(--fill-2);
  outline: none;
  transform: scale(1.12);
}
.emoji-picker__empty {
  padding: 40px 0;
  color: var(--text-3);
  text-align: center;
}

/* -- Context menu / lift (iMessage style) ---------------------------------------------------------- */
.lift {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
}
.lift::backdrop {
  background: transparent;
}
/* r4 · 12.17 long-press lift: the chat blurs 8 px under --scrim-light, the bubble lifts (1.03),
   a glass tapback capsule pops its emoji in one by one (24 ms) above it, the menu sits below. */
.lift__scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim-light);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-out);
}
.lift.is-desktop .lift__scrim {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.lift.is-open .lift__scrim {
  opacity: 1;
}
.lift__stack {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.lift__clone {
  position: relative;
  pointer-events: none;
  transform-origin: center;
  transition: transform 380ms var(--ease-spring);
}
.lift__clone .msg {
  padding: 0;
}
.lift__clone .msg__col {
  max-width: none;
}
.lift__clone .bubble {
  box-shadow: var(--shadow-lift);
}
.lift__clone .bubble::before {
  display: none;
}
.lift__clone .msg .bubble {
  border-radius: var(--bubble-radius);
}
.lift__reactions,
.lift__menu {
  opacity: 0;
  transform: scale(0.6);
  transition:
    transform var(--dur-bouncy) var(--spring-bouncy),
    opacity var(--dur-2) ease;
}
.lift.is-open .lift__reactions,
.lift.is-open .lift__menu {
  opacity: 1;
  transform: none;
}
.lift__reactions {
  display: flex;
  align-items: center;
  gap: 2px;
  align-self: flex-start;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--glass-sheen), var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter-strong);
  backdrop-filter: var(--mat-filter-strong);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-xl);
  transform-origin: bottom left;
}
.lift.is-out .lift__reactions,
.lift.is-out .lift__menu {
  align-self: flex-end;
  transform-origin: bottom right;
}
.lift__reactions button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transition: transform var(--dur-2) var(--spring-bouncy);
}
.lift__reactions button:hover,
.lift__reactions button:focus-visible {
  outline: none;
  transform: scale(1.28) translateY(-3px);
}
.lift__reactions button:focus-visible {
  background: var(--fill-2);
}
.lift__reactions button.is-mine {
  background: var(--accent-soft);
}
.lift__reactions .lift__more {
  width: 34px;
  height: 34px;
  background: var(--fill-2);
  color: var(--text-2);
  font-size: 16px;
}
@media (prefers-reduced-motion: no-preference) {
  .lift.is-open .lift__reactions button {
    animation: chat-pop var(--dur-bouncy) var(--spring-bouncy) backwards;
  }
  .lift.is-open .lift__reactions button:nth-child(2) { animation-delay: 24ms; }
  .lift.is-open .lift__reactions button:nth-child(3) { animation-delay: 48ms; }
  .lift.is-open .lift__reactions button:nth-child(4) { animation-delay: 72ms; }
  .lift.is-open .lift__reactions button:nth-child(5) { animation-delay: 96ms; }
  .lift.is-open .lift__reactions button:nth-child(6) { animation-delay: 120ms; }
  .lift.is-open .lift__reactions button:nth-child(7) { animation-delay: 144ms; }
  .lift.is-open .lift__reactions button:nth-child(8) { animation-delay: 168ms; }
}
.lift__menu {
  min-width: 240px;
  padding: 6px;
  border: 0;
  border-radius: var(--radius-menu);
  background: var(--glass-sheen), var(--mat-thick);
  -webkit-backdrop-filter: var(--mat-filter-strong);
  backdrop-filter: var(--mat-filter-strong);
  box-shadow:
    var(--glass-rim),
    0 0 0 0.5px var(--glass-border),
    var(--shadow-xl);
  transform-origin: top left;
}
.lift__menu .menu__item {
  height: 44px;
  font-size: var(--type-body);
}
.lift__menu .menu__item .icon {
  order: 2;
  margin-left: auto;
}
@media (pointer: fine) {
  .lift__reactions button {
    width: 36px;
    height: 36px;
    font-size: 24px;
  }
  .lift__reactions .lift__more {
    width: 30px;
    height: 30px;
  }
  .lift__menu {
    min-width: 220px;
  }
  .lift__menu .menu__item {
    font-size: var(--type-body);
  }
  .lift__menu .menu__item {
    height: var(--row-h);
  }
  .lift__menu .menu__item .icon {
    order: 0;
    margin-left: 0;
  }
}
/* Message info (my own message): the bubble's ticks + "Read · 12:22" (DM) or "Read by 2 · …". */
.lift__seen {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.lift__seen--dm {
  gap: 6px;
}
.lift__seen-label {
  color: var(--text);
  font-weight: var(--fw-medium);
}
.lift__seen-sep {
  color: var(--text-3);
}
.lift__seen .avatar-stack {
  flex-shrink: 0;
}
/* Desktop context menu: the message it belongs to stays highlighted. */
.msg.is-context .bubble {
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent),
    var(--bubble-shadow);
}

/* -- Lightbox -------------------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: rgb(0 0 0 / 0.94);
  color: var(--text-on-accent);
  touch-action: none;
}
.lightbox::backdrop {
  background: transparent;
}
@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] {
    animation: chat-fade 220ms ease-out;
  }
}
.lightbox__bar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(rgb(0 0 0 / 0.6), transparent);
  transition: opacity var(--dur-2) ease;
}
.lightbox.is-chromeless .lightbox__bar,
.lightbox.is-chromeless .lightbox__nav,
.lightbox.is-chromeless .lightbox__caption {
  opacity: 0;
  pointer-events: none;
}
.lightbox__who {
  display: grid;
  flex: 1;
  min-width: 0;
  font-size: var(--fs-sm);
}
.lightbox__who span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lightbox__who span:last-child {
  color: rgb(255 255 255 / 0.72);
  font-size: var(--fs-xs);
}
.lightbox__btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.12);
  color: var(--text-on-accent);
  cursor: pointer;
  text-decoration: none;
}
.lightbox__btn:hover {
  background: rgb(255 255 255 / 0.22);
}
.lightbox__btn:focus-visible {
  outline: 2px solid rgb(255 255 255 / 0.8);
  outline-offset: 2px;
}
.lightbox__track {
  position: absolute;
  inset: 0;
  display: flex;
  will-change: transform;
}
.lightbox__slide {
  display: grid;
  flex: 0 0 100%;
  place-items: center;
  overflow: hidden;
}
@media (min-width: 768px) {
  .lightbox__slide {
    padding: 64px 72px;
  }
}
.lightbox__slide img,
.lightbox__slide video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  margin-top: -22px;
}
.lightbox__nav--prev {
  left: 12px;
}
.lightbox__nav--next {
  right: 12px;
}
.lightbox__caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  padding: 24px 20px calc(18px + var(--safe-bottom));
  background: linear-gradient(transparent, rgb(0 0 0 / 0.6));
  font-size: var(--fs-md);
  text-align: center;
}
.lightbox__count {
  color: rgb(255 255 255 / 0.75);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
@media (hover: none) {
  .lightbox__nav {
    display: none;
  }
}

/* -- Info panel ------------------------------------------------------------------------------------ */
.info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.info__head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  height: calc(var(--chat-head-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0 10px;
  background: var(--mat-chrome);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
}
@media (min-width: 768px) {
  .info__head {
    height: 52px;
    padding-top: 0;
  }
}
.info__head .btn--icon {
  border-radius: 50%;
}
.info__head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: var(--type-headline);
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info__scroll {
  flex: 1;
  min-height: 0;
  padding-bottom: calc(24px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Hero (Contacts): 80 px avatar, 22 px name, a grey subtitle, then the action tiles. */
.info__hero {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 16px 18px;
  text-align: center;
}
.info__hero > .chat-avatar {
  --size: 80px;
  margin-bottom: 6px;
}
.info__hero h3 {
  margin: 0;
  font-size: var(--fs-title-2);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-snug);
  line-height: 1.2;
  text-wrap: balance;
}
.info__hero p {
  margin: 0;
  color: var(--text-2);
  font-size: var(--type-subhead);
}
.info__quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 14px;
}
.info__quick > * {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 56px;
  padding: 8px 4px 7px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--card-ring);
  color: var(--accent-ink);
  font: inherit;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-1) ease,
    transform var(--dur-2) var(--spring-snappy);
}
.info__quick > * span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info__quick > *:hover {
  background: color-mix(in srgb, var(--surface), var(--text) 4%);
}
.info__quick > *:active {
  transform: scale(0.95);
}
.info__quick > *:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 1px;
}
.info__quick > [aria-pressed="true"] {
  background: var(--accent);
  color: var(--text-on-accent);
}
.info__section {
  margin: 0 16px 20px;
}
.info__section .list-group__header {
  padding-inline: 16px;
}
.info__desc {
  padding: 11px 16px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--card-ring);
  color: var(--text);
  font-size: var(--type-body);
  white-space: pre-wrap;
}
.info-members {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--card-ring);
  list-style: none;
}
.info-members > li {
  position: relative;
}
.info-members > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 62px;
  height: 0.5px;
  background: var(--line);
}
.info-member {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 12px 6px 14px;
}
@media (hover: hover) {
  .info-member:hover {
    background: var(--fill-1);
  }
}
.info-member--action {
  width: 100%;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.info-member--action:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: -2px;
}
.info-member__body {
  display: grid;
  flex: 1;
  min-width: 0;
}
.info-member__name {
  overflow: hidden;
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info-member__sub {
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info-member__sub.is-online {
  color: var(--accent-ink);
}
/* Gallery tabs: a scrolling strip with edge fades (ky labels are long). */
.info-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 6px 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  background: var(--bg);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, black var(--fade-l, 0px), black calc(100% - var(--fade-r, 0px)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, black var(--fade-l, 0px), black calc(100% - var(--fade-r, 0px)), transparent 100%);
}
.info-tabs::-webkit-scrollbar {
  display: none;
}
.info-tabs.has-more-right {
  --fade-r: 44px;
}
.info-tabs.has-more-left {
  --fade-l: 44px;
}
.info-tab {
  flex: 1 0 auto;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-1) ease,
    color var(--dur-1) ease;
}
.info-tab:hover {
  color: var(--text);
}
.info-tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.info-tab[aria-selected="true"] {
  background: var(--segmented-thumb);
  box-shadow: var(--segmented-thumb-shadow);
  color: var(--text);
}
.info-gallery {
  padding: 4px 16px;
}
.info-gallery__month {
  margin: 14px 16px 6px;
  color: var(--text-2);
  font-size: var(--type-footnote);
  font-weight: var(--fw-regular);
}
.info-gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.info-gallery__grid .media {
  aspect-ratio: 1;
  border-radius: 8px;
}
.info-gallery__list {
  display: grid;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--card-ring);
}
.info-gallery__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: auto;
  margin: 0;
  padding: 9px 14px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.info-gallery__item + .info-gallery__item::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 14px;
  height: 0.5px;
  background: var(--line);
}
@media (hover: hover) {
  .info-gallery__item:hover {
    background: var(--fill-1);
  }
}
.info-gallery__empty {
  padding: 32px 16px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  text-align: center;
  text-wrap: pretty;
}
.info__danger {
  color: var(--danger-ink);
}
.info-skeleton {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 20px;
}
.info-skeleton .skeleton--circle {
  --size: 88px;
}
.info-skeleton .skeleton--title {
  width: 55%;
}
.info-skeleton > .skeleton--text {
  width: 70%;
}
.info-skeleton > .skeleton--text:nth-of-type(2) {
  width: 30%;
}
.info-skeleton__quick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin: 6px 0 8px;
}
.info-skeleton__quick .skeleton {
  height: 58px;
  border-radius: var(--radius-lg);
}

/* Wallpaper swatches (Chat settings) */
.wall-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  padding: 8px;
}
.wall-swatch {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-md);
  background:
    radial-gradient(70% 55% at 12% 0%, var(--wall-glow-1), transparent 72%),
    radial-gradient(60% 50% at 95% 100%, var(--wall-glow-2), transparent 72%),
    var(--wall-base);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--dur-1) ease;
}
.wall-swatch::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--wall-ink);
  -webkit-mask-image: var(--wall-pattern);
  mask-image: var(--wall-pattern);
  -webkit-mask-size: calc(var(--wall-size, 240px) / 2.5);
  mask-size: calc(var(--wall-size, 240px) / 2.5);
}
.wall-swatch__label {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  overflow: hidden;
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wall-swatch[aria-pressed="true"] {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--accent);
}
.wall-swatch:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* Forward picker / new chat / members (r4 · 12.25): a search capsule over an inset grouped list —
   36 px avatars, hairlines inset to the text, multi-select as a round check on the left. */
.pick-list {
  display: grid;
  max-height: min(56vh, 460px);
  margin: 10px 0 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--card-ring);
}
.pick-list:not(:has(.pick-item)) {
  background: none;
  box-shadow: none;
}
.pick-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 14px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pick-item + .pick-item::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 62px;
  height: 0.5px;
  background: var(--line);
}
.pick-item:has(> input[type="checkbox"]) + .pick-item::before {
  left: 96px;
}
@media (hover: hover) {
  .pick-item:hover {
    background: var(--fill-1);
  }
}
.pick-item:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: -2px;
}
.pick-item .chat-avatar--sm,
.pick-item > .avatar {
  --size: 36px;
  width: 36px;
  height: 36px;
}
/* Multi-select: the 9.7 check-circle look on the native checkbox, moved to the left. */
.pick-item > input[type="checkbox"] {
  order: -1;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid var(--text-3);
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}
.pick-item > input[type="checkbox"]::before {
  width: 12px;
  height: 12px;
}
.pick-item > input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}
.pick-item > input[type="checkbox"]:disabled:not(:checked) {
  opacity: 0.4;
}
.pick-item__body {
  display: grid;
  flex: 1;
  min-width: 0;
}
.pick-item__title {
  overflow: hidden;
  font-size: var(--type-body);
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-item__sub {
  overflow: hidden;
  color: var(--text-2);
  font-size: var(--type-footnote);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Global search results (list pane) and starred messages */
.chat-results {
  display: grid;
  gap: 2px;
}
.chat-results[hidden] {
  display: none;
}
.chat-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-lg);
  color: inherit;
  text-decoration: none;
}
.chat-result:hover,
.chat-result:focus-visible {
  background: var(--fill-1);
  outline: none;
}
.chat-result:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}
.chat-result__main {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.chat-result__top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.chat-result__top time {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
}
.chat-result__ctx {
  display: block;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-result__hit {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.chat-result__hit mark {
  border-radius: 3px;
  background: color-mix(in srgb, var(--c-yellow) 45%, transparent);
  color: inherit;
}
.chat-results .chat-list-empty {
  padding: 32px 16px;
}

/* Starred messages (r4 · 12.25): each hit reads as the bubble it came from. */
.chat-starred .chat-result {
  align-items: end;
}
.chat-starred .chat-result__main {
  gap: 4px;
}
.chat-starred .chat-result__top {
  padding-inline: 12px;
  color: var(--text-2);
  font-size: var(--type-footnote);
  font-weight: var(--fw-medium);
}
/* Transparent borders instead of padding: the 3-line clamp then never peeks into the padding. */
.chat-starred .chat-result__hit {
  justify-self: start;
  max-width: 100%;
  padding: 0;
  border: solid transparent;
  border-width: 7px 12px 8px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: var(--surface);
  box-shadow: 0 0 0 0.5px var(--card-ring);
  font-size: var(--type-body);
}

/* Selection toolbar */
.select-bar {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.composer.is-selecting .composer__row,
.composer.is-selecting .composer__ctx,
.composer.is-selecting .tray {
  display: none;
}
.composer.is-selecting .select-bar {
  display: flex;
}
.select-bar__count {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 479px) {
  .select-bar .btn span {
    display: none;
  }
  .select-bar .btn {
    width: var(--control-h);
    padding: 0;
  }
}

/* Skeleton while a conversation loads (the pane shell keeps the real header in place) */
.conv-skeleton {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  min-height: 0;
  padding: calc(var(--chat-head-h) + var(--safe-top) + 16px) clamp(14px, 3.5%, 56px) calc(var(--composer-h, 64px) + 14px);
  overflow: hidden;
}
.conv-skeleton i {
  flex-shrink: 0;
  height: 38px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bubble-in) 70%, transparent);
}
.conv-skeleton i:nth-child(odd) {
  width: min(58%, 380px);
}
.conv-skeleton i:nth-child(even) {
  align-self: flex-end;
  width: min(42%, 280px);
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}
.conv-skeleton i:nth-child(3n) {
  height: 58px;
}
@media (prefers-reduced-motion: no-preference) {
  .conv-skeleton i {
    animation: chat-pulse 1.4s ease-in-out infinite;
  }
  .conv-skeleton i:nth-child(2n) {
    animation-delay: 0.15s;
  }
}
.conv-pane.is-shell .composer {
  pointer-events: none;
}

/* View transition: shared avatar (list → header) */
::view-transition-group(chat-avatar) {
  animation-duration: 340ms;
  animation-timing-function: var(--ease-sheet);
}

/* Screen-reader announcements (new messages) */
.chat-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* -- Keyframes ------------------------------------------------------------------------------------- */
@keyframes chat-send {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.9);
  }
  55% {
    opacity: 1;
  }
  100% {
    transform: none;
  }
}
@keyframes chat-receive {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes chat-fade {
  from {
    opacity: 0;
  }
}
@keyframes chat-pop {
  0% {
    transform: scale(0);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes chat-pop-centered {
  0% {
    transform: translateX(-50%) scale(0.4);
  }
  60% {
    transform: translateX(-50%) scale(1.2);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}
@keyframes chat-emoji-in {
  0% {
    transform: scale(0.3) rotate(-12deg);
  }
  60% {
    transform: scale(1.15) rotate(4deg);
  }
  100% {
    transform: none;
  }
}
@keyframes chat-emoji-bounce {
  0%,
  100% {
    transform: none;
  }
  40% {
    transform: scale(1.4) translateY(-2px);
  }
}
@keyframes chat-roll-up {
  from {
    transform: translateY(100%);
  }
}
@keyframes chat-roll-down {
  from {
    transform: translateY(-100%);
  }
}
@keyframes chat-burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.4);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot));
  }
}
@keyframes chat-highlight {
  0%,
  30% {
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent),
      var(--bubble-shadow);
    transform: scale(1.02);
  }
  100% {
    box-shadow: var(--bubble-shadow);
    transform: none;
  }
}
@keyframes chat-typing {
  0%,
  60%,
  100% {
    opacity: 0.45;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
@keyframes chat-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}
@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes chat-tick-read {
  35% {
    transform: scale(1.2);
  }
}
@keyframes chat-blink {
  50% {
    opacity: 0.25;
  }
}
@keyframes chat-shimmer {
  to {
    background-position: -300% 0;
  }
}
@keyframes chat-nudge-up {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
@keyframes chat-menu-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
}
@keyframes chat-row-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@keyframes chat-status-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
@keyframes chat-pin-roll {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes chat-pulse {
  50% {
    opacity: 0.5;
  }
}
/* Upload ring progress (namespaced: a global --p registration broke other features' --p). */
@property --chat-p {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

/* ==================================================================================================
   Empty pane card (r3 alignment, kept in r4): a flat surface card instead of glass.
   ================================================================================================== */
.chat-empty__card {
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow:
    0 0 0 1px var(--card-ring),
    var(--shadow-sm);
}
.chat-empty__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
}
.chat-empty__text {
  font-size: var(--fs-sm);
}

/* -- Saved messages (Telegram "Saved Messages", WhatsApp "Message yourself") — saved-ui ----------
   The avatar is a filled bookmark on the accent tile (follows data-accent; the glyph is sized in %
   so it stays crisp at 28 · 36/38 · 52 · 88 px). The empty chat shows a centred intro card; a
   message saved from another chat gets Telegram's round "go to original" button beside it. */
.chat-avatar__tile--saved {
  background: linear-gradient(160deg, color-mix(in oklab, var(--accent) 74%, white), color-mix(in oklab, var(--accent) 92%, black));
  color: var(--text-on-accent);
}
.chat-avatar__saved {
  width: 46%;
  height: 46%;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 0.5px 0.5px rgb(0 0 0 / 0.18));
}
/* Selected row (accent background): invert so the tile doesn't melt into the row. */
.conv[aria-current="page"] .chat-avatar__tile--saved {
  background: var(--text-on-accent);
  color: var(--accent);
}
.conv[aria-current="page"] .chat-avatar__saved {
  filter: none;
}
@media (max-width: 767px) {
  .conv[aria-current="page"] .chat-avatar__tile--saved {
    background: linear-gradient(160deg, color-mix(in oklab, var(--accent) 74%, white), color-mix(in oklab, var(--accent) 92%, black));
    color: var(--text-on-accent);
  }
}
.palette__saved {
  --tone-solid: var(--accent);
  color: var(--text-on-accent);
}

/* Intro card of an empty "Saved messages" — centred in the pane, readable on every wallpaper. */
.conv-pane[data-kind="saved"]:not(.is-empty) .saved-intro {
  display: none;
}
.conv-pane[data-kind="saved"].is-empty .timeline__inner {
  justify-content: center;
}
.saved-intro.timeline__start {
  gap: 6px;
  width: min(100%, 360px);
  max-width: none;
  margin: 12px auto;
  padding: 26px 22px 22px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-2xl);
}
.saved-intro .chat-avatar {
  --size: 72px;
  margin-bottom: 6px;
}
.saved-intro__title {
  font-size: var(--fs-title-3);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}
.saved-intro__lead {
  color: var(--text-2);
}
.saved-intro__list {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 14px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  text-align: start;
}
.saved-intro__list li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--text);
  line-height: 1.35;
}
.saved-intro__list .icon {
  justify-self: center;
  box-sizing: content-box;
  padding: 6.5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent-ink);
}
@media (prefers-reduced-motion: no-preference) {
  .conv-pane[data-kind="saved"].is-empty .saved-intro {
    animation: saved-intro-in var(--dur-4) var(--ease-out) both;
  }
  @keyframes saved-intro-in {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.98);
    }
  }
}

/* "Go to original" — a round glass button beside a saved forward (Telegram). Always visible: it is
   the only way back to the source on touch; keyboard reachable (a link). */
.msg__origin {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  align-self: flex-end;
  width: 30px;
  height: 30px;
  margin: 0 2px 2px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    background-color var(--dur-1) ease,
    transform var(--dur-1) ease;
}
.msg__origin:hover {
  background: var(--surface);
}
.msg__origin:active {
  transform: scale(0.92);
}
.msg__origin:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.timeline.is-selecting .msg__origin {
  visibility: hidden;
}

/* A message that failed to send: ⚠ in its list row instead of the 🕓. */
.conv__failed {
  display: inline-flex;
  flex-shrink: 0;
  vertical-align: -2px;
  margin-inline-end: 3px;
  color: var(--danger-ink);
}
.conv[aria-current="page"] .conv__failed {
  color: var(--text-on-accent);
}

/* Info panel of "Saved messages" */
.info__hero .info__private {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.info__note {
  margin: 0 20px 16px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.45;
  text-align: center;
  text-wrap: pretty;
}

/* With a chat open, toasts ("Saved to Saved messages", errors…) sit above the composer. */
@media (min-width: 768px) {
  :root:has(.chat-app[data-has-conv]) .toast-root.toast-root {
    bottom: calc(var(--composer-h, 64px) + var(--safe-bottom) + 12px);
  }
}
@media (max-width: 767px) {
  :root:has(.chat-app[data-view="conversation"]) .toast-root.toast-root {
    bottom: calc(var(--composer-h, 64px) + var(--safe-bottom) + 14px);
  }
}

/* -- Reduced transparency (r4 · 0.2 rule 6): the few hand-made blurs go opaque like the materials. */
:root[data-transparency="reduced"] :is(.lift__scrim, .msg__actions button, .msg__swipe, .media__play, .msg__origin, .conv-pane .dropzone, .bubble.is-media-only .bubble__meta) {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
:root[data-transparency="reduced"] .lift__scrim {
  background: var(--scrim);
}
:root[data-transparency="reduced"] .bubble.is-media-only .bubble__meta {
  background: rgb(0 0 0 / 0.62);
}
@media (prefers-reduced-transparency: reduce) {
  :is(.lift__scrim, .msg__actions button, .msg__swipe, .media__play, .msg__origin, .conv-pane .dropzone, .bubble.is-media-only .bubble__meta) {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .lift__scrim {
    background: var(--scrim);
  }
  .bubble.is-media-only .bubble__meta {
    background: rgb(0 0 0 / 0.62);
  }
}

/* ==================================================================================================
   Polls (WhatsApp) — contract §13. The poll body lives in the bubble (.bubble.has-poll > .poll):
   question · hint · option rows (round radio / checkbox circle + text + voters + count, a thin bar
   = share of the people who voted) · total · "View votes". Mine = accent; on my own (accent)
   bubble everything is white on the gradient. Bars animate with transform only.
   ================================================================================================== */
.chat-app,
.chat-tokens {
  --poll-w: 330px;
  --poll-mark: 22px;
  --poll-track: var(--fill-3);
  --poll-fill: var(--accent);
  --poll-mark-line: color-mix(in srgb, var(--text) 34%, transparent);
  --poll-hint: var(--bubble-in-meta);
  --poll-line: color-mix(in srgb, var(--text) 12%, transparent);
}
.msg:has(> .msg__col > .bubble.has-poll) .msg__col {
  width: 100%;
  max-width: min(var(--poll-w), calc(100% - 8px));
}
.msg.is-in:has(> .msg__col > .bubble.has-poll) .msg__col {
  max-width: min(var(--poll-w), calc(100% - 44px));
}
.bubble.has-poll {
  width: 100%;
  padding: 10px 12px 0;
}
.bubble.has-poll > .bubble__meta {
  bottom: 54px;
}
.poll {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.poll__q {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: 1.32;
  text-wrap: pretty;
}
.poll__hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 3px 0 8px;
  color: var(--poll-hint);
  font-size: var(--fs-xs);
}
.poll__hint .icon {
  flex: none;
  width: 13px;
  height: 13px;
}
.poll.is-closed .poll__hint {
  font-weight: var(--fw-medium);
}
.poll__options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.poll-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: calc(100% + 12px);
  margin: 0 -6px;
  padding: 7px 6px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.poll-opt:hover:not([aria-disabled="true"]) {
  background: color-mix(in srgb, currentColor 6%, transparent);
}
.poll-opt:active:not([aria-disabled="true"]) {
  background: color-mix(in srgb, currentColor 11%, transparent);
}
.poll-opt:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
}
.poll-opt[aria-disabled="true"] {
  cursor: default;
}
.poll-opt__mark {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: var(--poll-mark);
  height: var(--poll-mark);
  margin-top: 1px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.75px var(--poll-mark-line);
  color: var(--text-on-accent);
}
.poll-opt__mark svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
}
.poll-opt.is-mine .poll-opt__mark {
  background: var(--poll-fill);
  box-shadow: none;
}
.poll-opt.is-mine .poll-opt__mark svg {
  stroke-dashoffset: 0;
}
.poll.is-closed .poll-opt:not(.is-mine) .poll-opt__mark {
  opacity: 0.5;
}
.poll-opt__main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.poll-opt__line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}
.poll-opt__text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.poll-opt__voters {
  display: inline-flex;
  flex: none;
}
.poll-opt__voters:empty {
  display: none;
}
.poll-opt__voters .avatar {
  --size: 18px;
  font-size: 8px;
}
.poll-opt__voters .avatar + .avatar {
  margin-inline-start: -5px;
}
.msg.is-in .poll-opt__voters .avatar {
  box-shadow: 0 0 0 1.5px var(--bubble-in);
}
.msg.is-out .poll-opt__voters .avatar {
  box-shadow: 0 0 0 1.5px var(--bubble-out-2);
}
.poll-opt__count {
  flex: none;
  min-width: 1ch;
  color: var(--poll-hint);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-align: end;
}
.poll-opt.is-mine .poll-opt__count {
  color: inherit;
  font-weight: var(--fw-semibold);
}
.poll-opt__bar {
  position: relative;
  display: block;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--poll-track);
  overflow: hidden;
}
.poll-opt__bar > i {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--poll-fill);
  opacity: 0.55;
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
}
[dir="rtl"] .poll-opt__bar > i {
  transform-origin: right center;
}
.poll-opt.is-mine .poll-opt__bar > i {
  opacity: 1;
}
.poll__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  margin: 4px 0 8px;
  color: var(--poll-hint);
  font-size: var(--fs-xs);
}
.poll__view {
  display: block;
  width: calc(100% + 24px);
  height: 46px;
  margin: 0 -12px;
  border: 0;
  border-top: 0.5px solid var(--poll-line);
  border-radius: 0 0 var(--bubble-radius) var(--bubble-radius);
  background: transparent;
  color: var(--accent-ink);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}
.poll__view:hover {
  background: color-mix(in srgb, currentColor 6%, transparent);
}
.poll__view:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.msg.is-in:not(.is-last) .bubble.has-poll .poll__view {
  border-bottom-left-radius: var(--bubble-joint);
}
.msg.is-out:not(.is-last) .bubble.has-poll .poll__view {
  border-bottom-right-radius: var(--bubble-joint);
}
/* My own bubble: white on the accent gradient. */
.msg.is-out .bubble.has-poll {
  --poll-track: rgb(255 255 255 / 0.28);
  --poll-fill: #fff;
  --poll-mark-line: rgb(255 255 255 / 0.78);
  --poll-hint: var(--bubble-out-meta);
  --poll-line: rgb(255 255 255 / 0.26);
}
.msg.is-out .poll-opt.is-mine .poll-opt__mark {
  color: color-mix(in oklab, var(--accent) 82%, black);
}
.msg.is-out .poll__view {
  color: #fff;
}
@media (prefers-reduced-motion: no-preference) {
  .poll-opt {
    transition: background-color var(--dur-1) ease;
  }
  .poll-opt__bar > i {
    transition:
      transform var(--dur-smooth) var(--ease-spring-soft),
      opacity var(--dur-2) ease;
  }
  .poll-opt__mark {
    transition:
      background-color var(--dur-2) ease,
      box-shadow var(--dur-2) ease;
  }
  .poll-opt__mark svg {
    transition: stroke-dashoffset var(--dur-3) var(--ease-out) 40ms;
  }
  .poll-opt.is-popped .poll-opt__mark {
    animation: chat-poll-pop var(--dur-snappy) var(--ease-spring);
  }
  .poll-opt__count.is-rolling-up {
    animation: chat-roll-up var(--dur-3) var(--ease-out);
  }
  .poll-opt__count.is-rolling-down {
    animation: chat-roll-down var(--dur-3) var(--ease-out);
  }
}
@keyframes chat-poll-pop {
  0% {
    transform: scale(0.82);
  }
  55% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

/* Decision of a discussion: a centred card in the timeline (a pinned system line). */
.system-msg.decision-msg {
  margin: 14px 0;
}
.decision-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: min(88%, 460px);
  padding: 12px 18px;
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--c-green) 12%, var(--wall-solid));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--c-green) 32%, transparent),
    var(--shadow-xs);
  color: var(--text);
  text-align: center;
}
.decision-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--c-green-ink);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.decision-card__text {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.42;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.decision-card__by {
  color: var(--text-2);
  font-size: var(--fs-2xs);
}

/* Discussion sub-header in the conversation pane: a glass strip under the header (like the
   pinned bar, which moves below it). */
.conv-pane.has-discussion {
  --disc-h: 44px;
}
.discussion-bar {
  position: absolute;
  top: calc(var(--chat-head-h) + var(--safe-top));
  right: 0;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px 12px;
  height: var(--disc-h, 44px);
  padding: 0 10px 0 max(14px, var(--safe-left));
  background: var(--mat-chrome);
  -webkit-backdrop-filter: var(--mat-filter);
  backdrop-filter: var(--mat-filter);
  box-shadow: 0 0.5px 0 var(--line);
}
.discussion-bar.is-decided {
  background: color-mix(in srgb, var(--c-green) 10%, var(--mat-chrome));
}
.conv-pane > .discussion-bar {
  position: absolute;
  z-index: 5;
}
.conv-pane.has-discussion .conv-pinned {
  top: calc(var(--chat-head-h) + var(--safe-top) + var(--disc-h));
}
.conv-pane.has-discussion .timeline__inner {
  padding-top: calc(var(--chat-head-h) + var(--safe-top) + var(--disc-h) + 10px);
}
.conv-pane.has-discussion.has-pinned .timeline__inner {
  padding-top: calc(var(--chat-head-h) + var(--safe-top) + var(--disc-h) + 58px);
}
.conv-pane.has-discussion .day__sep {
  top: calc(var(--chat-head-h) + var(--safe-top) + var(--disc-h) + 8px);
}
.conv-pane.has-discussion.has-pinned .day__sep {
  top: calc(var(--chat-head-h) + var(--safe-top) + var(--disc-h) + 56px);
}
.discussion-bar__main {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.discussion-bar__project {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 40%;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
}
.discussion-bar__project:hover {
  color: var(--text);
}
.discussion-bar__project-name,
.discussion-bar__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discussion-bar__text {
  flex: 1 1 0;
  min-width: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.discussion-bar__actions {
  display: flex;
  flex: none;
  gap: 6px;
}
@media (max-width: 639px) {
  .discussion-bar {
    padding-inline: 12px 6px;
  }
  .discussion-bar__text {
    display: none;
  }
  .discussion-bar__project {
    max-width: 55%;
  }
  .discussion-bar__actions .btn:not(.discussion-bar__decide) .btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
.discussion-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
}
.discussion-pill.is-decided {
  background: color-mix(in srgb, var(--c-green) 16%, transparent);
  color: var(--c-green-ink);
}

/* List rows: a discussion's project is the first line under its name (an attribute, so live
   preview updates keep it), a ✓ beside the name once decided. */
.conv__preview[data-project] {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}
.conv[aria-current="page"] .conv__preview[data-project]::before {
  color: inherit;
  opacity: 0.78;
}
.conv__preview[data-project]::before {
  content: attr(data-project);
  display: block;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv__decided {
  display: inline-flex;
  flex: none;
  color: var(--c-green-ink);
}
.conv__decided .icon {
  width: 13px;
  height: 13px;
}

/* -- "Create poll" sheet (poll_builder.html; also inside "Start a discussion") ----------------- */
.poll-builder {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.poll-builder .field {
  margin: 0;
}
.poll-builder__question {
  min-height: 44px;
  font-size: var(--fs-md);
  resize: none;
}
.poll-builder__options {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.poll-builder__list {
  display: flex;
  flex-direction: column;
  margin: 6px 0 0;
  padding: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  list-style: none;
  overflow: hidden;
}
.poll-builder__row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 0 6px 0 4px;
  background: var(--surface);
}
.poll-builder__row + .poll-builder__row {
  box-shadow: 0 -0.5px 0 var(--line);
}
.poll-builder__row.is-ghost {
  opacity: 0.4;
}
.poll-builder__row:focus-within {
  box-shadow: inset 3px 0 0 var(--accent);
}
.poll-builder__grip {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 36px;
  color: var(--text-3);
  cursor: grab;
  touch-action: none;
}
.poll-builder__row.is-empty .poll-builder__grip {
  visibility: hidden;
}
.poll-builder__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
}
.poll-builder__input::placeholder {
  color: var(--text-3);
}
.poll-builder__input:focus {
  outline: none;
}
.poll-builder__row.is-dup .poll-builder__input {
  color: var(--danger);
}
.poll-builder__remove {
  flex: none;
  color: var(--text-3);
}
.poll-builder__hint {
  margin: 6px 2px 0;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.poll-builder__hint:empty {
  display: none;
}
.poll-builder__toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.poll-builder__toggle-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  font-weight: var(--fw-medium);
}
.poll-builder__toggle-sub {
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
}
.poll-builder__toggle .switch {
  flex: none;
}

/* -- "View votes" ------------------------------------------------------------------------------- */
.poll-votes__question {
  margin: 0 0 12px;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.poll-votes__options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.poll-votes__option {
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.poll-votes__option.is-empty .poll-votes__head {
  opacity: 0.55;
}
.poll-votes__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.poll-votes__text {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: var(--fw-semibold);
  overflow-wrap: anywhere;
}
.poll-votes__count {
  flex: none;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.poll-votes__people {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.poll-votes__person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}
.poll-votes__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poll-votes__you,
.poll-votes__time,
.poll-votes__none {
  color: var(--text-3);
}
.poll-votes__time {
  flex: none;
  font-size: var(--fs-xs);
}
.poll-votes__none {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
  opacity: 0.8;
}

/* ==================================================================================================
   Project "Discussions" tab (chat:discussions) — contract §14. Scoped under .discussions.
   ================================================================================================== */
.discussions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding-bottom: 32px;
}
.discussions__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
}
.discussions__intro {
  min-width: 0;
}
.discussions__title {
  margin: 0;
  font-size: var(--fs-title-3);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
}
.discussions__lead {
  margin: 2px 0 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-wrap: pretty;
}
.discussions__filter {
  flex: none;
}
.discussions__n {
  margin-inline-start: 6px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.discussions__list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--line),
    var(--shadow-xs);
  list-style: none;
  overflow: hidden;
}
.discussion-row + .discussion-row {
  box-shadow: 0 -0.5px 0 var(--line);
}
.discussion-row__link {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
}
.discussion-row__link:hover {
  background: var(--fill-1);
}
.discussion-row__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.discussion-row__tile {
  flex: none;
  margin-top: 2px;
}
.discussion-row__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.discussion-row__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.discussion-row__title {
  min-width: 0;
  overflow: hidden;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discussion-row.is-unread .discussion-row__title {
  font-weight: var(--fw-bold);
}
.discussion-row__desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.4;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.discussion-row__preview {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.discussion-row__preview .icon {
  flex: none;
  align-self: center;
}
.discussion-row__preview-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discussion-row__sender {
  flex: none;
  color: var(--text);
  font-weight: var(--fw-medium);
}
.discussion-row__time {
  flex: none;
  margin-inline-start: auto;
  padding-inline-start: 8px;
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.discussion-row__decision {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--c-green) 11%, transparent);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.discussion-row__decision .icon {
  flex: none;
  margin-top: 2px;
  color: var(--c-green-ink);
}
.discussion-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 2px;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.discussion-row__people {
  display: inline-flex;
}
.discussion-row__poll {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--c-orange) 14%, transparent);
  color: var(--c-orange-ink);
  font-weight: var(--fw-medium);
}
.discussion-row__end {
  display: flex;
  flex: none;
  align-items: center;
  align-self: center;
  gap: 6px;
}
.discussion-row__chevron {
  color: var(--text-3);
}
.discussion-row .conv__badge {
  position: static;
}
@media (max-width: 639px) {
  .discussions__head {
    flex-direction: column;
    align-items: stretch;
  }
  .discussions__filter {
    width: 100%;
  }
  .discussions__filter .segmented__item {
    flex: 1 1 0;
    justify-content: center;
  }
  .discussion-row__link {
    gap: 12px;
    padding: 12px;
  }
  .discussion-row__chevron {
    display: none;
  }
}
.discussions__empty {
  padding: 12px 0;
}
.discussions-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 540px;
  margin: 0 auto;
  padding: 32px 20px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px var(--line),
    var(--shadow-xs);
  text-align: center;
}
.discussions-hero__art {
  position: relative;
  width: 168px;
  height: 104px;
  margin-bottom: 16px;
}
.discussions-hero__bubble {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.discussions-hero__bubble.is-a {
  top: 8px;
  left: 0;
  width: 56px;
  height: 44px;
  border-bottom-left-radius: 6px;
  background: var(--accent);
  color: var(--text-on-accent);
}
.discussions-hero__bubble.is-b {
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  width: 104px;
  height: 72px;
  padding: 0 14px;
  border-bottom-right-radius: 6px;
  background: var(--surface-elevated);
  box-shadow:
    inset 0 0 0 1px var(--line),
    var(--shadow-sm);
}
.discussions-hero__bar {
  display: block;
  width: var(--w);
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--c-orange);
}
.discussions-hero__bar + .discussions-hero__bar {
  opacity: 0.6;
}
.discussions-hero__bar + .discussions-hero__bar + .discussions-hero__bar {
  opacity: 0.35;
}
.discussions-hero__bubble.is-c {
  bottom: 0;
  left: 46px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-green);
  color: #fff;
}
.discussions-hero__title {
  margin: 0;
  font-size: var(--fs-title-2);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
}
.discussions-hero__text {
  margin: 8px 0 16px;
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: 1.5;
  text-wrap: pretty;
}
.discussions-hero__steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  text-align: start;
}
.discussions-hero__steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
}
.discussions-hero__note {
  margin: 0;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
@media (prefers-reduced-motion: no-preference) {
  .discussions-hero__bubble {
    animation: chat-float 6s ease-in-out infinite;
  }
  .discussions-hero__bubble.is-b {
    animation-delay: -2s;
  }
  .discussions-hero__bubble.is-c {
    animation-delay: -4s;
  }
}

/* Project overview card. */
.discussions-card__count {
  margin: 0 0 8px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.discussions-card__count strong {
  color: var(--text);
  font-size: var(--fs-lg);
}
.discussions-card__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.discussions-card__item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin: 0 -8px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.discussions-card__item:hover {
  background: var(--fill-1);
}
.discussions-card__item .icon {
  flex: none;
  color: var(--text-3);
}
.discussions-card__item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discussion-row .conv__badge:not(.conv__badge--mention) {
  background: var(--accent);
  color: var(--text-on-accent);
}

/* Poll sheet / Start a discussion: the main button stays clickable while the form is incomplete
   (the server explains what's missing under the field) — it only looks quieter. */
:is(.poll-modal, .discussion-modal) .btn--primary.is-incomplete {
  opacity: 0.55;
  box-shadow: none;
}
