/* ==========================================================================
   Chat — the centrepiece. Header, message list, bubbles, composer.
   ========================================================================== */

/* ---------------------------------------------------------------- Header */
.ch {
  position: relative; z-index: 3;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3);
  min-height: calc(var(--header-h) + var(--safe-t));
  padding: calc(var(--safe-t) + 10px) var(--s3) 12px var(--s4);
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.5) blur(18px);
  -webkit-backdrop-filter: saturate(1.5) blur(18px);
  border-bottom: 1px solid color-mix(in oklab, var(--line) 55%, transparent);
  box-shadow: 0 8px 24px -18px rgba(28, 24, 16, 0.18);
  flex-shrink: 0;
}
.ch .ch__back { display: none; margin-left: -6px; }
.ch .ch__sbtoggle { display: none; }
.ch__id {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: var(--s3);
  text-align: left; padding: 4px; margin: -4px; border-radius: var(--r-md);
}
.ch__id .avatar { width: 40px; height: 40px; font-size: 13px; border-radius: 14px; }
.ch__text { min-width: 0; display: grid; }
.ch__name {
  font-weight: 750; font-size: var(--fs-lg); letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch__sub {
  position: relative; height: 18px; overflow: hidden;
  font-size: var(--fs-sm); color: var(--text-3); font-weight: 500;
}
.ch__sub > span {
  position: absolute; inset: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity var(--motion-normal) var(--ease-standard), transform var(--motion-normal) var(--ease-standard);
}
.ch__sub .sub-presence { color: var(--accent-text); font-weight: 600; opacity: 0; transform: translateY(6px); }
.ch__sub.is-live .sub-default { opacity: 0; transform: translateY(-6px); }
.ch__sub.is-live .sub-presence { opacity: 1; transform: none; }
.ch__actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ch__actions .ibtn {
  width: 34px; height: 34px;
  background: color-mix(in oklab, var(--surface-2) 90%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
}
.ch__chips {
  display: flex; align-items: center; gap: 8px;
  width: 100%; overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 0; -webkit-overflow-scrolling: touch;
}
.ch__chips::-webkit-scrollbar { display: none; }
.ch-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px; border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  box-shadow: inset 0 0 0 1px var(--line), var(--sh-1);
  color: var(--text-2); font-size: 11px; font-weight: 650;
  white-space: nowrap; flex-shrink: 0;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.ch-chip:hover { background: var(--surface); color: var(--text); }
.ch-chip svg { width: 14px; height: 14px; color: var(--accent-text); }
.ch-chip--status {
  background: color-mix(in oklab, var(--warn-soft) 80%, white);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warn) 22%, transparent);
  color: var(--text);
}
.ch-chip--tasks b { color: var(--text); font-weight: 800; }
.ch-chip--tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.ch-chip:empty { display: none; }

/* Search bar */
.ch-search {
  max-height: 0; overflow: hidden;
  background: var(--surface); border-bottom: 1px solid transparent;
  transition: max-height var(--motion-smooth) var(--ease-standard), border-color var(--motion-smooth);
  flex-shrink: 0; position: relative; z-index: 2;
}
.ch-search.is-open { max-height: 64px; border-bottom-color: var(--line); }
.ch-search__row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3) var(--s2) var(--s4); }
.ch-search__row .field { flex: 1; }
.ch-search__count { font-size: var(--fs-sm); color: var(--text-3); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

/* Selection bar (replaces header contents) */
.ch-select {
  position: absolute; inset: 0; z-index: 4;
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--safe-t) var(--s3) 0 var(--s3);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity var(--motion-normal) var(--ease-standard), transform var(--motion-normal) var(--ease-standard);
}
.chat.is-selecting .ch-select { opacity: 1; transform: none; pointer-events: auto; }
.ch-select__count { flex: 1; font-weight: 600; }

/* ---------------------------------------------------------------- Message list */
.msgs-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.msgs {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--s5) 0 28px;
  scroll-padding-bottom: 120px;
}
.msgs__inner { max-width: 880px; margin: 0 auto; padding: 0 var(--s5); }
.msgs__loader { height: 40px; display: grid; place-items: center; color: var(--text-3); font-size: var(--fs-sm); }

/* Row */
.row {
  position: relative;
  display: flex; align-items: flex-end; gap: var(--s2);
  margin-top: 14px;
  touch-action: pan-y;
}
.row.is-grouped { margin-top: 3px; }
.row--out { justify-content: flex-end; }
.row.has-reactions { margin-bottom: 18px; }
.row.has-reactions .bubble { padding-bottom: 24px; }
.row.has-reactions .bubble__meta { bottom: 18px; }
.row--enter { animation: msg-in var(--motion-smooth) var(--ease-emphasized) both; }
.row--out.row--enter { animation-name: msg-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes msg-out { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.row--leave { animation: msg-leave var(--motion-normal) var(--ease-exit) forwards; }
@keyframes msg-leave { to { opacity: 0; transform: translateY(4px); } }

.row__avatar { width: 30px; flex-shrink: 0; align-self: flex-end; }
.row__avatar .avatar { width: 30px; height: 30px; font-size: 11px; visibility: hidden; }
.row.is-last .row__avatar .avatar { visibility: visible; }
.row--out .row__avatar { display: none; }

.row__check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line-2); background: var(--surface);
  display: none; place-items: center; align-self: center; flex-shrink: 0;
  color: var(--accent-ink);
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.chat.is-selecting .row__check { display: grid; }
.chat.is-selecting .row--out .row__check { margin-right: auto; }
.row.is-selected .row__check { background: var(--accent); border-color: var(--accent); }
.row__check svg { width: 13px; height: 13px; opacity: 0; }
.row.is-selected .row__check svg { opacity: 1; }
.chat.is-selecting .row { cursor: pointer; }
.chat.is-selecting .row::after {
  content: ""; position: absolute; inset: -1px -20px; border-radius: 0; z-index: -1;
  background: transparent; transition: background var(--motion-fast);
}
.chat.is-selecting .row.is-selected::after { background: color-mix(in oklab, var(--accent) 9%, transparent); }

.bwrap {
  position: relative;
  max-width: min(82%, 560px);
  min-width: 0;
  display: flex; flex-direction: column;
}
.row.is-armed .bwrap, .row.is-swiping .bwrap { will-change: transform; }
.row--out .bwrap { align-items: flex-end; }

/* Swipe-to-reply affordance */
.row__swipe {
  position: absolute; left: 0; top: 50%;
  width: 32px; height: 32px; margin-top: -16px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2); box-shadow: var(--sh-1);
  opacity: 0; transform: scale(0.5);
  pointer-events: none;
}
.row__swipe svg { width: 16px; height: 16px; }
.row.is-armed .row__swipe { background: var(--accent); color: var(--accent-ink); }

/* Bubble */
.bubble {
  position: relative;
  padding: 12px 18px 16px 15px;
  border-radius: var(--r-bubble);
  background: var(--in);
  color: var(--in-ink);
  box-shadow: 0 0 0 1px var(--in-edge), var(--sh-bubble);
  font-size: var(--fs-base);
  line-height: 1.48;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: background var(--motion-smooth) var(--ease-standard), color var(--motion-smooth) var(--ease-standard), filter var(--motion-fast) var(--ease-standard), opacity var(--motion-fast);
}
/* Dedicated per-person tint — very subtle wash; name colour stays vivid */
.row--in .bubble.bubble--person {
  background: color-mix(in oklab, var(--person) 7%, var(--in));
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--person) 12%, transparent),
    var(--sh-bubble);
}
html[data-theme-mode="ember"] .row--in .bubble.bubble--person {
  background: color-mix(in oklab, var(--person) 8%, white);
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--person) 14%, transparent),
    var(--sh-bubble);
}
html[data-theme-mode="ember-night"] .row--in .bubble.bubble--person {
  background: color-mix(in oklab, var(--person) 9%, var(--in));
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--person) 16%, transparent),
    var(--sh-bubble);
}
.row--out .bubble {
  background: var(--out); color: var(--out-ink);
  box-shadow: 0 0 0 1px var(--out-edge), var(--sh-bubble);
}
html[data-theme-mode="ember"] .row--out .bubble,
html[data-theme-mode="ember-night"] .row--out .bubble {
  box-shadow: 0 0 0 1px color-mix(in oklab, white 10%, transparent), 0 16px 36px -8px color-mix(in oklab, var(--out) 55%, transparent);
}
/* Bubble geometry: tighten the corners that face neighbours in a group */
.row--in.is-grouped .bubble { border-top-left-radius: var(--r-bubble-tight); }
.row--in:not(.is-last) .bubble { border-bottom-left-radius: var(--r-bubble-tight); }
.row--out.is-grouped .bubble { border-top-right-radius: var(--r-bubble-tight); }
.row--out:not(.is-last) .bubble { border-bottom-right-radius: var(--r-bubble-tight); }
.row--in.is-first.is-last .bubble { border-bottom-left-radius: var(--r-bubble-tight); }
.row--out.is-first.is-last .bubble { border-bottom-right-radius: var(--r-bubble-tight); }

.row.is-pressed .bubble { filter: brightness(0.97); opacity: .96; }
.row.is-flash .bubble { animation: flash 1.4s var(--ease-standard); }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--focus); }
  100% { box-shadow: 0 0 0 1px var(--in-edge), var(--sh-bubble); }
}

.bubble__name {
  display: flex; align-items: baseline; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600; margin-bottom: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bubble__name small { font-weight: 500; color: var(--in-meta); font-size: var(--fs-xs); }
.bubble__fwd { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-style: italic; color: var(--in-meta); margin-bottom: 2px; }
.row--out .bubble__fwd { color: var(--out-meta); }

.bubble__text { white-space: pre-wrap; }
.bubble__text a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in oklab, currentColor 40%, transparent); text-underline-offset: 2px; }
.bubble__text mark { background: color-mix(in oklab, #f5c84b 55%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.bubble__text strong { font-weight: 750; }
.bubble__text .mention {
  display: inline-flex; align-items: center;
  padding: 1px 8px; margin: 0 1px; border-radius: 7px;
  font-size: 0.92em; font-weight: 750; line-height: 1.55;
  background: color-mix(in oklab, var(--warn-soft) 85%, white);
  color: color-mix(in oklab, var(--warn) 72%, black);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--warn) 22%, transparent);
  vertical-align: baseline;
}
.row--out .bubble__text .mention {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  color: color-mix(in oklab, var(--out-ink) 88%, var(--accent));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 28%, transparent);
}
.bubble__text.is-jumbo { font-size: 34px; line-height: 1.15; }
.bubble__text.is-deleted { font-style: italic; color: var(--in-meta); }
.row--out .bubble__text.is-deleted { color: var(--out-meta); }
.bubble__more { font-weight: 600; color: var(--accent-text); margin-left: 4px; }
.row--out .bubble__more { color: inherit; text-decoration: underline; }

/* Inline meta (time, ticks) — spacer + inset keep time clear of corner radius */
.bubble__spacer { display: inline-block; width: var(--meta-w, 64px); height: 1px; }
.bubble__meta {
  position: absolute; right: 14px; bottom: 8px;
  display: flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 500; line-height: 1;
  color: var(--in-meta);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.row--out .bubble__meta { color: var(--out-meta); }
.bubble__meta svg { width: 14px; height: 14px; }
.bubble__meta .tick { transition: color var(--motion-normal), opacity var(--motion-normal); }
.bubble__meta .tick.is-read { color: color-mix(in oklab, var(--accent) 80%, var(--out-ink)); }
.bubble__meta .imp { width: 11px; height: 11px; opacity: .8; }

/* System, date, unread */
.sys { display: flex; justify-content: center; margin: 14px 0; }
.sys__pill {
  max-width: 84%; text-align: center;
  padding: 5px 12px; border-radius: 10px;
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 500;
  box-shadow: 0 0 0 1px var(--line);
}
.datesep { display: flex; justify-content: center; margin: 18px 0 8px; pointer-events: none; }
.float-date {
  position: absolute; top: 10px; left: 50%; z-index: 3; pointer-events: none;
  opacity: 0; transform: translate(-50%, -6px);
  transition: opacity var(--motion-normal) var(--ease-standard), transform var(--motion-normal) var(--ease-standard);
}
.float-date.is-on { opacity: 1; transform: translate(-50%, 0); }
.datesep span, .float-date {
  padding: 5px 14px; border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px var(--line), var(--sh-1);
  color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.float-date { padding: 4px 12px; border-radius: 999px; }
.unread-sep { display: flex; align-items: center; gap: var(--s3); margin: 16px -20px 6px; color: var(--accent-text); font-size: var(--fs-xs); font-weight: 600; }
.unread-sep::before, .unread-sep::after { content: ""; flex: 1; height: 1px; background: var(--accent-line); }
.unread-sep span { padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); }

/* Reply quote */
.quote {
  position: relative; display: block; width: 100%;
  margin: 2px -4px 5px -6px; width: calc(100% + 10px);
  padding: 6px 10px 6px 12px;
  border-radius: 10px;
  background: var(--in-quote);
  text-align: left; overflow: hidden;
  transition: filter var(--motion-fast);
}
.quote::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--q-color, var(--accent)); }
.row--out .quote { background: var(--out-quote); }
.row--out .quote__name { color: color-mix(in oklab, var(--q-color, var(--accent)) 35%, var(--out-ink)); }
.row--in .quote__name { color: color-mix(in oklab, var(--q-color, var(--accent)) 78%, var(--in-ink)); }
.row--out .quote::before { background: color-mix(in oklab, var(--q-color, var(--accent)) 45%, var(--out-ink)); }
.quote:hover { filter: brightness(0.97); }
.quote__name { font-size: var(--fs-sm); font-weight: 600; color: var(--q-color, var(--accent-text)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote__text { font-size: var(--fs-sm); opacity: .78; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.quote__text svg { width: 13px; height: 13px; margin-right: 3px; vertical-align: -2px; }

/* Media */
.bubble--media { padding: 3px; }
.bubble--media .bubble__name { padding: 4px 8px 2px; }
.bubble--media .quote { margin: 0 0 3px; width: 100%; }
.bubble__img {
  position: relative; display: block; overflow: hidden;
  border-radius: 15px; background: var(--surface-3);
  width: min(300px, 62vw); aspect-ratio: var(--ar, 4 / 3); max-height: 360px;
}
.row:not(.is-first) .bubble--media .bubble__img,
.bubble--media .bubble__name + .bubble__img { border-top-left-radius: 12px; }
.bubble__img img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--motion-smooth); }
.bubble__img img.is-loaded { opacity: 1; }
.bubble__img--nocap::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 44px;
  background: linear-gradient(transparent, rgba(0,0,0,.32)); pointer-events: none;
}
.bubble--media .bubble__text { padding: 5px 8px 4px; }
.bubble--media .bubble__meta.on-img { color: #fff; right: 14px; bottom: 12px; z-index: 1; }
.bubble__omitted { display: flex; align-items: center; gap: 8px; color: var(--in-meta); font-style: italic; }
.row--out .bubble__omitted { color: var(--out-meta); }

/* Reactions — clipped onto the bubble edge; bubble padding clears message/time */
.reactions {
  position: absolute; bottom: -12px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 4px;
  max-width: min(100%, 260px);
  padding: 0 2px;
}
.row--in .reactions { left: 8px; justify-content: flex-start; }
.row--out .reactions { right: 8px; justify-content: flex-end; }
.rx {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  min-width: 28px; min-height: 26px; padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px var(--line-2), var(--sh-1);
  font-size: 12.5px; line-height: 1;
  transition: background var(--motion-fast), box-shadow var(--motion-fast), opacity var(--motion-fast);
}
.rx.is-new { animation: rx-pop var(--motion-smooth) var(--ease-emphasized); }
.rx:active { opacity: .88; }
.rx.is-mine { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-line); }
.rx__n { font-size: 10.5px; font-weight: 750; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rx__n.bump { animation: bump var(--motion-normal) var(--ease-emphasized); }
@keyframes bump { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes rx-pop {
  0% { opacity: 0; transform: translateY(5px) scale(.92); }
  70% { opacity: 1; transform: translateY(-1px) scale(1.04); }
  100% { opacity: 1; transform: none; }
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Hover tools (desktop only) */
.tools {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: flex; gap: 2px; padding: 3px;
  border-radius: 999px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--sh-2);
  opacity: 0; pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-standard);
}
.row--in .tools { left: calc(100% + 8px); transform: translate(-4px, -50%); }
.row--out .tools { right: calc(100% + 8px); transform: translate(4px, -50%); flex-direction: row-reverse; }
.tools button {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2);
  transition: background var(--motion-fast), color var(--motion-fast);
}
.tools button:hover { background: var(--surface-2); color: var(--text); }
.tools svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .row:hover .tools, .row.is-menu .tools { opacity: 1; pointer-events: auto; transform: translate(0, -50%); }
}
.chat.is-selecting .tools { display: none; }

/* Voice message */
.voice { display: flex; align-items: center; gap: 10px; padding: 3px 2px 14px 0; width: min(300px, 64vw); }
.voice__lead { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.voice__lead .avatar { width: 44px; height: 44px; font-size: 14px; transition: opacity var(--motion-normal), transform var(--motion-normal) var(--ease-standard); }
.voice__mic {
  position: absolute; right: -3px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--in); color: var(--accent);
}
.row--out .voice__mic { background: var(--out); }
.voice__mic svg { width: 12px; height: 12px; }
.voice__speed {
  position: absolute; inset: 6px 0; border-radius: 999px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: color-mix(in oklab, currentColor 12%, transparent);
  opacity: 0; transform: scale(.7);
  transition: opacity var(--motion-normal), transform var(--motion-normal) var(--ease-emphasized);
}
.voice.is-active .voice__lead .avatar, .voice.is-active .voice__mic { opacity: 0; transform: scale(.7); }
.voice.is-active .voice__speed { opacity: 1; transform: none; }
.voice__play {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  color: inherit;
  transition: transform var(--motion-fast) var(--ease-standard);
}
.voice__play:active { opacity: .85; }
.voice__play svg { width: 26px; height: 26px; }
.voice__body { flex: 1; min-width: 0; position: relative; }
.wave {
  position: relative; height: 30px; display: flex; align-items: center; gap: 2px;
  cursor: pointer; touch-action: none;
}
.wave span {
  flex: 1 1 0; min-width: 1.5px; max-width: 3px; border-radius: 2px;
  height: calc(var(--h) * 1%);
  background: color-mix(in oklab, currentColor 28%, transparent);
  transition: background var(--motion-fast);
}
.wave span.on { background: var(--accent); }
.row--out .wave span.on { background: color-mix(in oklab, var(--out-ink) 70%, var(--accent)); }
.wave__knob {
  position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--in);
  transition: transform var(--motion-fast);
}
.row--out .wave__knob { background: color-mix(in oklab, var(--out-ink) 70%, var(--accent)); box-shadow: 0 0 0 2px var(--out); }
.voice__dur { position: absolute; left: 0; bottom: -16px; font-size: 10.5px; font-weight: 500; color: var(--in-meta); font-variant-numeric: tabular-nums; }
.row--out .voice__dur { color: var(--out-meta); }
.voice.is-loading .wave span { animation: wave-load 1s ease-in-out infinite alternate; }
@keyframes wave-load { from { opacity: .35; } to { opacity: .9; } }

/* ---------------------------------------------------------------- Presence pill */
.presence {
  position: absolute; left: 50%; bottom: 14px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px 0 6px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--sh-2);
  font-size: var(--fs-sm); color: var(--text-2); font-weight: 500;
  white-space: nowrap; max-width: calc(100% - 120px);
  opacity: 0; transform: translate(-50%, 6px);
  pointer-events: none;
  transition: opacity var(--motion-normal) var(--ease-standard), transform var(--motion-normal) var(--ease-emphasized);
}
.presence.is-on { opacity: 1; transform: translate(-50%, 0); }
.presence .avatars { display: flex; }
.presence .avatar { width: 22px; height: 22px; font-size: 9px; box-shadow: 0 0 0 2px var(--surface); }
.presence .avatar + .avatar { margin-left: -6px; }
.presence__label { overflow: hidden; text-overflow: ellipsis; }
.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .35; animation: dot 1.2s var(--ease-standard) infinite; }
.dots i:nth-child(2) { animation-delay: .16s; }
.dots i:nth-child(3) { animation-delay: .32s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: rec 1.1s ease-in-out infinite; }
@keyframes rec { 50% { opacity: .3; } }
.mic-bars { display: inline-flex; gap: 2px; align-items: center; height: 14px; }
.mic-bars i { width: 2px; border-radius: 2px; background: var(--danger); animation: micbar .9s ease-in-out infinite; }
.mic-bars i:nth-child(1) { height: 6px; }
.mic-bars i:nth-child(2) { height: 12px; animation-delay: .15s; }
.mic-bars i:nth-child(3) { height: 8px; animation-delay: .3s; }
.mic-bars i:nth-child(4) { height: 11px; animation-delay: .45s; }
@keyframes micbar { 50% { transform: scaleY(.4); } }

/* Scroll-to-bottom */
.fab {
  position: absolute; right: 18px; bottom: 16px; z-index: 3;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  box-shadow: 0 0 0 1px var(--line), var(--sh-2);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--motion-normal) var(--ease-standard), transform var(--motion-normal) var(--ease-emphasized);
}
.fab.is-on { opacity: 1; transform: none; pointer-events: auto; }
.fab__n {
  position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.fab__n:empty { display: none; }

/* ---------------------------------------------------------------- Composer */
.composer {
  position: relative; z-index: 3;
  padding: 6px 12px calc(10px + var(--safe-b));
  background: transparent;
  flex-shrink: 0;
}
.composer__inner {
  max-width: 880px; margin: 0 auto;
  padding: 8px 10px 10px;
  border-radius: var(--r-island);
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow: var(--sh-island), 0 0 0 1px color-mix(in oklab, var(--line) 80%, transparent);
}
.composer__quick {
  display: flex; align-items: center; justify-content: flex-start; gap: 6px;
  overflow-x: auto; scrollbar-width: none; padding: 0 2px 8px;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 28px), transparent);
}
.composer__quick::-webkit-scrollbar { display: none; }
.qchip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: color-mix(in oklab, var(--surface-2) 92%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text-2); font-size: 11px; font-weight: 650; white-space: nowrap; flex-shrink: 0;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.qchip:hover { background: var(--surface-2); color: var(--text); }
.qchip:active { opacity: .88; }
.qchip svg { width: 14px; height: 14px; color: var(--text-3); }
.qchip--accent svg { color: var(--accent-text); }
.composer__reply {
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height var(--motion-smooth) var(--ease-standard), opacity var(--motion-normal) var(--ease-standard);
}
.composer__reply.is-open { max-height: 72px; opacity: 1; }
.reply-card {
  position: relative; display: flex; align-items: center; gap: var(--s2);
  margin: 0 0 8px 0;
  padding: 8px 6px 8px 14px; border-radius: var(--r-md);
  background: var(--surface-2);
}
.reply-card::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--q-color, var(--accent)); }
.reply-card__body { flex: 1; min-width: 0; }
.reply-card__name { font-size: var(--fs-sm); font-weight: 600; color: var(--q-color, var(--accent-text)); }
.reply-card__text { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.composer__row { display: flex; align-items: flex-end; gap: 8px; }
.cbtn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: var(--text-2);
  background: color-mix(in oklab, var(--surface-2) 90%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background var(--motion-fast), color var(--motion-fast), opacity var(--motion-fast);
}
.cbtn:hover { background: var(--surface-2); color: var(--text); }
.cbtn:active { opacity: .88; }
.cbtn.is-on { color: var(--accent-text); background: var(--accent-soft); box-shadow: none; }
.cbtn svg { width: 20px; height: 20px; }

.cfield {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; align-items: flex-end;
  min-height: 40px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface-2) 88%, transparent);
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: box-shadow var(--motion-fast) var(--ease-standard), background var(--motion-fast);
}
.cfield:focus-within {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 0 4px color-mix(in oklab, var(--accent) 10%, transparent);
}
.cfield textarea {
  flex: 1; min-width: 0;
  border: 0; outline: 0; resize: none; background: transparent;
  padding: 9px 42px 9px 15px;
  max-height: 148px; height: 40px;
  font-size: var(--fs-base); line-height: 22px;
}
.cfield textarea::placeholder { color: var(--text-4); }
.cfield .cbtn {
  position: absolute; right: 2px; bottom: 1px;
  width: 36px; height: 36px; background: transparent; box-shadow: none;
}
.cfield .cbtn:hover { background: transparent; color: var(--accent-text); }

.send {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  box-shadow: 0 8px 18px -6px color-mix(in oklab, var(--accent) 55%, transparent);
  transition: filter var(--motion-fast), opacity var(--motion-fast), background var(--motion-smooth), box-shadow var(--motion-smooth);
}
.send:hover { filter: brightness(1.04); }
.send:active { opacity: .9; }
.send svg { position: absolute; width: 20px; height: 20px; transition: opacity var(--motion-normal) var(--ease-standard); }
.send .i-send { opacity: 0; }
.send.is-send .i-send { opacity: 1; }
.send.is-send .i-mic { opacity: 0; }
.send.is-sent { animation: sent-pulse var(--motion-smooth) var(--ease-emphasized); }
@keyframes sent-pulse { 40% { filter: brightness(1.08); } }

/* Task card in thread */
.task-card {
  display: grid; gap: 10px; min-width: min(280px, 72vw);
}
.task-card__head { display: flex; align-items: flex-start; gap: 10px; }
.task-card__check {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0; margin-top: 1px;
  box-shadow: inset 0 0 0 1.5px var(--line-2); background: var(--surface);
  display: grid; place-items: center; color: var(--accent-ink);
  transition: background var(--motion-fast), box-shadow var(--motion-fast);
}
.task-card__check.is-done { background: var(--accent); box-shadow: none; }
.task-card__check svg { width: 13px; height: 13px; opacity: 0; }
.task-card__check.is-done svg { opacity: 1; }
.task-card__title { font-weight: 750; font-size: var(--fs-md); letter-spacing: -0.01em; line-height: 1.35; }
.task-card__title.is-done { text-decoration: line-through; color: var(--in-meta); }
.row--out .task-card__title.is-done { color: var(--out-meta); }
.task-card__meta { font-size: var(--fs-xs); color: var(--in-meta); font-weight: 550; margin-top: 2px; }
.row--out .task-card__meta { color: var(--out-meta); }
.task-card__people { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-card__people .avatar { width: 22px; height: 22px; font-size: 9px; box-shadow: 0 0 0 2px var(--in); }
.row--out .task-card__people .avatar { box-shadow: 0 0 0 2px var(--out); }
.task-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.task-card__actions .btn { height: 30px; padding: 0 10px; font-size: var(--fs-xs); }
.task-card__tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  color: var(--accent-text); font-size: 10.5px; font-weight: 700;
}
.task-card__source {
  font-size: 11.5px; font-weight: 650; color: var(--accent-text);
  text-align: left; text-decoration: underline; text-underline-offset: 2px;
  opacity: .9;
}
.row--out .task-card__source { color: inherit; }

.poll-card { display: grid; gap: 8px; min-width: min(260px, 70vw); }
.poll-card__q { font-weight: 750; font-size: var(--fs-md); letter-spacing: -0.01em; }
.poll-card__opt {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 38px; padding: 8px 12px; border-radius: 12px; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line); text-align: left; font-weight: 600;
}
.poll-card__bar {
  position: absolute; inset: 0 auto 0 0; background: color-mix(in oklab, var(--accent) 16%, transparent);
  pointer-events: none;
}
.poll-card__opt.is-mine { box-shadow: inset 0 0 0 1.5px var(--accent-line); }
.poll-card__label { position: relative; z-index: 1; }
.poll-card__pct { position: relative; z-index: 1; font-size: 11px; font-weight: 750; color: var(--text-3); font-variant-numeric: tabular-nums; }
.poll-card__meta { font-size: 11px; color: var(--in-meta); font-weight: 550; }
.row--out .poll-card__meta { color: var(--out-meta); }

.announce-card { display: grid; gap: 6px; min-width: min(240px, 68vw); }
.announce-card__badge {
  display: inline-flex; align-items: center; gap: 5px; width: fit-content;
  height: 22px; padding: 0 8px; border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  color: var(--accent-text); font-size: 10.5px; font-weight: 750;
}
.announce-card__badge svg { width: 13px; height: 13px; }
.announce-card__title { font-weight: 800; font-size: var(--fs-md); letter-spacing: -0.015em; }
.announce-card__body { font-size: var(--fs-sm); line-height: 1.45; opacity: .92; white-space: pre-wrap; }

.clist-card { display: grid; gap: 6px; min-width: min(240px, 68vw); }
.clist-card__title { font-weight: 750; }
.clist-card__meta { font-size: 11px; color: var(--in-meta); font-weight: 550; }
.row--out .clist-card__meta { color: var(--out-meta); }
.clist-card__item {
  display: flex; align-items: flex-start; gap: 8px; text-align: left;
  padding: 6px 0; font-weight: 550; font-size: var(--fs-sm);
}
.clist-card__check {
  width: 18px; height: 18px; border-radius: 6px; flex-shrink: 0; margin-top: 1px;
  box-shadow: inset 0 0 0 1.5px var(--line-2); display: grid; place-items: center;
}
.clist-card__check svg { width: 11px; height: 11px; opacity: 0; }
.clist-card__item.is-done .clist-card__check { background: var(--accent); box-shadow: none; color: var(--accent-ink); }
.clist-card__item.is-done .clist-card__check svg { opacity: 1; }
.clist-card__item.is-done span:last-child { text-decoration: line-through; opacity: .65; }

.doc-card, .loc-card {
  display: flex; align-items: center; gap: 12px;
  min-width: min(240px, 68vw); padding: 2px 0;
}
.doc-card__icon, .loc-card__map {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--accent) 85%, black); color: var(--accent-ink);
}
.doc-card__icon svg, .loc-card__map svg { width: 20px; height: 20px; }
.doc-card__title, .loc-card__title { font-weight: 750; font-size: var(--fs-sm); }
.doc-card__sub, .loc-card__sub { font-size: 11px; color: var(--in-meta); font-weight: 550; margin-top: 2px; }
.row--out .doc-card__sub, .row--out .loc-card__sub { color: var(--out-meta); }
.attach-card {
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px; padding: 10px 12px; border-radius: 16px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  box-shadow: inset 0 0 0 1px var(--line), var(--sh-1);
  max-width: 300px;
}
.attach-card__icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 11px;
  background: color-mix(in oklab, var(--accent) 85%, black); color: var(--accent-ink);
}
.attach-card__main { flex: 1; min-width: 0; }
.attach-card__name { font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-card__sub { font-size: 11px; color: var(--text-3); font-weight: 600; margin-top: 1px; }

.mention-pop { padding: 6px; min-width: 220px; max-height: 240px; overflow-y: auto; }
.mention-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 40px; padding: 0 10px; border-radius: 10px; text-align: left; font-weight: 600;
}
.mention-pop button:hover, .mention-pop button.is-on { background: var(--surface-2); }
.mention-pop .avatar { width: 28px; height: 28px; font-size: 10px; }

/* Recording bar */
.recbar {
  flex: 1; min-width: 0; height: 42px; border-radius: 999px;
  display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line-2);
  animation: fade-up var(--motion-normal) var(--ease-emphasized);
}
.recbar__time { font-weight: 600; font-variant-numeric: tabular-nums; font-size: var(--fs-md); min-width: 40px; }
.recbar__wave { flex: 1; min-width: 0; height: 24px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.recbar__wave i { width: 2.5px; border-radius: 2px; background: var(--danger); opacity: .75; flex-shrink: 0; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- Empty / onboarding */
.onboard {
  flex: 1; display: grid; place-items: center; padding: var(--s8) var(--s6);
  text-align: center;
}
.onboard__card { max-width: 440px; }
.onboard__art {
  width: 120px; height: 96px; margin: 0 auto var(--s5); position: relative;
}
.onboard__art i {
  position: absolute; display: block; border-radius: 16px; height: 34px;
  box-shadow: 0 0 0 1px var(--line), var(--sh-1);
  animation: fade-up var(--motion-slow) var(--ease-emphasized) both;
}
.onboard__art i:nth-child(1) { left: 0; top: 4px; width: 78px; background: var(--in); border-bottom-left-radius: 6px; }
.onboard__art i:nth-child(2) { right: 0; top: 30px; width: 86px; background: var(--out); border-bottom-right-radius: 6px; animation-delay: 120ms; }
.onboard__art i:nth-child(3) { left: 10px; top: 58px; width: 58px; background: var(--in); border-bottom-left-radius: 6px; animation-delay: 240ms; }
.onboard h2 { font-size: var(--fs-2xl); letter-spacing: -0.025em; margin: 0 0 var(--s2); }
.onboard p { color: var(--text-2); margin: 0 0 var(--s5); }
.onboard__ctas { display: flex; gap: var(--s2); justify-content: center; flex-wrap: wrap; }
.onboard__steps { margin: var(--s6) auto 0; display: grid; gap: var(--s2); text-align: left; max-width: 360px; }
.onboard__steps div { display: flex; gap: var(--s3); align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); }
.onboard__steps b { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: 11px; }
