/* The agent's VOICE (Run 350; Run 360 E3: voice first; Run 362 E3b: voice mode is the PAGE itself — no card) — loaded
   only when the site's voice is on. The SITE's accent only (--accent-rgb, W3): never a rainbow.
   · the FRAME: while the agent listens, thinks or speaks, a margin round the viewport (12 px; 8 px on a phone) filled
     with the brand and lit from its inner edge by a soft, layered light that follows the voice (--sa-level, set by
     voice.js). It is OPAQUE and covers only the page's outermost pixels, so no text is ever read through it (the E3
     glow lay see-through OVER the page and was capped by every line under it). It never takes a click.
   · the CAPTIONS: words straight on the page's foot — a full-width SCRIM rising from the bottom of the window (the
     site's surface, blurred, solid where the words are and fading to nothing above them), never a box, a border or a
     shadow (design critic, Run 362 round 1: a rounded shadowed caption box read as the Sesame card Joel ruled out).
     Large (30 px; 22 px on a phone), at most two lines at a time; the state and the question on ONE small line above.
   · the CONTROL BAR, on the same scrim: "Type", the orb (tap = stop / talk again), "Conversation". Nothing else.
   · the panel: only the typed agent and the transcript ("Conversation").
   · the SOURCE outline: the section the answer came from, for the length of the answer. */

/* ── the panel: typing and the transcript only ── */
.sa-panel .sa-log{scroll-margin:0}

/* ── the layer: the scrim, the captions, the bar — shown only for a conversation ── */
.sa-voice{
  --sa-scrim:color-mix(in srgb,var(--surface) 94%,transparent);
  --sa-fade:72px;   /* the scrim fades to nothing over this much ABOVE the words (the words never sit in the fade) */
  position:fixed;left:0;right:0;bottom:0;z-index:var(--z-overlay);
  display:none;flex-direction:column;align-items:center;gap:20px;
  padding:var(--sa-fade) 24px 18px;
  background:var(--surface);
  background:linear-gradient(to top,var(--sa-scrim) 0,var(--sa-scrim) calc(100% - var(--sa-fade)),transparent 100%);
  -webkit-backdrop-filter:blur(14px) saturate(1.15);backdrop-filter:blur(14px) saturate(1.15);
  -webkit-mask-image:linear-gradient(to top,#000 calc(100% - var(--sa-fade)),transparent 100%);mask-image:linear-gradient(to top,#000 calc(100% - var(--sa-fade)),transparent 100%);
  pointer-events:none;font-family:var(--fb);transition:opacity .4s var(--ease-out);
}
.sa[data-layer="on"] .sa-voice{display:flex}
/* inside the frame while it is on (the busy states); edge to edge otherwise — never a page that looks shifted with no
   frame round it (design critic round 4) */
.sa[data-orb="listening"] .sa-voice,.sa[data-orb="thinking"] .sa-voice,.sa[data-orb="speaking"] .sa-voice{left:var(--sa-fw,12px);right:var(--sa-fw,12px);bottom:var(--sa-fw,12px);border-radius:0 0 18px 18px}
.sa-voice > *{pointer-events:auto}
/* the resting orb steps aside: the bar's orb is the voice's control while the layer is shown */
.sa[data-layer="on"] .sa-orb-btn,.sa[data-layer="on"] .sa-orb-tag{display:none}
/* the site's own floating WhatsApp button steps aside too; the caption carries the WhatsApp link when the answer offers it */
html.sa-voice-on .sticky-wa{opacity:0;pointer-events:none;transition:opacity .2s}

.sa-caption{position:relative;width:100%;max-width:820px;box-sizing:border-box;text-align:center;transition:opacity .4s var(--ease-out)}
.sa-caption[hidden]{display:none}
.sa-caption[data-fade="out"]{opacity:0}
/* the state, in words (UI contract §6a), and the question — ONE quiet line above the words (design critic round 3: a
   status line, the question, the answer and its source stacked six lines at 390) */
.sa-caption-meta{font-size:15px;line-height:1.45;color:var(--text);margin-bottom:8px;overflow-wrap:anywhere}
.sa-voice-status{font-weight:600}
.sa-caption-asked[hidden]{display:none}
.sa-voice-status + .sa-caption-asked:not([hidden])::before{content:" · ";font-weight:600}
.sa-caption-text{
  font-family:var(--fd);font-size:30px;line-height:1.3;font-weight:600;letter-spacing:-0.01em;color:var(--ink);overflow-wrap:anywhere;
  display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;
}
.sa-caption-text[data-kind="hint"]{color:var(--text);font-weight:500}
/* a line or a hint (a state in words — nothing spoken to keep pace with) is a size smaller and may take THREE lines, so
   "The microphone is blocked… or type your question." reads whole at 390 instead of paging mid-sentence (design critic
   round 2); a spoken answer keeps two lines a page */
.sa-caption-text[data-kind="hint"],.sa-caption-text[data-kind="line"]{font-size:24px;-webkit-line-clamp:3}
/* the measurer: the same box, unclamped, never seen (voice.js pages a long answer two lines at a time) */
.sa-caption-measure{position:absolute;left:0;right:0;top:0;visibility:hidden;pointer-events:none;display:block;-webkit-line-clamp:none}
.sa-caption-wa{
  display:inline-flex;align-items:center;margin-top:10px;min-height:44px;padding:0 18px;border-radius:999px;
  background:var(--accent);color:var(--on-accent);text-decoration:none;font-size:14px;font-weight:700;
}
.sa-caption-wa[hidden]{display:none}
.sa-caption-wa:focus-visible{outline:2px solid var(--accent-ink);outline-offset:3px}
.sa-vnote{margin:8px 0 0;font-size:13px;line-height:1.5;color:var(--text)}
.sa-vnote[hidden]{display:none}
.sa-visually-hidden{position:absolute !important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* the control bar, on the scrim: Type · the orb · Conversation — quiet words either side of the one striking control */
.sa-bar{display:flex;align-items:center;justify-content:center;gap:18px}
.sa-type-btn,.sa-log-btn{
  min-height:44px;min-width:44px;padding:0 12px;border-radius:999px;border:0;background:transparent;
  color:var(--ink);font-family:var(--fb);font-size:15px;font-weight:600;cursor:pointer;white-space:nowrap;
  text-decoration:underline;text-decoration-color:rgba(var(--shadow-rgb),0.3);text-underline-offset:4px;
}
.sa-type-btn:hover,.sa-log-btn:hover{text-decoration-color:currentColor}
.sa-type-btn:focus-visible,.sa-log-btn:focus-visible{outline:2px solid var(--accent-ink);outline-offset:2px}
.sa-voice-btn{
  position:relative;width:60px;height:60px;flex:0 0 60px;border-radius:50%;border:0;cursor:pointer;
  display:flex;align-items:center;justify-content:center;background:var(--accent);color:var(--on-accent);
  box-shadow:0 0 0 6px rgba(var(--accent-rgb),0.14);
}
.sa-voice-btn svg{width:24px;height:24px;fill:currentColor;position:relative;z-index:1}
.sa-voice-btn:focus-visible{outline:2px solid var(--accent-ink);outline-offset:6px}
.sa-voice-btn:disabled{cursor:default}
.sa-voice-btn::before{content:"";position:absolute;inset:-7px;border-radius:50%;pointer-events:none;border:2px solid rgba(var(--accent-rgb),0)}
/* listening and speaking: the ring swells with the level (--sa-level 0…1 on the root) */
.sa[data-orb="listening"] .sa-voice-btn::before,.sa[data-orb="speaking"] .sa-voice-btn::before{
  border-color:rgba(var(--accent-rgb),0.6);transform:scale(calc(1 + var(--sa-level,0) * 0.32));
}
/* thinking: a slow sweep (a live progress indicator — the one loop §6a allows) */
.sa[data-orb="thinking"] .sa-voice-btn::before{border-color:rgba(var(--accent-rgb),0.2);border-top-color:rgba(var(--accent-rgb),0.95);animation:sa-sweep 1.4s linear infinite}
@keyframes sa-sweep{to{transform:rotate(360deg)}}
/* only the month's minutes used up rests the control (an error a tap can retry keeps the brand — the control IS the retry).
   Run 368 (U2 S8): the SAME ORB as the resting launcher in its limit state (ink, white, the orb's own waveform mark) —
   never a different-looking control */
.sa[data-orb="limit"] .sa-voice-btn{background:var(--ink);color:#fff;box-shadow:0 0 0 6px rgba(var(--shadow-rgb),0.12)}
/* unavailable: the brand orb with its waveform, its ring dotted — a tap retries */
.sa[data-orb="unavailable"] .sa-voice-btn::before,.sa[data-orb="unavailable"] .sa-orb-ring{border-color:rgba(var(--accent-rgb),0.55);border-style:dotted;animation:none}

/* ── Run 368 (U2 S8): the caption PILL — the state line and the question in one rounded chip on the scrim, so it reads
   as the voice's own label over any page; the words themselves stay on the scrim, as ruled in E3b ── */
.sa-caption-meta{
  display:inline-flex;flex-wrap:wrap;align-items:center;gap:0 4px;max-width:100%;
  padding:5px 14px;border-radius:999px;background:var(--surface);
  border:1px solid rgba(var(--accent-rgb),0.45);box-shadow:0 6px 18px -12px rgba(var(--shadow-rgb),0.6);
}

/* ── Run 368 (U2 S8): a brand-tint SHIMMER travels round the frame's band while the voice is busy — a slow light in the
   brand lightened, over the band only (the window is masked out), never over the page. Still for reduced motion. ── */
@property --sa-sheen{syntax:"<angle>";initial-value:0deg;inherits:false}
.sa-frame-sheen{
  position:absolute;inset:0;pointer-events:none;border-radius:0;
  border:var(--sa-fw) solid transparent;
  background:conic-gradient(from var(--sa-sheen),rgba(var(--sa-lite,255,255,255),0) 0deg,rgba(var(--sa-lite,255,255,255),0.85) 40deg,rgba(var(--sa-lite,255,255,255),0) 90deg,rgba(var(--sa-lite,255,255,255),0) 360deg) border-box;
  -webkit-mask:linear-gradient(#000 0 0) padding-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;
  mask:linear-gradient(#000 0 0) padding-box exclude,linear-gradient(#000 0 0);
  opacity:0;
}
.sa-frame[data-on="1"] .sa-frame-sheen{opacity:.7;animation:sa-sheen 4.5s linear infinite}
@keyframes sa-sheen{to{--sa-sheen:360deg}}
@media(prefers-reduced-motion:reduce){.sa-frame[data-on="1"] .sa-frame-sheen{animation:none;opacity:.35}}

/* the typed form's microphone ("speak instead") */
.sa-mic{
  width:44px;height:44px;flex:0 0 44px;display:flex;align-items:center;justify-content:center;
  background:var(--surface-2);color:var(--ink);border:1px solid rgba(var(--shadow-rgb),0.22);cursor:pointer;
}
.sa-mic svg{width:20px;height:20px;fill:currentColor}
.sa-mic:hover{background:#fff}
.sa-mic:focus-visible{outline:2px solid var(--accent-ink);outline-offset:3px}

/* the opt-in (W1): asked once, on the first tap (Run 403), in the visitor's language */
.sa-optin{width:100%;max-width:620px;box-sizing:border-box;padding:4px 0;text-align:center}
.sa-optin[hidden]{display:none}
.sa-optin-q{font-size:18px;font-weight:700;color:var(--ink);line-height:1.4;text-wrap:balance}
.sa-optin-note{font-size:14px;color:var(--text);margin-top:4px;line-height:1.5;text-wrap:balance}   /* round 3: no "(Beta)?" or "button." alone on a line */
/* design critic round 2 (Run 403): while the question is asked, the turn's listening is said ONCE (the sentence, not the
   state pill too) and the question leads — the sentence steps down below it */
.sa-voice:has(.sa-optin:not([hidden])) .sa-caption-meta{display:none}
.sa-voice:has(.sa-optin:not([hidden])) .sa-caption-text[data-kind="hint"]{font-size:16px}
.sa-optin-row{display:flex;gap:8px;margin-top:10px;justify-content:center}
.sa-optin-row button{min-height:44px;padding:0 16px;border-radius:999px;font-family:var(--fb);font-size:14px;font-weight:700;cursor:pointer;border:1px solid rgba(var(--shadow-rgb),0.22);background:transparent;color:var(--ink)}
.sa-optin-row .sa-optin-yes{background:var(--accent);color:var(--on-accent);border-color:transparent}
.sa-optin-row button:focus-visible{outline:2px solid var(--accent-ink);outline-offset:3px}

/* voice lines in the conversation */
.sa-panel .sa-state[data-state="voice_off"]{border-left-color:var(--accent-ink);background:var(--surface-2)}
.sa-panel .sa-state[data-state="voice_off"] .sa-label{color:var(--accent-ink)}

/* ── the FRAME (W3, Run 362): the page sits inside it while the voice is busy ── */
.sa-frame{
  --sa-fw:12px;
  position:fixed;inset:0;pointer-events:none;z-index:calc(var(--z-overlay) - 1);
  opacity:0;visibility:hidden;transition:opacity .35s var(--ease-out),visibility 0s linear .35s;
}
.sa-frame[data-on="1"]{opacity:1;visibility:visible;transition:opacity .35s var(--ease-out),visibility 0s}
/* the band: everything outside the rounded window, in the brand, opaque */
.sa-frame::before{
  content:"";position:absolute;inset:var(--sa-fw);border-radius:18px;
  box-shadow:0 0 0 100vmax rgb(var(--accent-rgb));
}
/* the light: layered from the window's inner edge OUTWARD into the band only — a shadow is never drawn inside its box,
   so never over the page. A bright line, then two soft halos of the brand lightened; brighter and wider with the voice
   (design critic rounds 1 and 3: a thin halo read as a flat coloured border — the outer halo now reaches across the
   whole band, so the band is lit from the window outward) */
.sa-frame::after{
  content:"";position:absolute;inset:var(--sa-fw);border-radius:18px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,calc(0.6 + var(--sa-level,0) * 0.4)),
    0 0 calc(5px + var(--sa-level,0) * 6px) calc(1px + var(--sa-level,0) * 2px) rgba(255,255,255,calc(0.45 + var(--sa-level,0) * 0.4)),
    0 0 calc(12px + var(--sa-level,0) * 10px) calc(3px + var(--sa-level,0) * 4px) rgba(var(--sa-lite,255,255,255),calc(0.8 + var(--sa-level,0) * 0.2)),
    0 0 calc(28px + var(--sa-level,0) * 12px) calc(8px + var(--sa-level,0) * 4px) rgba(var(--sa-lite,255,255,255),0.55);
}
/* thinking: the light breathes slowly (a live progress indicator) */
.sa-frame[data-s="thinking"]::after{animation:sa-frame-think 1.8s ease-in-out infinite}
@keyframes sa-frame-think{
  0%,100%{box-shadow:0 0 0 1px rgba(255,255,255,.6),0 0 5px 1px rgba(255,255,255,.45),0 0 12px 3px rgba(var(--sa-lite,255,255,255),.8),0 0 28px 8px rgba(var(--sa-lite,255,255,255),.55)}
  50%{box-shadow:0 0 0 1px rgba(255,255,255,.95),0 0 10px 3px rgba(255,255,255,.75),0 0 20px 6px rgba(var(--sa-lite,255,255,255),1),0 0 40px 12px rgba(var(--sa-lite,255,255,255),.7)}
}

/* ── the source outline ── */
.sa-source-on{outline:3px solid rgba(var(--accent-rgb),0.9);outline-offset:-3px;transition:outline-color .3s}

@media(max-width:768px){
  .sa-frame{--sa-fw:8px}
  .sa-frame::before,.sa-frame::after{border-radius:14px}
  .sa-voice{--sa-fw:8px;--sa-fade:56px;padding:var(--sa-fade) 14px 12px;gap:16px}
  .sa[data-orb="listening"] .sa-voice,.sa[data-orb="thinking"] .sa-voice,.sa[data-orb="speaking"] .sa-voice{border-radius:0 0 14px 14px}
  .sa-caption-text{font-size:22px}
  .sa-caption-text[data-kind="hint"],.sa-caption-text[data-kind="line"]{font-size:20px}
  .sa-bar{gap:8px}
}

@media(prefers-reduced-motion:reduce){
  .sa[data-orb="thinking"] .sa-voice-btn::before{animation:none;border-color:rgba(var(--accent-rgb),0.6)}
  .sa[data-orb="listening"] .sa-voice-btn::before,.sa[data-orb="speaking"] .sa-voice-btn::before{transform:none}
  /* a still light: the level is not followed (voice.js holds it at one value), nothing fades or breathes */
  .sa-frame,.sa-frame[data-on="1"],.sa-caption,.sa-voice,.sa-source-on,html.sa-voice-on .sticky-wa{transition:none}
  .sa-frame[data-s="thinking"]::after{animation:none}
}
