/* Inbox on a phone: master-detail layout, the conversation (floating header, thread, bubbles) and the composer.
   Split #7 of index.html: moved unchanged, wrapped in the same @media it sat in, and linked at the exact spot it
   used to sit (the big phone block is closed and reopened around the link) so the cascade order is the same. */
@media (max-width: 768px) {
    /* ════════════════════════════════════════════════════════════════
       G4. Inbox page
    ════════════════════════════════════════════════════════════════ */
    /* ── MASTER-DETAIL: mobile shows ONE pane at a time ──
       Default = the conversation list (master). Tapping a conversation adds
       .inbox-thread-open (in selectInboxContact) → the list hides and the
       thread (center) takes over full-screen; the back button in the thread
       header (inboxBackToList) returns to the list. All scoped to ≤768px, so
       the desktop 3-pane layout is completely untouched. */
    .inbox-layout {
      flex-direction: column; overflow: hidden; gap: 0;
      padding: 8px 8px max(10px, var(--safe-bottom));
    }
    .inbox-left {
      width: 100% !important; max-width: 100% !important;
      flex: 1 1 auto !important; min-height: 0 !important;
      border-radius: 14px !important;
    }
    .inbox-center, .inbox-right { display: none !important; }
    .inbox-layout.inbox-thread-open .inbox-left { display: none !important; }
    .inbox-layout.inbox-thread-open .inbox-center {
      display: flex !important; flex: 1 1 auto !important;
      width: 100% !important; max-width: 100% !important;
      min-height: 0 !important; border-radius: 14px !important;
    }
    /* Swipe-back drag in progress: the list has no transform/transition of
       its own (it's a plain display:none↔flex toggle) — while the thread is
       being dragged off, force the list to render absolutely UNDERNEATH it
       so it's visible behind the finger, Telegram-style. Cleared once the
       gesture ends either way. */
    .inbox-layout.inbox-thread-open .inbox-left.swipe-reveal {
      display: flex !important;
      position: absolute; inset: 0; z-index: 0;
    }
    .inbox-layout.inbox-thread-open .inbox-center { position: relative; z-index: 1; }
    /* ── 1b · The conversation (design_handoff_inbox_refresh §4) ────────────
       FULL SCREEN. The brand bar and the tab bar both go while a conversation
       is open — production kept the brand bar, which cost 46px of thread on a
       phone to repeat a logo you were not looking at. The status-bar strip is
       left transparent over the thread, so the pattern runs to the top edge.

       An open thread PINS its header and composer and scrolls only the messages,
       opening at the newest. That overrides the mobile body-scroll model just for
       this one screen, which is why it is fixed rather than in flow. */
    .inbox-layout.inbox-thread-open {
      position: fixed !important;
      top: 0; left: 0; right: 0; bottom: 0;
      z-index: 1000; height: auto !important; min-height: 0 !important;
      background: var(--bg);
    }
    /* The page behind an open conversation must not scroll. iOS 26 misplaces
       the caret in a fixed view's field whenever the page under it has a
       scroll offset (the text box cut off, the cursor floating below it over
       the keyboard). The keyboard code also pins the page back to the top. */
    html:has(.inbox-layout.inbox-thread-open),
    body:has(.inbox-layout.inbox-thread-open) { overflow: hidden !important; overscroll-behavior: none; }
    body:has(.inbox-layout.inbox-thread-open) .mtop-bar,
    body:has(.inbox-layout.inbox-thread-open) .mtab-bar,
    body:has(.inbox-layout.inbox-thread-open) .mtab-fade { display: none !important; }
    .inbox-layout.inbox-thread-open .inbox-center {
      height: 100% !important; border-radius: 0 !important;
    }
    .inbox-layout.inbox-thread-open .inbox-thread-body {
      flex: 1 1 auto !important; min-height: 0 !important;
      overflow-y: auto !important; -webkit-overflow-scrolling: touch;
    }
    /* ── iOS keyboard-aware composer ──────────────────────────────────────
       iOS Safari never resizes the layout viewport when the keyboard opens —
       it draws the keyboard on top of the page. A composer pinned to the
       bottom of that (unchanged) layout viewport renders UNDER the keyboard,
       invisible. --kb-height is written by the visualViewport tracker below
       (0px whenever this composer's field isn't the focused, keyboard-open
       field) and lifts the composer to sit just above the keyboard instead.
       The thread body is flex:1 with min-height:0 above it, so it simply
       shrinks to make room rather than being pushed off-screen. The keyboard
       covers the home-indicator area itself, so the safe-area inset is dropped
       (not added) while it's up — otherwise the gap is double-counted. */
    .inbox-layout.inbox-thread-open .inbox-compose {
      flex-shrink: 0;
      margin-bottom: var(--kb-height, 0px);
      transition: margin-bottom 120ms ease-out;
    }
    body.kb-open .inbox-layout.inbox-thread-open .inbox-compose {
      padding-bottom: 10px !important;
    }
    /* The bottom tab bar would otherwise sit sandwiched between the lifted
       composer and the keyboard — every messaging app hides its tab chrome
       the instant typing starts, so this does the same, and only while this
       composer's own field is the one focused (kb-open is scoped to it, not
       to any keyboard anywhere in the app). */
    body.kb-open .mtab-bar, body.kb-open .mtab-fade { display: none !important; }
    /* ...and the room reserved for it has to go with it. --tabbar-space pads the
       body so content clears the floating bar; while the keyboard is up the bar
       is hidden, so that padding is 88px of nothing sitting UNDER the composer,
       pushing it down behind the keyboard. Ruby caught the composer sliced in
       half mid-word on his phone. Hiding the bar without releasing its space is
       only half the job. */
    body.kb-open { padding-bottom: 0 !important; }
    /* Don't let the global hamburger float over the open chat / contact screen */
    body:has(.inbox-layout.inbox-thread-open) #mobile-menu-btn,
    body.ics-open #mobile-menu-btn { display: none !important; }
    /* The thread surface + the illustrated tile, same art as desktop but tiled at
       360px for a 393px screen. A pseudo-element rather than a background layer:
       it must sit BEHIND the messages, hold still while they scroll, and carry
       mix-blend-mode, which a background layer cannot do on its own. One mask
       only (vertical): a phone is too narrow to give up 120px to a side fade. */
    .inbox-layout.inbox-thread-open .inbox-center {
      position: relative; isolation: isolate;
      background: var(--c-thread-base);
    }
    .inbox-layout.inbox-thread-open .inbox-center::before {
      content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
      background-image: url("assets/chat-pattern.jpg");
      background-size: 360px 360px; background-repeat: repeat;
      opacity: var(--c-pat-op); filter: var(--c-pat-filter); mix-blend-mode: var(--c-pat-blend);
      -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 110px, #000 calc(100% - 120px), transparent 100%);
              mask-image: linear-gradient(180deg, transparent 0, #000 110px, #000 calc(100% - 120px), transparent 100%);
    }
    @media (prefers-reduced-transparency: reduce) {
      .inbox-layout.inbox-thread-open .inbox-center::before { display: none; }
    }
    /* ── Floating header: three glass pieces over the thread ────────────────
       Back pill · name pill · ⋯ circle. Messages scroll underneath all three.
       Same glass recipe as the desktop pills and the tab bar (--c-head-glass),
       so every frosted surface in this app is cut from one material. */
    .inbox-layout.inbox-thread-open .inbox-thread-header {
      position: absolute; top: calc(var(--safe-top) + 4px); left: 10px; right: 10px; z-index: 30;
      padding: 0 !important; gap: 6px !important; align-items: center !important;
      background: none !important; border-bottom: none !important; box-shadow: none !important;
    }
    [data-theme="dark"] .inbox-layout.inbox-thread-open .inbox-thread-header {
      background: none !important; border-bottom: none !important; box-shadow: none !important;
    }
    .inbox-layout.inbox-thread-open .inbox-thread-header .thread-pill,
    .inbox-layout.inbox-thread-open .inbox-back-btn,
    .inbox-layout.inbox-thread-open .thread-circ-btn {
      background: var(--c-head-glass);
      border: 1px solid var(--border2);
      box-shadow: 0 2px 12px rgba(24,24,27,0.07);
      backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
    }
    /* Back pill: the chevron plus how many OTHER conversations are still unread,
       so leaving this one is a decision you can make without going back to look. */
    .inbox-thread-header .inbox-back-btn { display: inline-flex !important; }
    .inbox-layout.inbox-thread-open .inbox-back-btn {
      height: 44px !important; min-height: 44px !important; min-width: 44px !important; width: auto !important;
      padding: 0 12px 0 8px !important; border-radius: 22px !important;
      gap: 1px; flex-shrink: 0; align-items: center; justify-content: center;
      color: var(--text2) !important; font-size: 14px; line-height: 1; font-weight: 600; font-family: inherit;
    }
    .inbox-layout.inbox-thread-open .inbox-back-btn svg { width: 22px !important; height: 22px !important; stroke-width: 2.2; }
    .inbox-back-count:empty { display: none; }
    /* Name pill. Tapping it opens the contact screen (1c) — the whole pill, not a
       word inside it, because a 15px name is not a tap target. */
    .inbox-layout.inbox-thread-open .inbox-thread-header .thread-pill-left {
      display: flex !important; flex: 1; min-width: 0;
      height: 44px; border-radius: 22px; gap: 8px; padding: 0 12px 0 6px; align-items: center;
    }
    .inbox-layout.inbox-thread-open .inbox-thread-header .thread-pill-right {
      display: flex !important; flex-shrink: 0; gap: 0; padding: 0;
      background: none; border: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
    }
    /* The panel toggle is a three-column desktop control — there is no third
       column on a phone, and the ⋯ menu carries Contact info instead. */
    .inbox-layout.inbox-thread-open #thread-panel-btn,
    .inbox-layout.inbox-thread-open #pace-panel-btn,
    .inbox-layout.inbox-thread-open .thread-circ-gap { display: none !important; }
    .inbox-layout.inbox-thread-open .thread-circ-btn {
      width: 44px !important; height: 44px !important; min-height: 44px !important; border-radius: 50% !important;
      color: var(--text2) !important;
    }
    .inbox-layout.inbox-thread-open .thread-circ-btn svg { width: 20px !important; height: 20px !important; }
    .inbox-layout.inbox-thread-open .thread-circ-btn.is-on { background: var(--bg3) !important; }
    .inbox-thread-header .thread-avatar {
      width: 32px !important; height: 32px !important; border-radius: 50% !important;
      font-size: 12px !important; position: relative; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
      background: var(--bg3) !important; color: var(--text2) !important;
    }
    .inbox-thread-header .thread-id { cursor: pointer; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
    .inbox-thread-header .thread-id > div:first-child { flex-wrap: nowrap !important; min-width: 0; overflow: hidden; }
    .inbox-thread-header .thread-stage-badge { display: none !important; }
    .inbox-thread-header #inbox-thread-ai-badge { display: none !important; }
    .inbox-thread-header .thread-name {
      font-size: 14.5px !important; font-weight: 600 !important; letter-spacing: -0.01em;
      line-height: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* Status line: [message-square] SMS · [bot] Pace is replying */
    .inbox-thread-header .thread-sub {
      display: flex !important; align-items: center; gap: 4px;
      font-size: 11px; line-height: 14px; color: var(--text2); margin: 0;
      white-space: nowrap; overflow: hidden;
    }
    .inbox-thread-header .thread-sub svg { width: 10px; height: 10px; flex-shrink: 0; }
    /* Declutter (phone only): the Pace state pill ("You've taken over" / "Pace is
       on", same right-hand slot) and the DND chip are hidden here. They are only
       hidden, never removed — inboxSyncPacePill and inboxToggleDnd still write to
       them, and the ⋯ menu carries the actions. Desktop rules are untouched. */
    .inbox-thread-header .thread-pace-state,
    .inbox-thread-header .thread-dnd { display: none !important; }
    /* Name left on one line (ellipsis), channel label pinned far right of the pill.
       The label never shrinks, so the name is what gives way: no overlap. */
    .inbox-layout.inbox-thread-open .inbox-thread-header .thread-id-row { display: flex; flex-direction: row; align-items: center; gap: 8px; min-width: 0; }
    .inbox-layout.inbox-thread-open .inbox-thread-header .thread-id-row .thread-name { flex: 0 1 auto; min-width: 0; max-width: 100%; }
    .inbox-layout.inbox-thread-open .inbox-thread-header .thread-id-row .thread-sub {
      flex: 0 0 auto; margin-left: auto; justify-content: flex-end; max-width: 55%; min-width: 0;
    }
    .inbox-thread-header .inbox-action-btns { display: none !important; }
    /* The ⋯ menu — 246 wide, 44px rows, anchored under the circle. It is
       position:fixed rather than absolute: the header is a floating strip 10px
       from each edge, and an absolutely-positioned menu inside it would be
       clipped by the pill it hangs from. */
    /* NOT position:fixed: the header pill carries backdrop-filter / will-change, which makes
       the pill the containing block, so 'fixed' + a safe-top offset was measured from the pill
       and the menu opened 55-70px too low. Anchor to the ⋯ button's own wrapper instead: the
       top edge is always 8px under the circle, on every iPhone, with or without a notch. */
    .inbox-layout.inbox-thread-open .thread-more-wrap { position: relative; display: flex; }
    .inbox-layout.inbox-thread-open .thread-more-menu {
      position: absolute; top: calc(100% + 8px); right: 0; left: auto; padding-top: 0; z-index: 30;
    }
    /* The menu hangs from the 44px ⋯ circle, and the page-wide phone rule
       '.main * { max-width:100% }' capped it to that circle: a 44px-wide menu with
       every label wrapped under its icon (Reuven's phone, 20 Oct). It is position:fixed,
       so its width has nothing to do with its parent. */
    .inbox-layout.inbox-thread-open .thread-more-menu,
    .inbox-layout.inbox-thread-open .thread-more-menu * { max-width: none; }
    .inbox-layout.inbox-thread-open .thread-more-menu-inner {
      width: 246px; max-width: calc(100vw - 20px); display: flex; flex-direction: column; padding: 7px; gap: 2px; border-radius: 14px;
      /* Same frosted glass as the Dashboard's ⋯ menu, but nearly solid: since 26 Oct the menu sits
         INSIDE the floating glass header (position:absolute), and a backdrop-filter nested in another
         one can't blur the thread behind, so the see-through fill let messages show through the rows
         (Reuven's phone, 2 Nov). Keep this fill opaque. */
      background: color-mix(in srgb, var(--bg) 94%, transparent); box-shadow: var(--glass-edge), var(--glass-shadow);
      backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    }
    .inbox-layout.inbox-thread-open .thread-more-menu button {
      display: flex; align-items: center; width: 100%; white-space: nowrap; text-align: left;
      border: none; background: none; font: inherit; color: var(--text); cursor: pointer;
      height: 42px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500; gap: 10px;
    }
    .inbox-layout.inbox-thread-open .thread-more-menu button svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text2); }
    .inbox-layout.inbox-thread-open .thread-more-menu button:active { background: var(--accent-soft); color: var(--accent); }
    .inbox-layout.inbox-thread-open .thread-more-menu button:active svg { color: var(--accent); }
    .inbox-layout.inbox-thread-open .thread-more-menu button.primary svg { color: var(--accent); }
    .inbox-layout.inbox-thread-open .thread-more-menu button.primary { color: var(--accent); font-weight: 600; }
    /* no divider lines, like the Dashboard menu */
    .inbox-layout.inbox-thread-open .thread-more-menu .tmm-div { display: none; }
    /* ── Thread ─────────────────────────────────────────────────────────────
       116px of top padding is what clears the floating header: the messages
       genuinely scroll under it rather than starting below it. */
    .inbox-layout.inbox-thread-open .inbox-thread-body,
    .inbox-layout.inbox-thread-open .inbox-thread-body.thread-canvas,
    [data-theme="dark"] .inbox-layout.inbox-thread-open .inbox-thread-body,
    [data-theme="dark"] .inbox-layout.inbox-thread-open .inbox-thread-body.thread-canvas {
      padding: 116px 12px 12px; gap: 8px;
      background: none; background-image: none;
    }
    /* UI fix #22 (26 Nov 2026): on the Chats list the glass buttons float over the rows, and
       after a scroll the names showed straight through them. The rows now dissolve under the
       button row (the same page-colour fade the contact screen uses behind its back button). */
    html body #page-inbox .inbox-mtitle .inbox-mrow1::before {
      content: ''; position: absolute; left: 0; right: 0; z-index: -1; pointer-events: none;
      top: calc(-1 * var(--safe-top)); height: calc(var(--safe-top) + 76px);
      background: linear-gradient(180deg, var(--bg2) 0, var(--bg2) calc(var(--safe-top) + 50px), transparent 100%);
    }
    /* UI fix #18 (26 Nov 2026): what scrolls up under the floating header fades
       out just below it, so a date pill never reads as sitting under the
       header's buttons. It stops well above the 116px the first message starts
       at, so nothing at rest is faded. Only the mask's opacity counts, so any
       opaque token does for its colour. */
    .inbox-layout.inbox-thread-open .inbox-thread-body.thread-canvas {
      -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent calc(var(--safe-top) + 48px), var(--text) calc(var(--safe-top) + 64px));
              mask-image: linear-gradient(to bottom, transparent 0, transparent calc(var(--safe-top) + 48px), var(--text) calc(var(--safe-top) + 64px));
    }
    .inbox-layout.inbox-thread-open .msg-date-div { font-size: 12px; font-weight: 500; border-radius: 20px; padding: 3px 12px; }
    /* Bubbles. `display:flow-root` is what lets the floated timestamp sit on the
       last line of text and still be contained by the bubble. */
    .inbox-layout.inbox-thread-open .msg-bubble {
      padding: 7px 11px 6px 12px; border-radius: 18px;
      font-size: 15px; line-height: 1.42; display: flow-root;
    }
    .inbox-layout.inbox-thread-open .msg-wrap { max-width: 82%; }
    /* Pace's mark sits BESIDE an outbound bubble, so those rows get the extra
       4% back — otherwise a Pace reply is measurably narrower than ours. */
    .inbox-layout.inbox-thread-open .msg-wrap.out { max-width: 86%; }
    .inbox-layout.inbox-thread-open .msg-wrap.in .msg-bubble { background: var(--c-in-bg); border-color: var(--c-in-bd); box-shadow: var(--c-in-sh); }
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble { background: var(--c-out-bg); box-shadow: var(--c-out-sh); }
    /* The rule above paints EVERY outbound bubble on a phone, and at (0,4,0) it
       outranks the channel colours in the base sheet (0,3,0 / 0,4,0 dark). So on a
       phone a WhatsApp message came out blue like an SMS, and a message that never
       arrived came out looking delivered. Re-state the channel and failure colours
       at a specificity that wins; values are the base sheet's, unchanged. */
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.wa {
      background: linear-gradient(#1E9963, #10774A); color: #fff;
      box-shadow: 0 8px 20px -14px rgba(16,119,74,.6), inset 0 1px 0 rgba(255,255,255,.17);
    }
    [data-theme="dark"] .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.wa {
      background: linear-gradient(#23A06B, #147A4D);
      box-shadow: 0 10px 24px -14px rgba(35,160,107,.6), inset 0 1px 0 rgba(255,255,255,.17);
    }
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.wa-failed,
    [data-theme="dark"] .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.wa-failed {
      background: #2A1420; border: 1px solid #6B2733; color: #F3D9DD; box-shadow: none;
    }
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.msg-failed {
      background: #fdecea; border: 1px solid #f0b4ad; color: #7f1d1d; box-shadow: none;
    }
    [data-theme="dark"] .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.msg-failed {
      background: #2A1420; border: 1px solid #6B2733; color: #F3D9DD; box-shadow: none;
    }
    /* Time INSIDE the bubble, floated to the end of the last line. The top-line
       label this replaces (.msg-bubble-label) is gone — it put a second, fainter
       copy of the channel above every single bubble. The base stylesheet already
       hides it; this block simply no longer reveals it. */
    .inbox-layout.inbox-thread-open .msg-imeta {
      float: right; display: inline-flex; align-items: center; gap: 3px;
      margin: 6px 0 -4px 10px; font-size: 11px; line-height: 14px; white-space: nowrap;
      color: var(--text2);
    }
    .inbox-layout.inbox-thread-open .msg-imeta svg { width: 10px; height: 10px; flex-shrink: 0; }
    .inbox-layout.inbox-thread-open .msg-imeta .mim-ticks svg { width: 14px; height: 14px; }
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-imeta { color: rgba(255,255,255,0.85); }
    .inbox-layout.inbox-thread-open .msg-imeta .mim-bad { color: #fecaca; font-weight: 700; }
    .inbox-layout.inbox-thread-open .msg-wrap.in .msg-imeta .mim-bad { color: var(--f-danger); }
    /* A failed send's reason wraps under the time inside the bubble instead of running
       off its edge, and reads in the failed bubble's own text colour (same as desktop). */
    .inbox-layout.inbox-thread-open .msg-imeta.msg-imeta-fail {
      float: none; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center;
      margin: 4px 0 -2px; white-space: normal; text-align: right;
    }
    .inbox-layout.inbox-thread-open .msg-imeta.msg-imeta-fail .mim-bad { flex: 1 1 100%; white-space: normal; overflow-wrap: anywhere; }
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.msg-failed .msg-imeta,
    .inbox-layout.inbox-thread-open .msg-wrap.out .msg-bubble.msg-failed .msg-imeta .mim-bad { color: inherit; }
    /* Grouping, same rules as desktop: a run from one sender inside five minutes
       closes up, and only the last bubble of the run keeps its tail corner. */
    .inbox-layout.inbox-thread-open .msg-wrap.msg-grouped { margin-top: -5px; }
    .inbox-layout.inbox-thread-open .msg-wrap.in.msg-mid .msg-bubble { border-bottom-left-radius: 18px; }
    .inbox-layout.inbox-thread-open .msg-wrap.in.msg-grouped .msg-bubble { border-top-left-radius: 4px; }
    .inbox-layout.inbox-thread-open .msg-wrap.out.msg-mid .msg-bubble { border-bottom-right-radius: 18px; }
    .inbox-layout.inbox-thread-open .msg-wrap.out.msg-grouped .msg-bubble { border-top-right-radius: 4px; }
    /* Pace's 22px mark beside an outbound bubble — a line glyph in a bordered
       circle on the page surface, never a solid indigo disc (F5). */
    .inbox-layout.inbox-thread-open .msg-av,
    .inbox-layout.inbox-thread-open .msg-av.ai {
      width: 22px; height: 22px; background: var(--bg); border: 1px solid var(--border2);
      color: var(--accent); margin-bottom: 1px;
    }
    .inbox-layout.inbox-thread-open .msg-av .lucide,
    .inbox-layout.inbox-thread-open .msg-av svg { width: 12px; height: 12px; }
    /* No hover toolbar on a touch screen — the bubble's own long-press menu is
       how a phone reaches Copy and the reactions. */
    .inbox-layout.inbox-thread-open .msg-hover-bar { display: none !important; }
    /* "↓ N new" — 34px, above the composer, out of the send button's way. */
    .inbox-layout.inbox-thread-open .thread-jump-pill {
      display: none; position: absolute; right: 14px; bottom: 112px; z-index: 6;
      align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 10px;
      border-radius: 17px; background: var(--bg); border: 1px solid var(--border2);
      box-shadow: 0 4px 14px rgba(24,24,27,0.14); color: var(--text);
      font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap;
    }
    .inbox-layout.inbox-thread-open .thread-jump-pill.on { display: flex; }
    .inbox-layout.inbox-thread-open .thread-jump-pill svg { width: 15px; height: 15px; }
    .inbox-layout.inbox-thread-open .thread-jump-pill .tjp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
    /* The pinned date and the drag-to-attach veil are desktop affordances: one
       needs a mouse to drop a file, the other competes with the floating header
       for the same 40px of a phone screen. */
    .thread-date-pin, .thread-drop-veil { display: none !important; }

    /* ── Composer ───────────────────────────────────────────────────────────
       The SAME .cmp-* structure desktop uses, restyled — not a second composer.
       That is what the handoff draws (channel button inset to the message bar,
       From on the right, attach circle · field · send circle) and it is already
       in the markup, so the phone stops hiding it and hides the old GHL toolbar
       instead. The camera, ＋, clock and divider go with that toolbar. */
    .inbox-layout.inbox-thread-open .compose-mode-tabs,
    .inbox-layout.inbox-thread-open .compose-from-row,
    .inbox-compose .compose-ghl-head,
    .inbox-compose .compose-status-line,
    .inbox-compose .compose-toolbar,
    .inbox-compose .compose-foot { display: none !important; }
    .inbox-compose, .inbox-compose > * { max-width: 100% !important; box-sizing: border-box; }
    .inbox-layout.inbox-thread-open .inbox-compose,
    [data-theme="dark"] .inbox-layout.inbox-thread-open .inbox-compose {
      position: relative; z-index: 5; flex-shrink: 0;
      display: flex; flex-direction: column; gap: 8px;
      padding: 4px 10px calc(10px + max(24px, var(--safe-bottom))) !important;
      background: none; background-image: none; border-top: none; box-shadow: none;
    }
    /* Top row. The 52px left inset lines the channel button up with the message
       bar, clearing the 44px attach circle and its 8px gap. */
    .inbox-compose .cmp-top { display: flex !important; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px 0 52px; }
    .inbox-compose .cmp-ch {
      /* The BASE .cmp-ch is declared in the DESKTOP-only media block, so on a
         phone this button inherits nothing and falls back to the browser's
         native chrome — a black outset border on a grey fill. Every visual
         property it needs is therefore declared here, not just the sizes. */
      display: inline-flex; align-items: center; justify-content: center;
      height: 28px; padding: 0 9px 0 8px; border-radius: 8px; gap: 5px;
      font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1;
      letter-spacing: 0.01em;
      white-space: nowrap; cursor: pointer;
      background: var(--c-pill-bg); border: 1px solid var(--border2); color: var(--accent);
      transition: background 0.2s, color 0.2s, border-color 0.2s;
    }
    .inbox-compose .cmp-ch svg { width: 14px; height: 14px; }
    .inbox-compose .cmp-ch .cmp-caret { width: 12px; height: 12px; opacity: 0.55; }
    /* The blanket `.main button { min-height:44px }` tap-target rule above wins
       over the height here, which is what made this pill a 44px slab. It is
       exempt on purpose: it is a label-and-chooser sitting ON a 44px row, not a
       standalone target, and the whole row opens the menu. */
    .inbox-compose .cmp-ch { min-height: 0 !important; }
    .inbox-compose .cmp-from { font-size: 12px; color: var(--text2); }
    .inbox-compose .cmp-from b { color: var(--text); font-weight: 600; }
    .inbox-compose .cmp-from-pick { font-size: 12px; height: 28px; min-height: 0 !important; }
    .inbox-compose .cmp-ch-menu.cmp-from-menu { width: 280px; max-width: calc(100vw - 24px); }
    .inbox-compose .cmp-ch-menu.cmp-from-menu button { height: auto; min-height: 52px; padding: 6px 11px; }
    .inbox-compose .cmp-from-txt small { display: block; font-size: 12px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    /* The segment count is a desktop readout — there is no room for it beside
       the From number, and it reappears the moment the phone turns landscape. */
    .inbox-compose .cmp-top .compose-char-count { display: none !important; }
    .inbox-compose .cmp-main { display: flex !important; align-items: flex-end; gap: 8px; }
    .inbox-compose .cmp-anchor { position: relative; display: flex; flex-shrink: 0; }
    .inbox-compose .cmp-round {
      width: 44px; height: 44px; min-height: 44px !important; border-radius: 50%; flex-shrink: 0; padding: 0;
      display: flex; align-items: center; justify-content: center;
      background: var(--c-cmp-field); border: 1px solid var(--border2); color: var(--text2);
      box-shadow: 0 1px 2px rgba(24,24,27,.05), 0 4px 14px rgba(24,24,27,.06);
    }
    .inbox-compose .cmp-round svg { width: 20px; height: 20px; }
    .inbox-compose .cmp-field {
      display: flex !important; flex: 1; min-width: 0; min-height: 44px; border-radius: 22px;
      align-items: flex-end; gap: 0; padding: 0 16px;
      background: var(--c-cmp-field); border: 1px solid var(--border2);
      box-shadow: 0 1px 2px rgba(24,24,27,.05), 0 4px 14px rgba(24,24,27,.06);
    }
    /* Emoji and translate are desktop-only inside the field: two 30px circles
       inside a 44px bar on a 393px screen leave no room for the words. Translate
       is in the attach menu instead; the phone keyboard has its own emoji key. */
    .inbox-compose .cmp-inline-btn { display: none !important; }
    .inbox-compose .compose-body { flex: 1; min-width: 0; padding: 11px 0 !important; }
    .inbox-compose .compose-ta {
      display: block; width: 100%; height: 20px; min-height: 20px !important; max-height: 108px; padding: 0;
      border: none; outline: none; overflow-y: hidden; resize: none;
      background: none; color: var(--text); font-family: inherit;
      /* 16px or Safari zooms the whole page the moment the field takes focus. */
      font-size: 16px !important; line-height: 20px;
      transition: height 120ms ease-out;
      -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
    }
    .inbox-compose .compose-ta::placeholder { color: var(--text3); }
    .inbox-compose .compose-ta:disabled { opacity: 0.55; }
    .inbox-compose .cmp-send {
      display: flex !important;
      width: 44px; height: 44px; min-height: 44px !important; border-radius: 50%; flex-shrink: 0; border: none; padding: 0;
      align-items: center; justify-content: center;
      background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.28);
      transition: background 0.2s, transform 100ms ease-out;
    }
    .inbox-compose .cmp-send svg { width: 19px; height: 19px; }
    .inbox-compose .cmp-send:active { transform: scale(0.92); }
    .inbox-compose .cmp-send:disabled { opacity: 0.45; box-shadow: none; }
    /* Both menus open UPWARD — there is nothing below the composer to open into.
       They are position:fixed for the same reason the ⋯ menu is: the composer is
       a floating strip and an absolutely-positioned menu would be clipped. */
    .inbox-compose .cmp-menu {
      position: fixed; left: 10px; right: auto; bottom: auto; z-index: 1300;
      padding: 6px; border-radius: 14px;
      background: var(--f-menu-bg); box-shadow: var(--f-menu-sh);
      backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
      /* The base .cmp-menu is the rule that makes these a COLUMN, and this block
         re-declares .cmp-menu rather than extending it — so without repeating the
         flex here the rows lay out side by side and wrap: SMS and WhatsApp on one
         line, Email under them, the divider floating across the middle. */
      display: flex; flex-direction: column;
    }
    /* `.cmp-menu[hidden] { display:none }` lives in the desktop block, and the
       `display:flex` above outranks the plain `hidden` attribute — so without
       this the CLOSED menu sits on screen permanently as an empty grey slab
       above the composer. It has to repeat the hide, not rely on the base. */
    .inbox-compose .cmp-menu[hidden] { display: none !important; }
    .inbox-compose .cmp-ch-menu { width: 226px; }
    .inbox-compose .cmp-ch-menu button {
      /* Same trap as .cmp-ch: the base rule that strips a button back to plain
         text (border:none, background:none, text-align:left) is in the desktop
         block, so a row that only sets its height here renders as a NATIVE
         button — a hard black box around every channel. Declare the reset. */
      display: flex; align-items: center; width: 100%; box-sizing: border-box;
      height: 44px; padding: 0 11px; border-radius: 10px; gap: 11px;
      border: none; background: none; text-align: left; white-space: nowrap;
      font-family: inherit; font-size: 15px; font-weight: 500; color: var(--text);
      cursor: pointer;
    }
    .inbox-compose .cmp-ch-menu button:active { background: var(--bg3); }
    .inbox-compose .cmp-ch-menu button:disabled { opacity: 0.45; cursor: not-allowed; }
    .inbox-compose .cmp-ch-menu .cmp-ch-name { flex: 1; }
    .inbox-compose .cmp-ch-menu button > svg { width: 18px; height: 18px; }
    .inbox-compose .cmp-ch-menu .cmp-ch-tick { width: 16px; height: 16px; }
    /* Internal comment is the one channel that never reaches the renter, so it
       is the one channel that is coloured in the list as well as when it is on. */
    .inbox-compose .cmp-ch-menu button.cmp-ch-note { color: var(--note-fg); }
    .inbox-compose .cmp-ch-menu button.cmp-ch-note > svg { color: var(--note-fg); }
    .inbox-compose .cmp-menu .cmp-div { height: 1px; margin: 4px 10px; background: var(--border2); }
    .inbox-compose .cmp-attach-menu { width: 250px; border-radius: 14px; }
    .inbox-compose .cmp-attach-menu button { gap: 11px; padding: 7px 9px; border-radius: 9px; }
    /* Light mode: the + menu now lists your lines too, so it is tall enough to sit over
       the messages. At the shared 26% glass the words behind it read through the rows.
       Firm it up the same way dark mode was on 26 Oct. This menu only. */
    :root:not([data-theme="dark"]) .inbox-compose .cmp-menu { --glass-fill-menu: var(--bg2); }
    .inbox-compose .cmp-attach-ico { width: 34px; height: 34px; }
    .inbox-compose .cmp-attach-ico svg { width: 17px; height: 17px; }
    .inbox-compose .cmp-attach-t b { font-size: 15px; font-weight: 500; }
    .inbox-compose .cmp-attach-t span { font-size: 12px; }
    /* Internal comment mode — the channel button, the field and send all turn
       orange together, so there is no way to mistake a note for a message. */
    .inbox-compose.compose-internal-note .cmp-ch { background: var(--note-bg); border-color: var(--note-bd); color: var(--note-fg); }
    .inbox-compose.compose-internal-note .cmp-field { background: var(--note-field); border-color: var(--note-bd); }
    .inbox-compose.compose-internal-note .cmp-send { background: var(--note-send); box-shadow: 0 2px 8px rgba(217,119,6,.28); }
    /* P9 — WhatsApp with no provable consent. It sits above the main row and
       matches the message bar's inset, so it reads as a note about the box below
       it rather than a page-level banner. */
    .inbox-compose .cmp-consent {
      display: flex !important; align-items: flex-start; gap: 8px; margin-left: 0;
      padding: 9px 12px; border-radius: 14px;
      background: var(--c-cmp-field); border: 1px solid var(--f-danger);
      font-size: 13px; line-height: 1.4; color: var(--text);
    }
    .inbox-compose .cmp-consent > svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; color: var(--f-danger); }
    .inbox-compose .cmp-consent button { font-size: 13px; font-weight: 600; color: var(--accent); }
    .inbox-compose .cmp-subject { margin-left: 0; height: 40px; border-radius: 20px; padding: 0 16px; }
    .inbox-compose .cmp-subject input { font-size: 16px !important; }
    .inbox-compose .compose-staged { padding: 0 0 0 52px; }
    .inbox-compose .compose-xlate { margin-left: 52px; border-radius: 10px; padding: 6px 12px; font-size: 12px; }
    .inbox-compose .wa-tpl-bar, .inbox-compose .sms-dead-bar {
      margin-left: 0; border-radius: 12px; border-bottom: none;
      border: 1px solid rgba(217,119,6,.28); padding: 8px 12px;
    }
    .inbox-compose .sms-dead-bar { border-color: rgba(220,38,38,.28); }
    @media (prefers-reduced-motion: reduce) {
      .inbox-compose .compose-ta, .inbox-compose .cmp-send { transition: none !important; }
      .inbox-compose .cmp-send:active { transform: none; }
    }
    /* staged photo previews (the attach menu's Photos & videos item) */
    .compose-staged { gap: 8px; padding: 8px 12px 0; flex-wrap: wrap; }
    .cstaged-chip { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border2); }
    .cstaged-chip img { width: 100%; height: 100%; object-fit: cover; }
    /* A file chip (a PDF, the contact card) is a wide label, not a 56px square. These used to be declared
       only in the desktop-only block, so on a phone a file chip squeezed its name into a 56px box. */
    .cstaged-chip.is-file { width: auto; min-width: 120px; max-width: 190px; height: auto; background: var(--bg2); }
    .cstaged-file { display: flex; align-items: center; gap: 6px; padding: 9px 28px 9px 10px; font-size: 11px; color: var(--text); }
    .cstaged-file i { width: 15px; height: 15px; flex-shrink: 0; color: var(--text2); }
    .cstaged-fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .cstaged-chip button {
      position: absolute; top: 2px; right: 2px; width: 18px !important; height: 18px !important;
      min-width: 0 !important; min-height: 0 !important; border-radius: 50%; border: none;
      background: rgba(0,0,0,0.6); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
      display: flex; align-items: center; justify-content: center; padding: 0;
    }
}
