/* Buy or Block — Messaging & unified inbox.
   The inbox looks like WhatsApp Web: chat list | chat | contact info. Colours come from tokens.css only:
   --chat-* is the WhatsApp look (same in every preset), --accent stays for buttons, links and filters. */
:root { --sms: var(--primary); }
.ch-whatsapp { --ch: var(--wa); } .ch-sms { --ch: var(--sms); } .ch-email { --ch: var(--mail); }
.ch-messenger { --ch: var(--fb); } .ch-instagram { --ch: var(--ig); } .ch-website { --ch: var(--info); }

/* ======================= inbox shell ======================= */
.page-inbox .content { max-width: none; padding: 0; }
.inbox {
  --ib-list: clamp(300px, 30%, 400px); --ib-info: 340px; --ib-bar: var(--surface-2);
  --ib-hover: color-mix(in oklab, var(--text) 4%, var(--surface));
  --ib-on: color-mix(in oklab, var(--text) 8%, var(--surface));
  display: grid; grid-template-columns: var(--ib-list) minmax(0, 1fr) var(--ib-info);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  background: var(--surface); overflow: hidden; font-variant-numeric: normal; font-feature-settings: normal;
}
.inbox:not(.has-chat), .inbox.is-info-hidden { grid-template-columns: var(--ib-list) minmax(0, 1fr); }
.inbox:not(.has-chat) .inbox-contact, .inbox.is-info-hidden .inbox-contact { display: none; }
.inbox-scrim { display: none; }
.inbox .icon-btn { min-width: 40px; height: 40px; padding: 0 9px; border-radius: 999px; }

/* ---------- left: chat list ---------- */
.inbox-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border-right: 1px solid var(--border); }
.inbox-list-head { padding: 8px 16px 0; flex: none; }
.inbox-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.inbox-title h2 { font-size: 22px; font-weight: 700; }
.inbox-title-actions { display: flex; gap: 2px; margin-right: -8px; }
.inbox-filters { display: flex; gap: 8px; align-items: center; margin: 2px 0 6px; }
.inbox-search { position: relative; display: block; flex: 1; min-width: 0; margin: 0; }
.inbox-search i, .inbox-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.inbox-search input { width: 100%; height: 40px; padding: 0 14px 0 42px; border: 1px solid transparent; border-radius: 999px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; }
.inbox-search input::placeholder { color: var(--muted); }
.inbox-search input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inbox-status { flex: none; height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.inbox-status:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.select-sm { padding: 6px 10px; font-size: 13px; flex: 1; min-width: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-family: inherit; }

/* whose chats: segmented control (always fits, equal widths) */
.ib-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 3px; margin: 2px 0 8px; border-radius: 12px; background: var(--surface-2); }
.ib-tab { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; height: 34px; padding: 0 8px; border-radius: 9px; color: var(--muted); font-size: 13.5px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background-color .15s, color .15s, box-shadow .15s; }
.ib-tab > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.ib-tab:hover { color: var(--text); }
.ib-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ib-tab:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.ib-tab.active .inbox-count { background: var(--accent); color: var(--on-accent); }
/* which app: round brand icons; the active one shows its name. Scrolls sideways if ever too many. */
.inbox-chips { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 10px; }
.inbox-chips::-webkit-scrollbar { display: none; }
.ib-ch { position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background-color .15s, color .15s, border-color .15s; }
.ib-ch::after { content: ""; position: absolute; inset: -6px -2px; }  /* 44px tap target */
.ib-ch:hover { color: var(--text); border-color: var(--border-strong); }
.ib-ch.active { background: var(--accent-soft); border-color: var(--accent-line, var(--accent)); color: var(--accent); }
.ib-ch:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.ib-ch.ch-chip { padding: 0 4px; }
.ib-ch.ch-chip.active { padding: 0 12px 0 4px; background: color-mix(in oklab, var(--ch) 12%, var(--surface)); border-color: color-mix(in oklab, var(--ch) 45%, var(--surface)); color: var(--text); }
.ib-ch-ic { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ch, var(--muted)); color: var(--on-brand); }
.ch-instagram .ib-ch-ic { background: var(--ig-grad); }
.ib-ch-ic [data-lucide], .ib-ch-ic svg { width: 14px; height: 14px; }
.ib-ch.ch-chip:not(.active) .ib-ch-lbl { display: none; }
.ib-ch-link { position: relative; }
.ib-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--surface); }
.ch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ch, var(--muted)); }
.ch-instagram .ch-dot { background: var(--ig-grad); }
.inbox-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; line-height: 1; background: var(--surface); color: var(--muted); }
.inbox-count[hidden] { display: none; }

.inbox-items { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.inbox-item { position: relative; display: flex; align-items: center; gap: 13px; min-height: 72px; padding-left: 13px; color: var(--text); }
.inbox-item:hover { background: var(--ib-hover); color: var(--text); }
.inbox-item.active { background: var(--ib-on); }
.inbox-item:focus-visible { outline: 3px solid var(--ring); outline-offset: -3px; }
.inbox-avatar { width: 48px; height: 48px; font-size: 16px; position: relative; overflow: visible; }
.inbox-avatar img { border-radius: 50%; }
.inbox-ch { position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--on-brand); background: var(--ch, var(--muted)); border: 2px solid var(--surface); }
.inbox-item:hover .inbox-ch { border-color: var(--ib-hover); }
.inbox-item.active .inbox-ch { border-color: var(--ib-on); }
.inbox-ch [data-lucide], .inbox-ch svg { width: 10px; height: 10px; stroke-width: 2.5; }
.ch-instagram.inbox-ch, .ch-instagram.inbox-ch-inline { background: var(--ig-grad); }
.inbox-item-body { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 9px 15px 9px 0; border-bottom: 1px solid var(--border); }
.inbox-item:hover .inbox-item-body, .inbox-item.active .inbox-item-body { border-bottom-color: transparent; }
.inbox-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.inbox-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; line-height: 21px; color: var(--text); }
.inbox-time { flex: none; font-size: 12px; line-height: 16px; color: var(--muted); }
.inbox-item.unread .inbox-time { color: var(--chat-unread); font-weight: 600; }
.inbox-preview { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.inbox-item.unread .inbox-preview { color: var(--text); font-weight: 500; }
.inbox-you { font-weight: 400; color: var(--muted); }
.inbox-flags { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.inbox-item .inbox-unread { margin: 0; min-width: 20px; height: 20px; padding: 0 6px; border: 0; border-radius: 999px; display: inline-grid; place-items: center; background: var(--chat-unread); color: var(--chat-on-unread); font: 700 12px/1 var(--font-body); }
.inbox-tags { display: flex; gap: 6px; align-items: center; min-width: 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.inbox-tags .badge { flex: none; padding: 0 6px; font-size: 11px; line-height: 16px; }
.inbox-biz { min-width: 0; max-width: 55%; }
.inbox-who { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.inbox-biz + .inbox-who::before { content: "·"; margin-right: 3px; }
.inbox-who [data-lucide], .inbox-who svg { width: 12px; height: 12px; }
.inbox-who.is-unassigned { color: var(--warn); }
.inbox-items > .empty { padding: 48px 24px; }

/* ---------- middle: the chat ---------- */
.inbox-thread { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-wall); }
.thread-empty { margin: auto; }
.inbox-thread > .thread-empty { background: var(--surface); width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.thread-head { position: relative; z-index: 4; flex: none; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 8px 12px 8px 14px; background: var(--ib-bar); border-bottom: 1px solid var(--border); }
.thread-back { display: none; }
.thread-person { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; margin: -4px 0 -4px -6px; padding: 4px 6px; background: none; border: 0; border-radius: 12px; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.thread-person:hover { background: color-mix(in oklab, var(--text) 5%, transparent); }
.thread-person .avatar { width: 40px; height: 40px; font-size: 14px; }
.thread-person-text { display: flex; flex-direction: column; min-width: 0; }
.thread-person .person-name { display: block; font-size: 16px; font-weight: 600; line-height: 21px; }
.thread-person .person-sub { display: flex; align-items: center; gap: 5px; font-size: 13px; line-height: 18px; color: var(--muted); }
.inbox-ch-inline { flex: none; width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--ch, var(--muted)); color: var(--on-brand); }
.inbox-ch-inline [data-lucide], .inbox-ch-inline svg { width: 9px; height: 9px; stroke-width: 2.5; }
.thread-actions { flex: none; display: flex; gap: 4px; align-items: center; }
.thread-actions form { margin: 0; }
.thread-assign { position: relative; display: flex; align-items: center; }
.thread-assign > i, .thread-assign > svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.thread-actions .thread-assign .select-sm { width: 172px; height: 36px; min-height: 36px; padding: 0 10px 0 33px; border-radius: 999px; border-color: var(--border); font-size: 13px; }
.thread-btn { gap: 6px; font-size: 13px; }
.thread-open-app { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; background: var(--ch); color: var(--on-brand); }
.thread-open-app:hover, .msg-open-app:hover { filter: brightness(.93); color: var(--on-brand); }
.thread-open-app .lbl-wide { margin-right: -3px; }
.thread-info[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.thread-alert { margin: 0 0 6px; }
.wa-window { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.wa-window.open { background: var(--ok-soft); color: var(--ok); }
.wa-window.closed { background: var(--warn-soft); color: var(--warn); }

/* messages: WhatsApp wallpaper + bubbles with tails */
.msg-thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 8px clamp(10px, 5%, 64px) 10px; background-color: var(--chat-wall); background-image: var(--chat-doodle); background-size: 240px 240px; color: var(--chat-ink); font-size: 14.2px; line-height: 1.4; }
.msg-thread.mini { max-height: 340px; padding: 6px 8px 10px; margin-bottom: 4px; border-radius: var(--radius); }
.msg-day { position: relative; z-index: 1; display: flex; justify-content: center; margin: 12px 0 4px; pointer-events: none; }
.msg-day span { min-width: 104px; padding: 5px 12px 6px; border-radius: 7.5px; background: var(--chat-pill); color: var(--chat-pill-ink); box-shadow: var(--chat-shadow); font-size: 12.5px; line-height: 15px; text-align: center; }
.msg-thread > .empty { margin: auto; padding: 10px 16px; border-radius: 7.5px; background: var(--chat-pill); color: var(--chat-pill-ink); box-shadow: var(--chat-shadow); font-size: 13px; }
.msg-thread > .empty .empty-icon { display: none; }
.msg-thread > .empty p { margin: 0; }
.msg-row { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; margin-top: 10px; padding: 0 8px; }
.msg-row.out { align-items: flex-end; }
.msg-row.in + .msg-row.in, .msg-row.out + .msg-row.out { margin-top: 2px; }
.msg-bubble { position: relative; max-width: min(65%, 620px); padding: 6px 7px 8px 9px; border-radius: 7.5px; background: var(--chat-in); color: var(--chat-ink); box-shadow: var(--chat-shadow); overflow-wrap: anywhere; }
.msg-row.out .msg-bubble { background: var(--chat-out); }
.msg-bubble::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; background: inherit; }
.msg-row.in .msg-bubble { border-top-left-radius: 0; }
.msg-row.in .msg-bubble::before { left: -8px; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg-row.out .msg-bubble { border-top-right-radius: 0; }
.msg-row.out .msg-bubble::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg-row.in + .msg-row.in .msg-bubble, .msg-row.out + .msg-row.out .msg-bubble { border-radius: 7.5px; }
.msg-row.in + .msg-row.in .msg-bubble::before, .msg-row.out + .msg-row.out .msg-bubble::before { display: none; }
.msg-bubble.is-failed { box-shadow: inset 0 0 0 1px var(--bad-line), var(--chat-shadow); }
.msg-bubble.is-queued { opacity: .75; }
.msg-subject { font-weight: 600; margin-bottom: 2px; }
.msg-text { display: inline; white-space: normal; }
/* links and phone numbers in a message: tappable, like Messenger (owner, 8 Nov 2026) */
.msg-link { color: var(--chat-link); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg-link[href^="tel:"] { white-space: nowrap; }
.msg-link:hover { text-decoration-thickness: 2px; }
.msg-text.is-emoji { font-size: 34px; line-height: 1.2; letter-spacing: 2px; }   /* "👍" alone reads big, like Messenger */
/* a swipe-reply: the message it answers, quoted on top of the bubble */
.msg-quote { display: flex; align-items: stretch; gap: 8px; margin: 0 0 4px; padding: 5px 8px 5px 9px; border-left: 3px solid var(--chat-quote);
  border-radius: 6px; background: color-mix(in oklab, var(--chat-ink) 7%, transparent); color: var(--chat-ink); text-decoration: none; font-size: 13px;
  line-height: 1.3; max-width: 100%; min-width: min(200px, 100%); cursor: pointer; }
.msg-quote.from-us { border-left-color: var(--chat-link); }
.msg-quote:hover { background: color-mix(in oklab, var(--chat-ink) 11%, transparent); }
.msg-quote-body { display: flex; flex-direction: column; min-width: 0; }
.msg-quote-who { font-weight: 600; font-size: 12px; color: var(--chat-quote); }
.msg-quote.from-us .msg-quote-who { color: var(--chat-link); }
.msg-quote-text { color: var(--chat-meta); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: pre-line; }
.msg-quote-thumb { flex: none; width: 44px; height: 44px; object-fit: cover; border-radius: 4px; order: 2; margin-left: auto; }
.msg-bubble.has-media > .msg-quote { margin: 2px 2px 6px; }
.msg-row.flash .msg-bubble { animation: msg-flash 1.4s ease-out; }
@keyframes msg-flash { 0%, 30% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--chat-link) 70%, transparent); } 100% { box-shadow: var(--chat-shadow); } }
/* time + ticks sit inside the bubble, bottom-right, on the last line when it fits (float trick) */
.msg-meta { float: right; display: flex; align-items: center; gap: 4px; margin: 6px 0 -5px 12px; font-size: 11px; line-height: 15px; color: var(--chat-meta); white-space: nowrap; }
.msg-row.out .msg-meta { color: var(--chat-meta-out); }
.msg-meta [data-lucide], .msg-meta svg { width: 13px; height: 13px; }
.msg-by { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.msg-chip { display: inline-flex; }
.msg-tick { display: inline-flex; }
.msg-tick [data-lucide], .msg-tick svg { width: 16px; height: 16px; }
.msg-tick.st-read { color: var(--chat-tick-read); }
.msg-tick.st-failed { color: var(--bad); }
.msg-meta .msg-auto, .msg-meta .ai-badge { display: inline-flex; align-items: center; gap: 2px; height: 16px; padding: 0 5px; border: 0; border-radius: 4px; background: color-mix(in oklab, var(--chat-ink) 8%, transparent); color: inherit; font-size: 10px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.msg-meta .msg-auto svg, .msg-meta .ai-badge svg, .msg-meta .msg-auto [data-lucide], .msg-meta .ai-badge [data-lucide] { width: 11px; height: 11px; }
.msg-meta .msg-why { font-size: 11px; }
.msg-meta .msg-why > summary { color: var(--chat-link); font-weight: 600; border-radius: 4px; }
.msg-meta .msg-why[open] > summary { margin: 0; }
.msg-meta .ai-why-body { position: absolute; z-index: 5; top: calc(100% + 6px); right: 0; white-space: normal; text-transform: none; letter-spacing: normal; }
.msg-row.in .msg-meta .ai-why-body { right: auto; left: 0; }
.msg-note { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 11.5px; color: var(--chat-meta); }
.msg-note.error { color: var(--bad); }
.msg-note.subtle { opacity: .85; }
.msg-note.ad { align-self: center; margin: 8px 0 2px; padding: 5px 12px; border-radius: 7.5px; background: var(--chat-pill); color: var(--chat-pill-ink); box-shadow: var(--chat-shadow); font-size: 12.5px; }
.msg-note.ad svg { color: var(--purple); }

/* ---------- photos, videos, voice notes, files in a bubble (messaging/_attachment.html) ---------- */
.msg-bubble.has-media { padding: 3px 3px 8px; }
.msg-bubble.has-media > .msg-text, .msg-bubble.has-media > .msg-subject { display: block; padding: 4px 6px 0; }
.msg-bubble.has-media > .msg-meta { margin-right: 4px; }
.msg-media { display: block; max-width: 100%; border-radius: 6px; overflow: hidden; }
.msg-media img { display: block; width: auto; max-width: min(330px, 100%); max-height: 360px; object-fit: cover; background: color-mix(in oklab, var(--chat-ink) 6%, transparent); }
.msg-media-sticker img { max-width: 140px; max-height: 140px; background: none; }
.msg-bubble.has-media:has(.msg-media-sticker) { background: transparent; box-shadow: none; }
.msg-bubble.has-media:has(.msg-media-sticker)::before { display: none; }
.msg-media-video { width: min(330px, 100%); max-height: 360px; background: var(--scrim); }
.msg-audio { display: flex; align-items: center; gap: 6px; width: min(300px, 70vw); max-width: 100%; padding: 4px 6px 0; color: var(--chat-meta); }
.msg-audio svg, .msg-audio [data-lucide] { flex: none; }
.msg-audio audio { flex: 1; min-width: 0; height: 40px; }
.msg-audio-len { flex: none; font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg-doc { display: flex; align-items: center; gap: 10px; min-width: min(240px, 100%); max-width: 330px; padding: 8px 10px; border-radius: 6px; background: color-mix(in oklab, var(--chat-ink) 6%, transparent); color: var(--chat-ink); text-decoration: none; }
.msg-doc:hover { background: color-mix(in oklab, var(--chat-ink) 10%, transparent); }
.msg-doc:focus-visible, .msg-media:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.msg-doc-icon { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.msg-doc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msg-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.msg-doc-size { font-size: 11.5px; color: var(--chat-meta); }
.msg-media-state { display: flex; align-items: center; gap: 8px; min-width: min(220px, 100%); padding: 10px 12px; border-radius: 6px; background: color-mix(in oklab, var(--chat-ink) 6%, transparent); color: var(--chat-meta); font-size: 13px; }
.msg-media-state svg, .msg-media-state [data-lucide] { flex: none; width: 18px; height: 18px; }
.msg-media-state.is-loading svg { animation: msg-pulse 1.4s ease-in-out infinite; }
.msg-media-state.is-failed { color: var(--bad); background: var(--bad-soft); }
@keyframes msg-pulse { 50% { opacity: .35; } }

/* composer: the chosen file above the bar */
.msg-attach { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 6px 6px 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.msg-attach.hidden, .msg-attach-btn.hidden { display: none; }
.msg-attach-thumb { flex: none; display: inline-grid; place-items: center; width: 48px; height: 48px; overflow: hidden; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.msg-attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.msg-attach-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msg-attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.msg-attach-remove { width: 36px; height: 36px; }
.msg-attach-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.msg-composer.is-dropping { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: var(--radius-lg); }

/* ---------- composer (WhatsApp bar) ---------- */
.chat-foot { flex: none; padding: 8px 12px; background: var(--ib-bar); border-top: 1px solid var(--border); }
.msg-composer { background: transparent; }
.msg-composer.compact { margin-top: 12px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.msg-composer-row { display: flex; align-items: flex-end; gap: 6px; }
.msg-composer-tools { flex: none; display: flex; align-items: center; gap: 2px; }
.msg-tool { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font: inherit; }
.msg-tool:hover, .msg-tool:focus-within, .dropdown.open > .msg-tool { background: color-mix(in oklab, var(--text) 7%, transparent); color: var(--text); }
.msg-tool:focus-visible, .msg-tpl:focus-within { outline: 3px solid var(--ring); outline-offset: 1px; }
.msg-tool [data-lucide], .msg-tool svg { width: 22px; height: 22px; }
.msg-tpl .msg-template-select { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 50%; opacity: 0; cursor: pointer; }
.msg-tpl:has(option:checked:not([value=""])) { color: var(--accent); }
.msg-tpl:has(.hidden) { display: none; }
.msg-vars .dropdown-menu { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; max-height: 50vh; overflow-y: auto; }
.msg-composer .dropdown-menu code { font-size: 12px; }
.msg-input { flex: 1; min-width: 0; }
.msg-input:has(> .hidden) { display: none; }
.msg-body { display: block; width: 100%; min-height: 42px !important; max-height: 160px; padding: 10px 16px; border: 1px solid transparent; border-radius: 21px; background: var(--surface); color: var(--text); font: inherit; font-size: 15px; line-height: 20px; resize: none; overflow-y: auto; field-sizing: content; }
.msg-composer.compact .msg-body { min-height: 62px !important; border-radius: 16px; }
.msg-body::placeholder { color: var(--muted); }
.msg-body:focus { outline: none; border-color: var(--accent-line); box-shadow: none; }
.msg-body:focus-visible { border-color: var(--accent); }
.msg-body[readonly] { background: var(--surface-2); color: var(--text-2); }
.msg-send { flex: none; margin-left: auto; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.msg-send [data-lucide], .msg-send svg { width: 20px; height: 20px; }
.msg-send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* voice message (owner, 16 Nov 2026): as in WhatsApp the microphone stands in Send's place while the box is empty
   (Send comes back with the first letter); recording swaps the row for a bar: bin, red dot, clock, moving bars,
   pause, send */
.msg-composer.is-recording .msg-composer-row { display: none; }
.msg-voice { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 2px 2px 2px 0; }
.msg-voice.hidden { display: none; }
.msg-voice-cancel { color: var(--bad); }
.msg-voice-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: msg-voice-blink 1.1s ease-in-out infinite; }
.msg-voice.is-paused .msg-voice-dot { animation: none; opacity: .45; }
.msg-voice-time { flex: none; min-width: 44px; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; color: var(--text); }
.msg-voice-wave { flex: 1 1 auto; min-width: 0; height: 32px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.msg-voice-wave i { flex: none; width: 3px; min-height: 3px; border-radius: 2px; background: var(--muted); }
.msg-voice-send { margin-left: 0; }
@keyframes msg-voice-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .msg-voice-dot { animation: none; } }
.msg-composer-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 28px; margin-top: 6px; padding: 0 2px; }
.msg-channels { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: color-mix(in oklab, var(--text) 6%, transparent); }
.msg-channel { position: relative; margin: 0; }
.msg-channel input { position: absolute; opacity: 0; pointer-events: none; }
.msg-channel > span { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.msg-channel > span [data-lucide], .msg-channel > span svg { width: 14px; height: 14px; }
.msg-channel input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.msg-channel input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }
.msg-channel.is-disabled > span { opacity: .45; cursor: not-allowed; }
.msg-counter { margin-left: auto; font-size: 12px; color: var(--muted); }
.msg-window { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 8px; padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.msg-window.open { background: var(--ok-soft); color: var(--ok); }
.msg-window.closed { background: var(--warn-soft); color: var(--warn); }
.btn.is-loading { opacity: .7; pointer-events: none; }

/* ---------- right: contact info ---------- */
.inbox-contact { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border-left: 1px solid var(--border); }
.ic-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 8px 12px; background: var(--ib-bar); border-bottom: 1px solid var(--border); }
.ic-head h3 { font-size: 16px; font-weight: 600; }
.ic-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 20px 28px; }
.ic-profile { text-align: center; }
.ic-profile .avatar-xl { width: 96px; height: 96px; font-size: 34px; margin: 0 auto 12px; }
.ic-profile h3 { font-size: 19px; font-weight: 600; }
.ic-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.inbox-contact .divider { margin: 20px -20px; }
.ic-kv { grid-template-columns: 104px minmax(0, 1fr); gap: 10px 12px; font-size: 14px; }
.ic-title, .inbox-contact .lead-card h4, .inbox-contact .ai-side h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.inbox-other { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px; margin: 0 -10px; border-radius: var(--radius); color: var(--text); font-weight: 500; }
.inbox-other:hover { background: var(--surface-2); color: var(--text); }

/* ---------- contact panel ---------- */
.msg-panel { margin-top: 16px; }
.msg-panel .card-header h3 { display: flex; align-items: center; gap: 8px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

/* ---------- templates page ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; }
.tpl-card .card-body { flex: 1; }
.tpl-card.is-inactive { opacity: .6; }
.tpl-ch { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--on-brand); background: var(--ch, var(--muted)); flex-shrink: 0; }
.tpl-ch.ch-instagram { background: var(--ig-grad); }
.tpl-body { font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; max-height: 140px; overflow: auto; }
.var-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--primary-50); color: var(--primary-700); }
.hook-url { display: flex; gap: 8px; }
.hook-url .input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.wrap { flex-wrap: wrap; }

/* Messenger / Instagram (inbox automation) */
.test-reply { margin: 0 0 8px; padding: 8px 10px; border: 1px dashed var(--warn-line); background: var(--warn-soft); border-radius: 10px; }
.test-reply-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--warn); margin-bottom: 6px; }
.test-reply-row { display: flex; gap: 8px; }
.test-reply-row .input { flex: 1; min-height: 38px; padding: 6px 12px; }
.lead-card { margin-top: 0; }
.lead-card h4 { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0 0 8px; }
.lead-biz { font-size: 12px; color: var(--muted); margin: 8px 0 6px; }
.lead-stages { display: flex; flex-wrap: wrap; gap: 6px; }
.lead-stage { --c: var(--primary); position: relative; border: 1px solid color-mix(in srgb, var(--c) 30%, var(--surface)); background: color-mix(in srgb, var(--c) 8%, var(--surface)); color: color-mix(in srgb, var(--c) 80%, var(--text)); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; }
.lead-stage:hover { background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.lead-stage.on { background: var(--c); border-color: var(--c); color: var(--on-brand); display: inline-flex; align-items: center; gap: 4px;
  overflow: hidden; isolation: isolate; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent), 0 2px 8px color-mix(in srgb, var(--c) 35%, transparent); }
/* a soft light sweeps across the current pill every few seconds (owner: calm, no bouncing) */
.lead-stage.on::before { content: ""; position: absolute; inset: 0 auto 0 -70%; width: 50%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent, color-mix(in srgb, var(--on-brand) 38%, transparent), transparent);
  animation: lead-sheen 4.5s ease-in-out 1s infinite; }
.lead-stage-tick { width: 14px; height: 14px; stroke-width: 3; }
/* current stage at a glance (owner: before a call, the eye must land on it) */
.lead-now { --c: var(--primary); display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 35%, var(--surface));
  border-left: 4px solid var(--c); }
.lead-now-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.lead-now-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.lead-now-lbl { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.lead-now-text b { font-size: 16px; color: color-mix(in srgb, var(--c) 75%, var(--text)); }
.lead-now-when { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
@keyframes lead-sheen { 0% { left: -70%; } 40%, 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .lead-stage.on::before { animation: none; display: none; } }
.lead-stage:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.lead-fields { display: grid; grid-template-columns: 1fr 90px; gap: 8px; margin-top: 12px; }
.lead-fields .select, .lead-fields .input { font-size: 13px; padding: 7px 9px; min-height: 38px; border-radius: 10px; }
.lead-ad { display: flex; gap: 6px; align-items: center; margin-top: 10px; padding: 7px 9px; border-radius: 8px; background: var(--purple-50); color: var(--purple); font-size: 12px; }
.lead-ad + form .lead-stages, .lead-ad + form .lead-biz { margin-top: 10px; }

/* ---------- WhatsApp templates (approval status, approved-template picker) ---------- */
.wa-badge { white-space: normal; line-height: 1.35; padding-top: 3px; padding-bottom: 3px; }
.wa-reason-bad { color: var(--red-700); }
.wa-section-title h3 { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; }
.tpl-wa-header { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.tpl-wa-footer { margin-top: 4px; }
.tpl-wa-button { font-size: 12px; font-weight: 600; color: var(--primary-700); border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 10px; }
[data-field="wa_category"] ul, [data-field="wa_category"] > div { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
[data-field="wa_category"] label { font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.msg-wa-picker { margin-bottom: 8px; border: 1px solid var(--warn-line); background: var(--warn-soft); border-radius: var(--radius); padding: 10px 12px; }
.msg-wa-picker.hidden, .msg-body.hidden { display: none; }
.msg-wa-picker-label { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--warn); margin: 0 0 2px; }
.msg-wa-picker .select { width: 100%; margin-top: 8px; }
.msg-wa-preview { margin-top: 8px; font-size: 13px; white-space: pre-line; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.msg-wa-preview:empty { display: none; }

/* ---------- live inbox (inbox-live.js) ---------- */
.live-alerts { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 8px 10px; border: 1px solid var(--info-line); background: var(--info-soft); color: var(--text); border-radius: var(--radius); font-size: 12px; line-height: 1.35; }
.live-alerts[hidden] { display: none; }
.live-alerts > i, .live-alerts > svg { color: var(--info); flex: none; }
.inbox-item.is-new { animation: inbox-flash 1.6s ease-out; }
@keyframes inbox-flash { from { background: var(--accent-soft); } to { background: transparent; } }
.msg-new-pill { position: sticky; bottom: 8px; align-self: center; z-index: 3; display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; min-height: 36px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--chat-pill); color: var(--chat-ink); font-family: inherit; font-weight: 600; font-size: 12.5px; line-height: 1.2; box-shadow: var(--shadow-md); cursor: pointer; }
.msg-new-pill:hover { color: var(--chat-link); }
.msg-new-pill[hidden] { display: none; }
.msg-seen { align-self: flex-end; margin: 2px 10px 0 0; font-size: 11px; color: var(--chat-meta); }
.msg-send-error { color: var(--bad); flex-basis: 100%; order: 3; }
.msg-send-error[hidden] { display: none; }

/* ======================= responsive ======================= */
/* tablet: contact info becomes a slide-over sheet */
/* ---------- connect your apps (inbox empty state, Channels page cards) ---------- */
.cx-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cx-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 20px; text-align: left; }
.cx-card h2, .cx-card h4 { margin: 4px 0 0; font: 600 18px/1.25 var(--font-head); color: var(--text); }
.cx-card .btn { margin-top: auto; }
.cx-blurb { margin: 0 0 8px; color: var(--muted); font-size: 14px; line-height: 1.45; flex: 1; }
.cx-logo, .cx-mini { display: grid; place-items: center; flex: none; color: var(--on-brand); background: var(--accent); }
.cx-logo { width: 48px; height: 48px; border-radius: 14px; }
.cx-logo svg { width: 26px; height: 26px; }
.cx-mini { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); }
.cx-mini svg { width: 12px; height: 12px; }
.cx-logo.ch-whatsapp, .cx-mini.ch-whatsapp { background: var(--wa); }
.cx-logo.ch-messenger, .cx-mini.ch-messenger { background: var(--fb); }
.cx-logo.ch-instagram, .cx-mini.ch-instagram { background: var(--ig-grad); }
.cx-state { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.cx-state.is-ok { color: var(--ok); } .cx-state.is-warn { color: var(--warn); }
.cx-state b { color: var(--text); }
.cx-card.is-on { border-color: var(--ok-line); }
.cx-empty { width: 100%; max-width: 860px; margin: auto; padding: 32px 24px; text-align: center; }
.cx-empty-head { max-width: 520px; margin: 0 auto 24px; }
.cx-empty-head h3 { margin: 0 0 6px; font: 600 22px/1.25 var(--font-head); color: var(--text); }
.cx-empty-head p { margin: 0; color: var(--muted); }
.cx-empty-ico { width: 56px; height: 56px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.cx-empty-foot { margin: 20px 0 0; color: var(--muted); font-size: 14px; }
.inbox-thread > .thread-connect { overflow-y: auto; }
.ib-only-m { display: none; }
.inbox-items .cx-empty { padding: 4px 0 16px; }
.inbox-items .cx-grid { grid-template-columns: 1fr; gap: 10px; }
.inbox-items .cx-card { padding: 14px; }
/* Channels pill in the chat-list header (managers) */
.ib-apps { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: 13px; line-height: 1.3; text-decoration: none; }
.ib-apps:hover { border-color: var(--accent-line); color: var(--text); }
.ib-apps small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.ib-apps b { color: var(--accent); font-weight: 600; white-space: nowrap; }
.ib-apps.is-warn { background: var(--warn-soft); border-color: var(--warn-line); }
.ib-apps.is-warn > i, .ib-apps.is-warn > svg { color: var(--warn); }
.ib-apps-icons { display: inline-flex; }
.ib-apps-icons .cx-mini + .cx-mini { margin-left: -6px; }
@media (max-width: 1100px) { .cx-grid { grid-template-columns: 1fr; } .cx-empty .cx-grid { max-width: 420px; margin: 0 auto; } }
@media (max-width: 760px) { .ib-only-m { display: block; } .ib-only-d { display: none; } }

@media (max-width: 1280px) {
  .inbox, .inbox.is-info-hidden { grid-template-columns: clamp(270px, 38%, 360px) minmax(0, 1fr); }
  .inbox-contact, .inbox.is-info-hidden .inbox-contact { display: flex; position: fixed; top: 0; right: 0; bottom: 0; z-index: 70; width: min(380px, 92vw); box-shadow: var(--shadow-pop); transform: translateX(105%); visibility: hidden; transition: transform .22s ease, visibility .22s; }
  .inbox.is-info-open .inbox-contact { transform: none; visibility: visible; }
  .inbox.is-info-open .inbox-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: var(--scrim); }
  .lbl-wide { display: none; }
}
/* a short screen (a 768 px laptop): the filters scroll away with the chats too, else 4 rows of chips leave room for
   three chats (8 Nov 2026) */
@media (min-width: 761px) and (max-height: 860px) {
  .inbox-list { overflow-y: auto; overscroll-behavior: contain; }
  .inbox-list > .inbox-items { flex: none; overflow: visible; min-height: auto; }
}
/* phone: list → full-screen chat with a back button, like WhatsApp on a phone */
@media (max-width: 760px) {
  .page-inbox .content { padding: 0; }
  .inbox { display: block; height: calc(100dvh - var(--topbar-h) - var(--pwa-tabbar-h, 72px) - env(safe-area-inset-bottom)); }
  .inbox-list { height: 100%; border-right: 0; overflow-y: auto; overscroll-behavior: contain; }
  /* the filters stay all in view at the top (owner) but scroll away with the chats, so a phone shows more than three
     chats at a time (8 Nov 2026: the 423 px head left 257 px for the list) */
  .inbox-list > .inbox-items { flex: none; overflow: visible; min-height: auto; }
  .inbox-thread { display: none; }
  .inbox.is-chat-open .inbox-list { display: none; }
  .inbox.is-chat-open .inbox-thread { display: flex; position: fixed; inset: 0; z-index: 50; height: 100dvh; }
  .thread-head { gap: 2px; padding: max(6px, env(safe-area-inset-top)) 4px 6px 4px; }
  .thread-back { display: inline-flex; }
  .thread-person { margin: 0; padding: 4px; gap: 10px; }
  .wa-window, .thread-info { display: none; }  /* tap the name for contact info */
  .thread-open-app { display: none; }   /* no room beside the name: a strip of its own under the header */
  /* the person's name needs the room: "Assign to" becomes a round icon that opens the same picker (8 Nov 2026: at
     375 px the 112 px select covered the name, only "N" showed) */
  .thread-actions .thread-assign .select-sm { width: 44px; padding: 0; color: transparent; background: transparent; background-image: none; border-color: transparent; text-indent: -999px; cursor: pointer; }
  .thread-actions .thread-assign .select-sm option { color: var(--text); text-indent: 0; }
  .thread-assign > i, .thread-assign > svg { display: block !important; left: 50%; transform: translateX(-50%); width: 20px; height: 20px; color: var(--text); }
  .thread-assign.is-set > i, .thread-assign.is-set > svg { color: var(--accent); }
  .thread-actions .thread-assign .select-sm, .inbox-status, .inbox-search input { font-size: 16px; }  /* no iOS zoom */
  .msg-thread { padding: 6px 6px 10px; }
  .msg-bubble { max-width: 85%; }
  .chat-foot { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .msg-body { font-size: 16px; }
  .msg-channel-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .inbox-contact, .inbox.is-info-hidden .inbox-contact { width: 100%; border-left: 0; }
  .ic-head { padding-top: max(8px, env(safe-area-inset-top)); }
}
/* touch: 44px targets */
@media (pointer: coarse) {
  .inbox .icon-btn { min-width: 44px; height: 44px; }
  .msg-tool { width: 44px; height: 44px; }
  .inbox-search input, .inbox-status, .thread-actions .thread-assign .select-sm { height: 44px; }
  .msg-channel > span { height: 32px; }
  .msg-channel::after, .lead-stage::after { content: ""; position: absolute; inset: -6px 0; }
  .lead-stage { min-height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .inbox-item.is-new { animation: none; }
  .inbox-contact, .ib-ch, .ib-tab { transition: none; }
}

/* Inbox header: labelled "More" menu (Auto-replies · Saved replies · Inbox settings) */
.ib-more-btn span { font-size: 13px; }
.ib-more .dropdown-item span { display: flex; flex-direction: column; min-width: 0; }
.ib-more .dropdown-item small { color: var(--muted); font-weight: 400; font-size: 12px; }
.ib-more .dropdown-menu { min-width: 260px; }

/* ---------- "new message" cards (live inbox) ---------- */
.ib-toasts { position: fixed; z-index: 60; right: 20px; top: 128px; display: flex; flex-direction: column; gap: 8px; width: min(320px, calc(100vw - 32px)); pointer-events: none; }
.ib-toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop); color: var(--text); text-decoration: none; animation: ib-toast-in .22s ease-out; }
.ib-toast:hover { border-color: var(--accent-line); color: var(--text); }
.ib-toast-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ib-toast-txt b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-toast-txt small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-toast-go { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; }
@keyframes ib-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* owner, 15 Nov 2026: the card sat on the message box and the Send button. On a computer it now sits over the foot of
   the chat list (inbox-live.js places it); on a phone there is no card at all: the list row and the sound say it. */
@media (max-width: 760px) { .ib-toasts { display: none; } }

/* potential leads row + marks (theme tokens: light and dark follow tokens.css) */
.lead-chip .lead-today { font-size: 10.5px; font-weight: 700; color: var(--ok, var(--success)); margin-left: 4px; white-space: nowrap; }
/* a list's name is never cut and its number never spills out of the pill ("Interested in physical class", 21 Nov
   2026): the chat card's own chip rule (max-width 46%) is not for these */
.lead-chips .lead-chip { max-width: 100%; flex-shrink: 0; }
/* Handover to Human (owner, 14 Nov 2026): a soft warm tint, no hard border; the count is the one warm spot that says
   "a reply is owed here". It lifts a little under the mouse. */
.lead-chips .lead-chip.lead-handover:not(.is-zero) { border-color: transparent; color: color-mix(in oklab, var(--warn) 78%, var(--text));
  background: linear-gradient(135deg, color-mix(in oklab, var(--warn) 13%, var(--surface)), color-mix(in oklab, var(--warn) 5%, var(--surface)));
  box-shadow: 0 1px 2px color-mix(in oklab, var(--warn) 16%, transparent); transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.lead-chips .lead-chip.lead-handover:not(.is-zero):hover { transform: translateY(-1px); background: color-mix(in oklab, var(--warn) 17%, var(--surface));
  box-shadow: 0 4px 10px color-mix(in oklab, var(--warn) 22%, transparent); }
.lead-chips .lead-chip.lead-handover:not(.is-zero) .lead-n { background: var(--warn); color: var(--on-status);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--warn) 45%, transparent); animation: ho-breathe 2.8s ease-out infinite; }
.lead-chips .lead-chip.lead-handover.active { background: color-mix(in oklab, var(--warn) 20%, var(--surface));
  border-color: color-mix(in oklab, var(--warn) 35%, transparent); color: color-mix(in oklab, var(--warn) 85%, var(--text)); }
@keyframes ho-breathe { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--warn) 40%, transparent); } 70%, 100% { box-shadow: 0 0 0 5px transparent; } }
@media (prefers-reduced-motion: reduce) { .lead-chips .lead-chip.lead-handover .lead-n { animation: none; } .lead-chips .lead-chip.lead-handover:hover { transform: none; } }
/* the soft switch (inbox-nav.js): a chat that takes more than a moment dims a little, nothing jumps */
.inbox.is-nav-loading .inbox-thread, .inbox.is-nav-loading .inbox-contact { opacity: .55; transition: opacity .2s ease .15s; }
.inbox.is-nav-loading.is-nav-list .inbox-items { opacity: .55; transition: opacity .2s ease .15s; }
.flag-block { background: var(--bad-soft); }
.flag-block > i { color: var(--bad); }
.via-chips { padding-top: 0; flex-wrap: wrap; overflow: visible; row-gap: 6px; }
.via-chips .ib-ch { height: 30px; padding: 0 10px; font-size: 12px; }
.via-mark { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-chips { padding-top: 0; flex-wrap: wrap; overflow: visible; row-gap: 6px; }  /* every chip in view on any screen (owner) */
.lead-chips .ib-ch { height: 30px; padding: 0 10px; }
.lead-chip .lead-n { font-size: 11px; font-weight: 700; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-2, var(--bg)); color: var(--muted); text-align: center; }
.lead-chip.active .lead-n { background: var(--accent); color: var(--on-accent, var(--surface)); }
.lead-chip.lead-hot { color: var(--warn); }
.lead-chip.lead-hot.active { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.lead-chip.lead-hot.active .lead-n { background: var(--warn); color: var(--on-status); }
.lead-chip.lead-sub { padding: 0 10px; }
.lead-mark { display: inline-flex; align-items: center; }
.lead-mark svg { width: 15px; height: 15px; }
.lead-mark.is-hot, .lead-mark.is-star, .star-btn.is-on { color: var(--warn); }
.lead-mark.is-new { color: var(--primary); }
.lead-mark.is-star svg, .star-btn.is-on svg { fill: currentColor; }

/* who moved the lead (AI / a person), with OK / Undo */
.lead-by { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: -4px 0 10px; font-size: 12px; color: var(--muted); }
.lead-by span { display: inline-flex; align-items: center; gap: 4px; }
.lead-by.is-ai span { color: var(--accent); font-weight: 600; }
.lead-by .link-btn { font-size: 12px; font-weight: 700; }
.block-btn:hover { color: var(--bad); }
.msg-wa-free { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; text-decoration: none;
  background: var(--ok-soft, var(--surface)); border: 1px solid var(--ok-line, var(--border)); color: var(--ok); }
.msg-wa-free span { display: flex; flex-direction: column; flex: 1; line-height: 1.25; }
.msg-wa-free small { color: var(--muted); font-size: 12px; }
.msg-wa-free.is-messenger { background: var(--fb); border-color: transparent; color: var(--on-brand); }
.msg-wa-free.is-messenger small { color: inherit; opacity: .9; }
.lead-name { display: flex; gap: 6px; margin-bottom: 10px; }
.lead-name .input { flex: 1; min-width: 0; }

/* ---------- calls at a glance (apps/messaging/calls.py): strip on top of the chat, cards between messages ---------- */
.call-strip { --cs: var(--muted); --cs-soft: var(--surface-2); position: relative; z-index: 3; flex: none; background: var(--ib-bar); border-bottom: 1px solid var(--border); font-size: 13px; }
.call-strip.tone-ok { --cs: var(--ok); --cs-soft: var(--ok-soft); }
.call-strip.tone-warn { --cs: var(--warn); --cs-soft: var(--warn-soft); }
.call-strip.tone-bad { --cs: var(--bad); --cs-soft: var(--bad-soft); }
.call-strip.tone-info, .call-strip.tone-live { --cs: var(--info); --cs-soft: var(--info-soft); }
.call-strip:not(.is-none) { background: linear-gradient(90deg, var(--cs-soft), var(--ib-bar) 70%); box-shadow: inset 3px 0 0 var(--cs); }
.cs-box > summary { list-style: none; }
.cs-box > summary::-webkit-details-marker { display: none; }
.cs-main { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px 6px 14px; cursor: pointer; }
.call-strip.is-none .cs-main { cursor: default; min-height: 38px; padding-block: 4px; }
.cs-main:hover .cs-more { color: var(--text); }
.cs-icon { position: relative; flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--cs-soft); color: var(--cs); }
.cs-icon svg { width: 16px; height: 16px; }
.call-strip.is-none .cs-icon { width: 26px; height: 26px; background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); }
.call-strip.is-none .cs-icon svg { width: 13px; height: 13px; }
.cs-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cs-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.cs-title { font-weight: 600; color: var(--text); }
.call-strip.is-none .cs-title { font-weight: 500; color: var(--muted); }
.cs-when { color: var(--muted); font-size: 12px; }
.cs-result { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.cs-result.tone-ok { background: var(--ok-soft); color: var(--ok); }
.cs-result.tone-warn { background: var(--warn-soft); color: var(--warn); }
.cs-result.tone-bad { background: var(--bad-soft); color: var(--bad); }
.cs-result.tone-info, .cs-result.tone-live { background: var(--info-soft); color: var(--info); }
.cs-notes { color: var(--text); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-hint { display: inline-flex; align-items: center; gap: 4px; color: var(--cs); font-size: 12px; font-weight: 600; }
.cs-side { flex: none; display: flex; align-items: center; gap: 8px; }
.cs-more { display: inline-flex; align-items: center; gap: 2px; padding: 3px 8px; border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.cs-more svg { transition: transform .2s ease; }
.cs-box[open] .cs-more svg { transform: rotate(180deg); }
.cs-box[open] .cs-notes { white-space: normal; }
.cs-list { list-style: none; margin: 0; padding: 4px 14px 12px 54px; max-height: min(320px, 45vh); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; animation: cs-drop .18s ease-out; }
.cs-item { display: flex; gap: 10px; }
.cs-dot { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-left: -34px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.cs-item.tone-ok .cs-dot { background: var(--ok-soft); color: var(--ok); }
.cs-item.tone-warn .cs-dot { background: var(--warn-soft); color: var(--warn); }
.cs-item.tone-bad .cs-dot { background: var(--bad-soft); color: var(--bad); }
.cs-item.tone-live .cs-dot, .cs-item.tone-info .cs-dot { background: var(--info-soft); color: var(--info); }
.cs-dot svg { width: 12px; height: 12px; }
.cs-item-body { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.cs-item-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.cs-item-head .cs-when { margin-left: auto; }
.cs-item-notes { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.cs-item-notes.is-empty { color: var(--muted); font-style: italic; font-size: 12px; }
.cs-item-log { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; font-weight: 600; }
.cs-all { font-size: 12px; }

/* attention: a call in the last 24h glows twice; a call going on right now keeps a soft ring */
.call-strip.is-recent .cs-icon::after, .call-strip.is-live .cs-icon::after, .call-strip.is-new .cs-icon::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--cs); opacity: 0; animation: cs-ring 1.6s ease-out 2; }
.call-strip.is-live .cs-icon::after { animation-iteration-count: infinite; }
.call-strip.is-live .cs-icon svg { animation: cs-shake 1.6s ease-in-out infinite; }
.call-strip.is-recent, .call-strip.is-new { animation: cs-flash 1.4s ease-out 2; }
@keyframes cs-ring { 0% { opacity: .7; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes cs-shake { 0%, 60%, 100% { transform: rotate(0); } 10%, 30%, 50% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } }
@keyframes cs-flash { 0% { box-shadow: inset 3px 0 0 var(--cs), inset 0 0 0 999px color-mix(in oklab, var(--cs) 16%, transparent); } 100% { box-shadow: inset 3px 0 0 var(--cs), inset 0 0 0 999px transparent; } }
@keyframes cs-drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* a call card between the messages */
.msg-call { align-self: center; display: flex; align-items: flex-start; gap: 8px; max-width: min(520px, 92%); margin: 10px 0 4px; padding: 7px 12px; border-radius: 10px; background: var(--chat-pill); color: var(--chat-pill-ink); box-shadow: var(--chat-shadow); font-size: 12.5px; line-height: 1.35; border-left: 3px solid var(--muted); }
.msg-call.tone-ok { border-left-color: var(--ok); }
.msg-call.tone-warn { border-left-color: var(--warn); }
.msg-call.tone-bad { border-left-color: var(--bad); }
.msg-call.tone-live, .msg-call.tone-info { border-left-color: var(--info); }
.mc-icon { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: color-mix(in oklab, var(--text) 6%, transparent); }
.msg-call.tone-ok .mc-icon { color: var(--ok); }
.msg-call.tone-warn .mc-icon { color: var(--warn); }
.msg-call.tone-bad .mc-icon { color: var(--bad); }
.msg-call.tone-live .mc-icon, .msg-call.tone-info .mc-icon { color: var(--info); }
.mc-icon svg { width: 12px; height: 12px; }
.mc-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mc-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.mc-line time { opacity: .75; font-size: 11.5px; }
.mc-notes { white-space: pre-line; overflow-wrap: anywhere; opacity: .9; }

/* chat list: someone called them lately */
.call-mark { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.call-mark svg { width: 10px; height: 10px; }
.call-mark.tone-warn { background: var(--warn-soft); color: var(--warn); }
.call-mark.tone-bad { background: var(--bad-soft); color: var(--bad); }
.call-mark.tone-info { background: var(--info-soft); color: var(--info); }

/* chat list: where the lead stands (stage, else the last call's result), right after the name */
.inbox-line:first-child .inbox-name { flex: 0 1 auto; }
.inbox-line:first-child .inbox-time { margin-left: auto; }
.lead-chip { --c: var(--muted); flex: 0 1 auto; min-width: 0; max-width: 46%; display: inline-flex; align-items: center; gap: 4px;
  padding: 0 7px 0 6px; height: 19px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1;
  color: color-mix(in oklab, var(--c) 82%, var(--text)); background: color-mix(in oklab, var(--c) 13%, transparent);
  border: 1px solid color-mix(in oklab, var(--c) 30%, transparent); }
.lead-chip-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.lead-chip svg { flex: none; width: 11px; height: 11px; }
.lead-chip.tone-ok { --c: var(--ok); }
.lead-chip.tone-warn { --c: var(--warn); }
.lead-chip.tone-bad { --c: var(--bad); }
.lead-chip.tone-info { --c: var(--info); }

@media (max-width: 767px) {
  .cs-main { padding: 5px 8px; gap: 8px; }
  .cs-list { padding: 4px 8px 10px 40px; }
  .cs-dot { margin-left: -30px; }
  .call-strip.is-none .cs-when { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .call-strip .cs-icon::after, .call-strip .cs-icon svg, .call-strip, .cs-list { animation: none !important; }
}

/* inbox side panel: the person's details from the workspace's own fields (apps/kits) */
.kis h4 { display: flex; align-items: center; gap: 6px; }
.kis-edit { margin-left: auto; font-size: 12px; font-weight: 600; }
.kis-sec { margin-top: 8px; }
.kis-sec-name { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.kis .ic-kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- 8 Nov 2026, owner: nothing may sit on top of the messages ----
   the day label stays in its place in the chat (it covered the first lines while it floated); "open in Meta's app"
   lives in the composer's bottom bar, the same place for Messenger and WhatsApp; the paid-template help folds away. */
.msg-open-app { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; height: 30px; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap; background: var(--ch); color: var(--on-brand); }
.msg-open-app svg { width: 14px; height: 14px; }
.msg-open-app + .msg-send-error { flex-basis: 100%; }
.msg-open-note { flex-basis: 100%; text-align: right; color: var(--muted); font-size: 12px; line-height: 1.35; }
.msg-counter:empty { display: none; }
.msg-composer:not(:has(input[name="channel"][value="sms"]:checked)) .msg-counter { display: none; }
.msg-wa-tpl > summary { list-style: none; cursor: pointer; padding: 4px 0; }
.msg-wa-tpl > summary::-webkit-details-marker { display: none; }
.msg-wa-tpl > summary small { font-weight: 500; color: var(--muted); }
.msg-wa-chev { margin-left: auto; transition: transform .2s ease; }
.msg-wa-tpl[open] .msg-wa-chev { transform: rotate(180deg); }
@media (max-width: 760px) {
  .thread-open-app { display: none; }
  /* calls and flags: one slim line each, the chat keeps the screen */
  .cs-main { min-height: 40px; padding: 4px 10px; gap: 8px; }
  .cs-box:not([open]) .cs-hint, .cs-box:not([open]) .cs-notes { display: none; }
  .cs-line { flex-wrap: nowrap; overflow: hidden; }
  .cs-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cs-when { white-space: nowrap; }
  .call-strip.is-none .cs-when { display: none; }
  .call-strip.is-none .cs-side .btn { height: 34px; padding: 0 12px; }
}
/* after the 24 hours: "Reply in Messenger" and "Reply in WhatsApp" look the same and sit in the same place, the paid
   template folds into a quiet line under it (owner, 8 Nov 2026: the orange box took half the screen) */
.msg-wa-picker { border: 0; background: transparent; padding: 0; }
.msg-wa-picker .msg-wa-free { background: var(--chat-unread); border-color: transparent; color: var(--chat-on-unread); }
.msg-wa-picker .msg-wa-free small { color: inherit; opacity: .9; }
.msg-wa-tpl { border-top: 1px dashed var(--border); padding-top: 4px; }
.msg-wa-tpl > summary { color: var(--text-2); font-weight: 600; }
.msg-wa-tpl[open] { padding-bottom: 8px; }
@media (max-width: 760px) {
  .cs-log { width: 34px; height: 34px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .cs-log svg { width: 16px; height: 16px; }
  .cs-more { padding: 3px 4px; }
}
/* phone: a chip with nothing in it (0) waits off screen; the rest stay all in view, a little tighter, so the chats
   start higher (owner, 8 Nov 2026: 12 chips over four rows left room for three chats) */
@media (max-width: 760px) {
  .lead-chips .ib-ch.is-zero { display: none; }
  .lead-chips { row-gap: 5px; gap: 5px; padding-bottom: 8px; }
  .lead-chips .ib-ch { height: 28px; padding: 0 9px; font-size: 12.5px; }
  .lead-chips .ib-ch svg { width: 14px; height: 14px; }
}
.thread-more { display: none; position: relative; }
.thread-more > summary { list-style: none; }
.thread-more > summary::-webkit-details-marker { display: none; }
.thread-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 6px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop); }
.thread-more-menu form { margin: 0; }
.thread-more-item { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; }
.thread-more-item:hover { background: var(--surface-2); }
.thread-more-item.is-danger { color: var(--bad); }
@media (max-width: 760px) {
  .thread-actions .star-btn, .thread-actions .block-btn { display: none; }
  .thread-more { display: block; }
}

/* Chat header (owner, 9 Nov 2026: "the name doesn't even show"). The name comes first: the 24h timer sits in the
   small line under it, "Open in WhatsApp" lives only beside the composer, and the action buttons drop their words
   when the chat column is narrow — measured on the column itself, not the screen (the contact panel takes room). */
.inbox-thread { container: thread / inline-size; }
.thread-person { min-width: 140px; }
.thread-person .person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-window-mini { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-weight: 600; }
.wa-window-mini.open { color: var(--ok); }
.wa-window-mini.closed { color: var(--warn); }
.wa-window-mini .icon-xs, .wa-window-mini svg { width: 13px; height: 13px; }
.thread-person .person-sub { overflow: hidden; white-space: nowrap; }
@container thread (max-width: 1040px) {
  .thread-head .lbl-wide { display: none; }
  .thread-actions .thread-assign .select-sm { width: 150px; }
}
@container thread (max-width: 700px) {
  .thread-actions .thread-assign .select-sm { width: 44px; padding: 0; color: transparent; background: transparent; background-image: none; border-color: transparent; text-indent: -999px; cursor: pointer; }
  .thread-actions .thread-assign .select-sm option { color: var(--text); text-indent: 0; }
  .thread-assign > i, .thread-assign > svg { left: 50%; transform: translateX(-50%); width: 20px; height: 20px; color: var(--text); }
  .thread-assign.is-set > i, .thread-assign.is-set > svg { color: var(--accent); }
}

/* line 2 under the name: number and timer never shrink; "on <page> · <business>" gives way first. A name of any
   length stays on one line with "…"; hovering shows it whole, and the contact panel always has it in full. */
.thread-person .person-sub { gap: 4px; }
.thread-phone { flex: none; color: var(--text); opacity: .78; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.wa-window-mini { flex: none; }
.person-sub .sep { margin: 0 4px 0 2px; color: var(--muted); font-weight: 400; }
.thread-sub-rest { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* narrow (a phone): the number must never be cut; the timer is already above the composer, so it steps aside */
@container thread (max-width: 520px) {
  .thread-sub-rest, .wa-window-mini { display: none; }
  .thread-phone { font-size: 12.5px; letter-spacing: 0; }
  .thread-person .person-sub { gap: 3px; }
  .thread-person .avatar { width: 36px; height: 36px; font-size: 13px; }
  .thread-person { gap: 8px; min-width: 0; }
}
.thread-more-menu .more-close { display: none; }
@container thread (max-width: 400px) {
  .thread-actions .thread-close { display: none; }
  .thread-more-menu .more-close { display: block; }
  .thread-actions { gap: 0; }
}

/* Fit the screen whatever sits above the inbox (owner, 9 Nov 2026: with the impersonation bar and the "confirm your
   email" banner the box to type in was pushed below the screen). The page itself never scrolls: the main column is
   exactly one screen tall, banners and notices take what they need, and the inbox gets the rest. */
@media (min-width: 761px) {
  body.page-inbox { --imp-h: 0px; overflow: hidden; }
  body.page-inbox:has(.pf-imp-banner) { --imp-h: 32px; }
  .page-inbox .main { height: calc(100vh - var(--imp-h)); height: calc(100dvh - var(--imp-h)); min-height: 0; }
  .page-inbox .content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .page-inbox .content > .inbox { flex: 1 1 auto; height: auto; min-height: 0; }
  /* notices above the inbox: one slim line each, edge to edge, so they cost as little height as possible */
  .page-inbox .content > .alert { flex: none; margin: 0; border-radius: 0; border-left: 0; border-right: 0; padding-top: 6px; padding-bottom: 6px; }
  .page-inbox .content > .alert + .alert { border-top: 0; }
}
/* phone: the same fit above the bottom tab bar (a notice above the list made the whole page scroll as well) */
@media (max-width: 760px) {
  .page-inbox .main { height: calc(100dvh - var(--pwa-tabbar-h, 72px) - env(safe-area-inset-bottom)); min-height: 0; }
  .page-inbox .content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-bottom: 0; }
  .page-inbox .content > .inbox { flex: 1 1 auto; height: auto; min-height: 0; }
  .page-inbox .content > .alert { flex: none; margin: 0; border-radius: 0; border-left: 0; border-right: 0; padding: 8px 12px; font-size: 13px; }
}

/* Phones and the EdTech dashboard's frame (14 Nov 2026, checked at 320-414 px): the composer's tools leave the
   message box more room. */
@media (max-width: 400px) {
  .msg-composer-tools { gap: 0; }
  .msg-composer-tools .msg-tool { width: 38px; }
}
@media (max-width: 360px) {
  .msg-composer-tools .msg-vars { display: none; }   /* {{name}} can still be typed; the box needs the room */
}

/* ---------- Another chat opens at once (inbox-nav.js, owner 14 Nov 2026) ----------
   At the tap: the person's name and photo over a soft skeleton of bubbles (it fades in only if the wait is
   noticeable); then the messages fade in. A phone slides the chat in over the list. */
.thread-skel { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: var(--chat-wall); }
.thread-skel-head { flex: none; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 14px; background: var(--ib-bar); border-bottom: 1px solid var(--border); }
.thread-skel-head .avatar { width: 40px; height: 40px; font-size: 14px; flex: none; }
.thread-skel-head .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.thread-skel-name { min-width: 0; font-weight: 700; font-size: 15px; color: var(--text); }
.thread-skel-back { display: none; }
.thread-skel-body { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; padding: 18px 16px; opacity: 0; animation: skel-show .25s ease .18s forwards; }
.thread-skel-body .skel-b { height: 36px; border-radius: 10px; max-width: 420px; }
.thread-skel-body .skel-b.in { align-self: flex-start; border-top-left-radius: 3px; }
.thread-skel-body .skel-b.out { align-self: flex-end; border-top-right-radius: 3px; }
.thread-skel-foot { flex: none; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--ib-bar); border-top: 1px solid var(--border); }
.thread-skel-foot .skeleton { height: 44px; border-radius: 22px; opacity: .7; }
@keyframes skel-show { to { opacity: 1; } }
.inbox.is-chat-switching .inbox-contact > * { opacity: .25; transition: opacity .15s ease; }   /* the last person's details step back */
.inbox.is-chat-arrived .msg-thread, .inbox.is-chat-arrived .inbox-contact > * { animation: chat-arrive .2s ease-out; }
@keyframes chat-arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes chat-enter { from { transform: translateX(100%); } to { transform: none; } }
@keyframes chat-leave { to { transform: translateX(100%); } }
@media (max-width: 760px) {
  .thread-skel-head { gap: 2px; padding: max(6px, env(safe-area-inset-top)) 4px 6px 4px; }
  .thread-skel-head .avatar { width: 36px; height: 36px; font-size: 13px; margin: 0 8px 0 4px; }
  .thread-skel-back { display: inline-flex; }
  .inbox.is-chat-entering .inbox-thread { animation: chat-enter .23s cubic-bezier(.2, .75, .25, 1); box-shadow: var(--shadow-lg); }
  .inbox.is-chat-open.is-chat-entering .inbox-list, .inbox.is-chat-open.is-chat-leaving .inbox-list { display: flex; }   /* the list stays behind while the chat slides in or out */
  .inbox.is-chat-leaving .inbox-thread { animation: chat-leave .19s cubic-bezier(.4, 0, .7, .2) forwards; box-shadow: var(--shadow-lg); }
}
@media (prefers-reduced-motion: reduce) {
  .thread-skel-body { animation: none; opacity: 1; }
  .inbox.is-chat-arrived .msg-thread, .inbox.is-chat-entering .inbox-thread, .inbox.is-chat-leaving .inbox-thread { animation: none; }
}

/* the foot of the chat list: older chats load as it is scrolled (messaging.js); the button is also pressable */
.ib-list-more { display: flex; align-items: center; justify-content: center; width: calc(100% - 16px); min-height: 44px; margin: 4px 8px 12px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.ib-list-more:hover { background: color-mix(in oklab, var(--text) 5%, var(--surface)); color: var(--text); }
.ib-list-more .ib-list-more-on { display: none; }
.ib-list-more.is-loading .ib-list-more-on { display: inline; }
.ib-list-more.is-loading .ib-list-more-off { display: none; }
.ib-list-more.is-loading { cursor: progress; }
.ib-list-more.is-failed .ib-list-more-off::after { content: " (try again)"; }

/* ---------- the chat keeps the screen (Upbeat's owner + owner, 24 Nov 2026) ----------
   Every list a chat is on (Handover to Human, Complaint, Stock out, Wants to talk…) was a bar of its own: three on top,
   two big ones above the box, and the messages got what was left. Now:
   - one slim row of chips right above the message box (messaging/_chat_tasks.html), where the thumb is: icon, a few
     words, how long ago, and the one button (Human reply done, Issue resolved, Done). The words open the full note and
     the other buttons ABOVE the row, over the foot of the chat, so nothing moves. Several chips scroll sideways.
   - the call button sits in the header, as in WhatsApp and Messenger; "Not called yet" has no row any more
   - the AI about to answer is Messenger's "typing…" bubble floating at the foot of the chat, not a sentence */
.chat-foot { position: relative; }
.chat-tasks { position: relative; margin: 0 0 6px; }   /* the notes open above it, measured from here */
.ct-row { display: flex; gap: 6px; padding: 1px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.ct-row::-webkit-scrollbar { display: none; }
.ct { --ct: var(--warn); --ct-soft: var(--warn-soft); flex: none; display: flex; align-items: center; gap: 2px; max-width: 100%; height: 36px; margin: 0; padding: 0 3px 0 0; border-radius: 999px; background: var(--ct-soft); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ct) 24%, transparent); }
.ct:only-child { flex: 1 1 auto; }
.ct.tone-bad { --ct: var(--bad); --ct-soft: var(--bad-soft); }
.ct.tone-ok { --ct: var(--ok); --ct-soft: var(--ok-soft); }
.ct.tone-info { --ct: var(--info); --ct-soft: var(--info-soft); }
.ct-info { flex: 1 1 auto; min-width: 0; }   /* not positioned: its note is placed against the whole row */
.ct-head { display: flex; align-items: center; gap: 6px; height: 34px; min-width: 0; padding: 0 8px 0 11px; border-radius: 999px; list-style: none; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; user-select: none; }
.ct-head::-webkit-details-marker { display: none; }
.ct-head > svg:first-child, .ct-head > i:first-child { flex: none; width: 16px; height: 16px; color: var(--ct); }
.ct-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ct-when { flex: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.ct-chev { flex: none; width: 14px; height: 14px; color: var(--muted); }
.ct-info[open] .ct-head { background: color-mix(in oklab, var(--ct) 14%, transparent); }
.ct-head:focus-visible, .ct-go:focus-visible { outline: 3px solid var(--ring); outline-offset: 1px; }
.ct-go { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--ok); color: var(--on-status); font: inherit; font-size: 12.5px; font-weight: 700; white-space: nowrap; cursor: pointer; transition: background-color .15s, transform .1s; }
.ct-go:hover { background: color-mix(in oklab, var(--ok) 86%, var(--text)); }
.ct-go:active { transform: scale(.96); }
.ct-go.is-danger { background: var(--bad); }
.ct-go.is-danger:hover { background: color-mix(in oklab, var(--bad) 86%, var(--text)); }
.ct-go svg, .ct-go [data-lucide] { width: 15px; height: 15px; }
.ct-short { display: none; }
.ct-row > .ct:not(:only-child) .ct-long { display: none; }    /* several chips: the short word, so they fit */
.ct-row > .ct:not(:only-child) .ct-short { display: inline; }
.ct-state { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; color: var(--ok); font-size: 12.5px; font-weight: 700; }
.ct-state svg { width: 14px; height: 14px; }
.ct-more { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20; display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-pop); color: var(--text); font-size: 13.5px; line-height: 1.45; white-space: normal; animation: ct-in .14s ease-out; }
.ct-more p { margin: 0; }
.ct-how { color: var(--text-2, var(--muted)); }
.ct-more .flag-ok { color: var(--ok); font-weight: 600; white-space: nowrap; }
.ct-more .flag-miss { color: var(--muted); white-space: nowrap; }
.ct-btns { display: flex; flex-wrap: wrap; gap: 6px; }
@keyframes ct-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* the call button in the header; the empty "Not called yet" row is gone (a real call still shows its strip) */
.call-strip.is-none { display: none; }
.thread-call { display: inline-flex; }
.thread-call .btn.icon-btn { width: 40px; min-width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ok); box-shadow: none; }
.thread-call .btn.icon-btn:hover { background: color-mix(in oklab, var(--text) 7%, transparent); color: var(--ok); }
.thread-call .btn svg, .thread-call .btn [data-lucide] { width: 20px; height: 20px; }

/* "AI typing…": floats over the foot of the chat; the chat gets the room back underneath it */
.ai-typing { position: absolute; left: 12px; bottom: calc(100% + 8px); z-index: 5; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 9px; border-radius: 999px; background: var(--chat-in, var(--surface-2)); box-shadow: var(--shadow-xs); color: var(--muted); font-size: 12px; font-weight: 700; pointer-events: none; animation: ct-in .2s ease-out; }
.ai-typing-who { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); }
.ai-typing-who svg, .ai-typing-who [data-lucide] { width: 13px; height: 13px; }
.ai-dots { display: inline-flex; gap: 3px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: ai-dot 1.2s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.inbox-thread:has(.ai-typing) .msg-thread { padding-bottom: 46px; }

/* the 24-hour line: only in its last two hours (the header says "24h open" the rest of the time) */
.msg-window.soon { background: var(--warn-soft); color: var(--warn); margin: 0 0 6px; padding: 3px 10px; }

/* "+" (phone): attach, templates, variables and the send-through row fold behind it, as in WhatsApp */
.msg-plus { display: none; }
@media (max-width: 760px) {
  .chat-foot .msg-plus { display: inline-grid; transition: transform .15s; }
  .chat-foot .msg-composer:not(.tools-open) .msg-composer-tools > :not(.msg-plus) { display: none; }
  .chat-foot .msg-composer:not(.tools-open) .msg-channels,
  .chat-foot .msg-composer:not(.tools-open) .msg-open-app { display: none; }
  .chat-foot .msg-composer.tools-open .msg-plus { transform: rotate(45deg); color: var(--text); }
  .chat-foot .msg-composer.tools-open .msg-composer-row { flex-wrap: wrap; }
  .chat-foot .msg-composer.tools-open .msg-composer-tools { flex-basis: 100%; order: -1; }
  .chat-foot .msg-composer-foot { min-height: 0; margin-top: 0; }
  .chat-foot .msg-composer.tools-open .msg-composer-foot { margin-top: 6px; }
  .thread-call .btn.icon-btn { width: 44px; min-width: 44px; height: 44px; }
}
@media (pointer: coarse) {
  .ct { height: 40px; }
  .ct-head { height: 38px; }
  .ct-go { height: 34px; }
}
@media (prefers-reduced-motion: reduce) { .ct-more, .ai-typing, .ai-dots i { animation: none; } .ct-go { transition: none; } }
