/* =========================================================================
   KIT: FAB (floating agent button and its bubble). Moved here from workspace.css (live UI review C1, 2 Nov).
   The person's own agent, bottom left (bottom right in Arabic) on the same line as a screen's round +, near the bottom
   of a phone screen. workspace.js (AGENT FAB) shows it and sets body.agent-fab-on while it is there; desktop.css hides
   it (the dock is the agent there).

   One reserve for every page: while the button shows, the page's scroller (.phone) ends --verser-fab-reserve above the
   bottom of the screen, which is the button's own line (--verser-fab-bottom), its height and a 16px gap. Any page or
   floating bar that has to clear the button uses that token, never its own number.

   Tokens (ui/tokens.css): --verser-fab-size, --verser-fab-inset, --verser-fab-bottom, --verser-fab-gap and
   --verser-fab-reserve (the bottom room a page keeps while the button shows).
   ========================================================================= */

/* ---- The reserve: the last row of every page scrolls clear of the button. */
body.agent-fab-on:not(.verser-open) .phone{padding-bottom:var(--verser-fab-reserve)}

/* ---- The button. It wears the agent's colours as every agent avatar does (the cyan tint, a soft cyan edge), over the
   solid glass so nothing shows through it. It steps aside under a sheet like the +. */
.agent-fab-btn{position:fixed;inset-inline-start:var(--verser-fab-inset);bottom:var(--verser-fab-bottom);z-index:45;display:grid;place-items:center;width:var(--verser-fab-size);height:var(--verser-fab-size);padding:0;border:2px solid color-mix(in srgb,var(--b) 55%,transparent);border-radius:var(--r-compact);background:linear-gradient(var(--agent-fill),var(--agent-fill)),var(--glass-solid);box-shadow:var(--shadow-control);color:var(--text);cursor:pointer;transition:transform 160ms var(--ease-out)}
.agent-fab-btn:active{transform:scale(.97)}
.agent-fab-btn[aria-expanded="true"]{border-color:var(--selected-edge)}
.agent-fab-face{display:grid;place-items:center;width:100%;height:100%;overflow:hidden;border-radius:calc(var(--r-compact) - 2px);font:700 var(--font-size-body)/1 var(--font)}
.agent-fab-face img{width:100%;height:100%;object-fit:cover}
/* Speaking: a soft ring goes out from the edge. A reply on its way: a dot pulses in the top corner. News: a pink dot. */
.agent-fab-btn.speaking{border-color:var(--b);animation:agent-fab-ring 1.4s ease-out infinite}
@keyframes agent-fab-ring{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--b) 55%,transparent)}100%{box-shadow:0 0 0 12px transparent}}
.agent-fab-btn.has-news::after{content:"";position:absolute;top:1px;inset-inline-end:1px;width:12px;height:12px;border:2px solid var(--glass-solid);border-radius:var(--radius-round);background:var(--pink)}
.agent-fab-btn.thinking::before{content:"";position:absolute;top:1px;inset-inline-start:1px;width:12px;height:12px;border:2px solid var(--glass-solid);border-radius:var(--radius-round);background:var(--b);animation:agent-fab-think 1s ease-in-out infinite alternate}
@keyframes agent-fab-think{from{opacity:.35;transform:scale(.8)}to{opacity:1;transform:none}}
body.sheet-open .agent-fab-btn{display:none}
/* Tucked (2 Nov, the lead): on a phone the button slides down out of the way while the page scrolls down and comes back
   on the first scroll up (workspace.js AGENT FAB TUCK sets body.agent-fab-tucked; never with a sheet, the bubble or the
   keyboard up). Transform only; once it is out of sight it also leaves the tab order (visibility). Under reduced
   motion it fades instead of moving (below). */
body.agent-fab-tucked .agent-fab-btn{transform:translateY(calc(var(--verser-fab-bottom) + 100%));visibility:hidden;
  transition:transform var(--duration-base,200ms) var(--ease-out),visibility 0s linear var(--duration-base,200ms)}

/* ---- The bubble (2026-10-02, hb1): a slim pill beside the button, on its line. Its first line is centred on the button
   and it grows upwards with the draft, to about four lines. It ends 16px from the screen's edge; a screen's round + is
   hidden while it is open. The agent's replies are not written in it, only heard; a confirm row's question with Yes and
   Not now sits just above it. Tap to hear, Join, source chips and the Studio's question with its answers sit inside it,
   over the draft, on its own background, so nothing of them lies over the page. It grows out of the button's side
   (--verser-fab-origin; workspace.js agentFabSetOpen slides it from that side too). */
.agent-fab-panel{--verser-fab-origin:left center;transform-origin:var(--verser-fab-origin);position:fixed;inset-inline-start:calc(var(--verser-fab-inset) + var(--verser-fab-size) + 8px);inset-inline-end:var(--verser-fab-inset);bottom:calc(var(--verser-fab-bottom) - var(--af-status-half,0px));z-index:61;display:block;min-height:52px;padding:5px;border:1px solid var(--line);border-radius:var(--verser-agent-fab-panel-radius);background:var(--glass-solid);box-shadow:var(--shadow)}
.agent-fab-panel:dir(rtl){--verser-fab-origin:right center}
/* The keyboard is up over a fixed-bottom text field (body.kb-field, index.html): the bubble sits on top of it. */
body.kb-field .agent-fab-panel{bottom:calc(var(--kb-field-lift,0px) + 8px)}
/* While the bubble is open the page's round + steps aside, so the bubble keeps the whole line (audit 28 Oct). */
body:has(#agentFabPanel:not(.hidden)) .screen.active .tasks-fab{display:none}
/* The one-line bubble (56px, like the button) shares the button's bottom; a status line over the draft (its 2px + 16px + 4px)
   drops it by half that, so the bubble stays centred on the button's line. */
.agent-fab-panel:has(> .agent-fab-status:not(:empty)){--af-status-half:11px}
.agent-fab-panel:has(> .agent-fab-inside > :not(.hidden)){border-radius:var(--vx-r-lg)}
.agent-fab-above{position:absolute;inset-inline:0;bottom:calc(100% + 8px);display:flex;flex-direction:column;align-items:flex-start;gap:6px}
.agent-fab-inside{display:flex;flex-direction:column;align-items:flex-start;gap:6px;padding:7px 7px 3px}
.agent-fab-inside:not(:has(> :not(.hidden))){display:none}
.agent-fab-status{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;margin:2px 12px 4px;overflow:hidden;color:var(--text-2);font-size:var(--font-size-meta);font-weight:600;line-height:16px;overflow-wrap:anywhere}
.agent-fab-status:empty{display:none}
.agent-fab-status.failed{color:var(--danger-text)}
/* A failed answer: My Agent as a kit button under the line, where the chat can try again. */
.agent-fab-open{margin:0 7px 6px}
.agent-fab-hear{position:relative;min-height:32px;padding:0 12px;border:1px solid var(--line);border-radius:var(--r-pill);background:var(--glass-solid);box-shadow:var(--shadow-control);color:var(--text);font:600 var(--font-size-meta)/1 var(--font)}
.agent-fab-hear::after{content:"";position:absolute;inset:-6px -2px}
.agent-fab-sources{display:flex;flex-wrap:wrap;gap:6px;max-width:100%}
.agent-fab-sources .source-chip{background:var(--glass-solid);box-shadow:var(--shadow-control)}
/* The confirm waiting in Verser's chat, as the kit's compact action card (index.html, proposedActionCard): its content
   in full up to five lines, scrolling inside past the panel's room. */
.agent-fab-confirm{align-self:stretch;max-height:min(56dvh,440px);overflow-y:auto;overscroll-behavior:contain;border-radius:var(--vx-r-md);box-shadow:var(--shadow)}
.agent-fab-question{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;margin:0;overflow:hidden;font-size:var(--font-size-small);line-height:1.35;overflow-wrap:anywhere}
.agent-fab-sources .agent-fab-question{flex:1 0 100%;padding:0 4px 2px}
/* Muted (workspace.js, AGENT MUTE): the newest reply written in the bubble, scrolling inside past a few lines; the
   speaker button shows the crossed speaker in the secondary text colour (a state, not a warning). */
.agent-fab-reply{display:block;max-height:8.2em;padding:0 4px 2px;overflow-y:auto;overscroll-behavior:contain;white-space:pre-line}
.agent-fab-mute.muted{color:var(--text-2)}
/* The draft row: mute, mic, the text box and send. */
.agent-fab-row{display:flex;align-items:flex-end;gap:4px;margin:0}
/* One line is the row's 44px (a finger's reach, the height of the buttons beside it): 20px of line, its 1px edges and
   the rest above and below it. */
.agent-fab-row textarea.agent-fab-input{flex:1;min-width:0;min-height:var(--tap-min);height:var(--tap-min);max-height:98px;padding:calc((var(--tap-min) - 22px) / 2) var(--vx-sp-2);border:1px solid transparent;border-radius:var(--verser-agent-fab-input-radius);background:transparent;box-shadow:none;line-height:20px;resize:none;overflow-y:hidden;field-sizing:fixed}
.agent-fab-mic,.agent-fab-send{flex:none;display:grid;place-items:center;width:44px;height:44px;padding:0;border:1px solid var(--line);border-radius:var(--radius-round);background:var(--fill-2);color:var(--text)}
.agent-fab-send{border:0;background:var(--primary);color:var(--on-primary)}
.agent-fab-mic .icon,.agent-fab-send .icon{width:18px;height:18px}
/* In right-to-left Send's arrow points up, as the composer's Send does: mirrored it points left and reads as Back (the
   lead, 29 Oct). */
.agent-fab-send:not(.agent-fab-stop):dir(rtl) svg{transform:rotate(-90deg)}
.agent-fab-mic.on{border-color:var(--green);color:var(--green)}
.agent-fab-mic.listening{background:var(--green);color:var(--on-success)}

@media (prefers-reduced-motion:reduce){
  .agent-fab-btn{transition:opacity 160ms var(--ease-out)}
  .agent-fab-btn:active{transform:none;opacity:.8}
  body.agent-fab-tucked .agent-fab-btn{transform:none;opacity:0;transition:opacity 160ms var(--ease-out),visibility 0s linear 160ms}
  .agent-fab-btn.speaking{animation:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--b) 55%,transparent)}
  .agent-fab-btn.thinking::before{animation:none}
}
