/* ============================================================
   HighStack agent widget — based on Caroline's Figma design
   (HighStack Vex Widget _standalone_.html, 2026-05-28).

   Three views inside the gradient frame:
     • .home        → Ask tab (Vex hero + specialist roster) ·
                       Tickets tab · History tab
     • .chat        → AgentCard header + .messages + handoff dividers
     • .voice       → Overlay: avatar with concentric rings,
                       waveform, status, controls (mute / end /
                       transfer-to-specialist)

   The video pipeline (LiveAvatar) is preserved in code but the
   button is hidden post-pivot; its DOM stays as a no-op container.
   ============================================================ */

:root {
  --bg:           #070708;
  --panel:        #0d0d10;
  --surface:      #141417;
  --surface-2:    #1b1b20;
  --line:         rgba(255,255,255,.08);
  --line-soft:    rgba(255,255,255,.05);
  --text:         #f4f4f6;
  --text-dim:     #8b8b94;
  --text-faint:   #5a5a62;
  --accent:       #7c5cff;
  --accent-2:     #d946ef;
  --online:       #27c46b;
  --grad:         linear-gradient(125deg, #3b82f6 0%, #8b5cf6 45%, #ec4899 100%);
  --glow:         rgba(139,92,246,.22);
  --r-panel:      26px;
  --r-frame:      18px;
  --font:         'Helvetica Neue', Helvetica, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}
body::before {
  /* faint depth behind the widget when standalone-viewed */
  content: "";
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(620px 520px at 50% 32%, rgba(124,92,255,.10), transparent 70%),
    radial-gradient(520px 480px at 70% 78%, rgba(236,72,153,.06), transparent 70%);
}

/* When embedded via iframe loader.js, the host page often sets a
   transparent background. Keep body bg dark so the widget reads
   correctly either way. */

.widget {
  /* Fully responsive: fill 100% of whatever box it's in. */
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #101013 0%, #0b0b0e 100%);
  border-radius: var(--r-panel);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow:
    0 1px 0 rgba(255,255,255,.05) inset,
    -22px 0 60px -30px rgba(124,92,255,.25),
    0 40px 90px -30px rgba(0,0,0,.8);
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
}

/* EMBEDDED (floating or window): the iframe IS the panel, so fill it edge
   to edge — no caps, no centering, no card chrome. This makes the chat
   resize to exactly the space the host gives it (full height of a docked
   side rail, whatever's above/below it). */
html[data-embedded="1"], html[data-embedded="1"] body { height: 100%; }
html[data-embedded="1"] body {
  display: block;          /* stop centering */
  min-height: 0;
}
html[data-embedded="1"] body::before { display: none; }   /* no decorative glow */
html[data-embedded="1"] .widget {
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* STANDALONE preview (/widget/ opened directly): keep the centered card. */
html[data-mode="standalone"] .widget {
  max-width: 480px;
  max-height: 760px;
}

/* Topbar — brand + close */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 14px;
  flex: none;
}
/* Host-framed modes (docked window / inline) bring their OWN chrome, so the
   brand "HighStack / ✕" topbar is hidden by DEFAULT — it's redundant there and
   reclaims ~42px of height (kills the extra scroll). Floating keeps it (the ✕
   is the only way to collapse back to the bubble). Opt it back in per-embed
   with data-show-header="1" on the loader <script>. */
html[data-mode="window"] .topbar,
html[data-mode="inline"] .topbar { display: none; }
html[data-show-header="1"] .topbar { display: flex; }
.brand {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.iconbtn {
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-dim);
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  transition: color .15s ease, background .15s ease;
}
.iconbtn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.iconbtn svg { width: 18px; height: 18px; }

/* Gradient frame — the magic ring that signals "AI" */
.frame {
  position: relative;
  flex: 1; min-height: 0;
  border-radius: var(--r-frame);
  padding: 1.4px;
  background: var(--grad);
  box-shadow: 0 0 0 .5px rgba(255,255,255,.04), 0 0 46px -8px var(--glow);
}
.frame__inner {
  height: 100%;
  border-radius: calc(var(--r-frame) - 1.4px);
  background: #0c0c0f;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   "Sal is responding" illumination (ported from the Sal redesign).
   ONE control point: `.widget.responding` (toggled in widget.js while a
   chat reply streams). Lights a rotating conic glow ring on the frame +
   a breathing inner flare + a glow halo on the online dot. All driven by
   the animated --a angle via the shared `flow` keyframe. Reuses the
   widget's brand vars (--accent / --accent-2 / --grad / --glow) so it
   re-themes with the embed — no hardcoded purples.
   ============================================================ */
@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes flow  { to { --a: 360deg; } }
@keyframes flare { 0%, 100% { opacity: .3; } 50% { opacity: .6; } }

/* Conic glow ring — sits ON TOP of the static gradient border of .frame.
   Idle: invisible. Responding: rotates + drop-shadow glow. The mask cuts
   the centre out so only the 2px border ring paints (matches frame radius). */
.frame::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1.4px;   /* match .frame's static gradient border so the ring sits exactly on it */
  background: conic-gradient(from var(--a),
    #fff 0%,
    var(--accent) 14%,
    var(--accent-2) 34%,
    color-mix(in srgb, var(--accent) 60%, #fff) 52%,
    var(--accent-2) 66%,
    var(--accent) 86%,
    #fff 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity .5s ease;
  pointer-events: none;
  z-index: 1;
}
.widget.responding .frame::before {
  opacity: 1;
  animation: flow 3s linear infinite;
  filter:
    drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 90%, transparent))
    drop-shadow(0 0 20px color-mix(in srgb, var(--accent-2) 50%, transparent));
}

/* Inner flare — a soft breathing glow inside the content viewport. Lives on
   .frame__inner (which is overflow:hidden + position:relative already) so it
   clips to the rounded panel and never escapes the frame. */
.frame__inner::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity .5s ease;
  pointer-events: none;
  z-index: 4;                 /* above messages bg, below composer/overlays */
  box-shadow:
    inset 0 0 56px -14px color-mix(in srgb, var(--accent) 55%, transparent),
    inset 0 0 90px -28px color-mix(in srgb, var(--accent-2) 42%, transparent);
}
.widget.responding .frame__inner::after {
  opacity: 1;
  animation: flare 2.3s ease-in-out infinite;
}

/* Icon glow — the online presence dot in the chat header gains a pulsing
   halo while Sal responds (the widget's analogue of the redesign's icon glow). */
.widget.responding .online {
  background: var(--accent);   /* green presence → active accent while thinking */
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent),
    0 0 14px color-mix(in srgb, var(--accent) 90%, transparent);
  transition: box-shadow .4s ease, background .4s ease;
}

/* Avatar aura — a rotating rainbow halo behind Sal's chat-header avatar while
   he responds (the redesign's icon glow, adapted). The ::before sits at a
   negative z-index so the blurred ring spills BEHIND the avatar, not over it. */
.agentcard .avatar::before {
  content: "";
  position: absolute; inset: -7px;
  border-radius: 50%;
  z-index: -1;
  background: conic-gradient(from var(--a),
    #FF3333, #FF7700, #FF69B4, #9966FF, #4499FF, #AAFF33, #00FFCC, #FF3333);
  filter: blur(9px);
  opacity: 0;
  transition: opacity .5s ease;
  pointer-events: none;
}
.widget.responding .agentcard .avatar::before {
  opacity: .9;
  animation: flow 3s linear infinite;
}

/* Avatar (used in agent cards, roster cards, voice stage) */
.avatar {
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 600;
  letter-spacing: -.01em;
  position: relative;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 14px -4px rgba(0,0,0,.4);
}
/* Per-agent gradients. Salvador (the single concierge) uses the HighStack
   brand gradient by default; widget.js overrides it inline when a host
   passes custom accent colours. The others remain for internal/legacy use. */
/* Sal's profile image — the HighStack Λ logo. One rule skins every avatar
   (hero, chat header, voice, message bubbles) since they all carry
   data-agent="salvador". color:transparent hides the fallback monogram. */
.avatar[data-agent="salvador"] { background: #15102b url('sal-avatar.png?v=20260622m') center/cover no-repeat; color: transparent; box-shadow: 0 0 0 1px rgba(255,255,255,.10), 0 4px 14px -4px rgba(123,92,255,.45); }
.avatar[data-agent="vex"]  { background: linear-gradient(140deg, #8b5cf6, #d946ef); box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 14px -4px rgba(217,70,239,.4); }
.avatar[data-agent="kaio"] { background: linear-gradient(140deg, #fbbf24, #f472b6); box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 14px -4px rgba(244,114,182,.4); }
.avatar[data-agent="zayn"] { background: linear-gradient(140deg, #38bdf8, #6366f1); box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 4px 14px -4px rgba(99,102,241,.4); }

/* ── HOME view (tabs · ask · tickets · history) ───────────────────── */
.home { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabs {
  display: flex; gap: 6px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tab {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0;
  transition: color .15s ease, background .15s ease;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab.active {
  background: rgba(255,255,255,.07);
  color: var(--text);
  border-color: var(--line);
}
.count {
  display: inline-grid; place-items: center;
  min-width: 17px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  color: var(--text-dim);
  font-size: 10px; font-weight: 600;
  margin-left: 7px; letter-spacing: 0;
}
.home__body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 15px 16px;
  display: flex; flex-direction: column; gap: 22px;
}
.home__body::-webkit-scrollbar      { width: 7px; }
.home__body::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.08); border-radius: 99px; }
.home__body::-webkit-scrollbar-track{ background: transparent; }

.empty {
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
  padding: 30px 10px;
}

/* Hero (Vex front-door card on the Ask tab) */
.hero {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 3px;
  padding: 8px 6px 2px;
}
.hero__ring {
  padding: 3px;
  border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 0 38px -6px var(--glow);
  margin-bottom: 9px;
}
.hero__ring .avatar {
  box-shadow: 0 0 0 3px #0c0c0f inset, 0 0 0 3px #0c0c0f !important;
}
.hero__name { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.hero__sub  { font-size: 12.5px; color: var(--text-dim); }
.hero__line {
  font-size: 13.5px; line-height: 1.5;
  color: #b9b9c2; max-width: 300px;
  margin-top: 7px; text-wrap: pretty;
}
.hero__starters {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 13px;
}

.starter {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  color: var(--text-dim);
  border-radius: 99px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.starter:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--c, #a78bfa) 55%, transparent);
  background: rgba(255,255,255,.05);
}
.starter--vex:hover { border-color: rgba(167,139,250,.6); }

.home__section { display: flex; flex-direction: column; gap: 10px; }
.home__label {
  font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 2px 1px;
}

.pick { display: flex; flex-direction: column; gap: 8px; }
.starters { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 2px 4px 4px; }

/* Roster card — specialist picker */
.rostercard {
  display: flex; align-items: center; gap: 11px;
  text-align: left; width: 100%;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  cursor: pointer; font-family: inherit;
  color: var(--text);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.rostercard:hover {
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.055);
  transform: translateX(2px);
}
.rostercard__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rostercard__top  { display: flex; align-items: baseline; gap: 8px; }
.rostercard__name { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.rostercard__role { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.rostercard__domain { font-size: 12px; color: var(--text-dim); line-height: 1.35; text-wrap: pretty; }
.rostercard__arrow  { color: var(--text-faint); flex: none; display: flex; }

/* Tickets list */
.ticket {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  background: rgba(255,255,255,.022);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
.ticket:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.05); }
.ticket__meta { flex: 1; min-width: 0; }
.ticket__top  { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ticket__subject { font-size: 13.5px; font-weight: 600; }
.ticket__time    { font-size: 11px; color: var(--text-faint); flex: none; }
.ticket__bottom  { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 99px; border: 1px solid;
}
.ticket__ref { font-size: 11px; color: var(--text-faint); font-family: ui-monospace, Menlo, monospace; }

/* History list */
.convo {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  background: transparent; border: 0;
  border-radius: 12px; padding: 9px 8px;
  color: var(--text);
  transition: background .15s ease;
}
.convo:hover { background: rgba(255,255,255,.045); }
.convo--new {
  border: 1px dashed var(--line);
  margin-bottom: 8px;
}
.convo--new:hover { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.03); }
.convo__meta  { flex: 1; min-width: 0; }
.convo__top   { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.convo__title { font-size: 13.5px; font-weight: 600; }
.convo__time  { font-size: 11px; color: var(--text-faint); flex: none; }
.convo__last  { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* ── CHAT view ────────────────────────────────────────────────────── */
.agentcard {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
  flex: none;
}
.agentcard__meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.agentcard__name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.agentcard__role { font-size: 12.5px; color: var(--text-dim); }
.agentcard__back { color: var(--text-dim); margin: 0 -2px 0 -4px; }
.online {
  margin-left: auto;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 3px rgba(39,196,107,.16);
}
.agentcard__switch { transition: opacity .3s ease; }

/* The chat view must be a bounded flex column filling frame__inner, so the
   .messages child's flex:1 + min-height:0 actually computes a fixed height
   and overflow-y kicks in. Without this, .chat is display:block and the
   message list grows unbounded → no scroll (the bug). */
.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 18px 15px 8px;
  display: flex; flex-direction: column; gap: 11px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar      { width: 7px; }
.messages::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.08); border-radius: 99px; }
.messages::-webkit-scrollbar-track{ background: transparent; }

.msg {
  max-width: 80%;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  border-radius: 17px;
  animation: msg-pop .26s cubic-bezier(.2,.8,.3,1.2);
  word-wrap: break-word;
  text-wrap: pretty;
  white-space: pre-wrap;
}
@keyframes msg-pop { from { transform: translateY(7px) scale(.985); } to { transform: none; } }

/* Glowing streaming caret — appended after the bot text while it streams.
   widget.js adds/removes `.stream` on the bubble's .msg__body. */
.msg__body.stream::after {
  content: "";
  display: inline-block;
  width: 6px; height: 13px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--accent, #7c5cff);
  box-shadow: 0 0 8px var(--accent, #7c5cff);
  animation: caret .8s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* Accessibility: honour reduced-motion. Keep the responding STATE legible
   (ring + flare + caret stay visible) but stop the rotation/breath/blink. */
@media (prefers-reduced-motion: reduce) {
  .widget.responding .frame::before,
  .widget.responding .frame__inner::after,
  .widget.responding .agentcard .avatar::before,
  .msg__body.stream::after {
    animation: none !important;
  }
  .widget.responding .frame::before     { opacity: 1; }
  .widget.responding .frame__inner::after { opacity: .45; }
  .widget.responding .agentcard .avatar::before { opacity: .9; }
}
/* User bubble: an accent-TINTED surface, not a solid accent fill — light
   text then stays readable on any accent hue (no white-on-green). */
.msg--user  {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 28%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
  color: #fff; border-bottom-right-radius: 6px;
}
.msg--agent { align-self: flex-start; background: var(--surface-2); color: #dadae0; border-bottom-left-radius: 6px; }
/* Human support agent — distinct blue, with their name, so it never reads as
   Sal. (Sal = neutral grey, player = accent, human = blue.) */
.msg--human {
  align-self: flex-start;
  background: color-mix(in srgb, #2f6df6 16%, var(--surface-2));
  border: 1px solid color-mix(in srgb, #2f6df6 32%, transparent);
  color: #eef2ff; border-bottom-left-radius: 6px;
}
.msg__who { font-size: 11px; font-weight: 700; color: #8ab4ff; margin-bottom: 3px; }
/* Per-message timestamp — subtle, right-aligned under the text. */
.msg__time {
  font-size: 10px; line-height: 1;
  color: currentColor; opacity: .45;
  text-align: right; margin-top: 4px;
  user-select: none;
}
.msg--error { font-style: italic; opacity: .75; }
.msg__retry {
  display: block; margin-top: 7px;
  background: transparent; border: 1px solid var(--line);
  color: var(--accent, #0efda8); font: 600 12px/1 inherit; font-family: inherit;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.msg__retry:hover { border-color: color-mix(in srgb, var(--accent, #0efda8) 50%, transparent); }

.typing {
  align-self: flex-start;
  background: var(--surface-2);
  border-radius: 17px;
  border-bottom-left-radius: 6px;
  padding: 14px 15px;
  display: flex; gap: 5px;
}
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7d7d86;
  animation: typing-blink 1.3s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typing-blink {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-3px); }
}

/* Handoff divider — chip in the middle of the chat */
.divider {
  align-self: stretch;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin: 6px 0;
  font-size: 12px; color: var(--text-dim);
  animation: msg-pop .3s ease;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line-soft);
}
.divider__chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 11px 5px 6px;
  white-space: nowrap;
}
.divider__chip strong { color: #fff; font-weight: 600; }

/* ── Composer ───────────────────────────────────────────────────── */
.composer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 4px 4px;
  flex: none;
}
/* Camera button — the obvious place to send Sal a photo to analyse. Tinted to
   the accent so it reads as an action, not a faint icon. */
.attach {
  flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent, #0efda8) 16%, transparent);
  color: var(--accent, #0efda8);
  border: 1px solid color-mix(in srgb, var(--accent, #0efda8) 42%, transparent);
  cursor: pointer; display: grid; place-items: center;
  transition: filter .15s ease, transform .12s ease, background .15s ease;
}
.attach:hover  { filter: brightness(1.12); background: color-mix(in srgb, var(--accent, #0efda8) 24%, transparent); }
.attach:active { transform: scale(.94); }
.attach svg { width: 20px; height: 20px; }

/* Pending image attachment preview, above the composer. Solid background +
   real vertical breathing room + raised stacking — the chip must never sit
   ON the gradient frame border (observed: frame line cutting through it). */
.attach-preview {
  display: flex; align-items: center; gap: 9px;
  margin: 10px 8px 8px;
  padding: 7px 9px;
  background: var(--bg, #0d0d12);
  border: 1px solid var(--line);
  border-radius: 12px;
  position: relative; z-index: 3;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.attach-preview img {
  width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex: none;
}
.attach-preview__name {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-preview__remove {
  flex: none; background: transparent; border: 0; cursor: pointer;
  color: var(--text-faint); font-size: 14px; padding: 4px 6px;
}
.attach-preview__remove:hover { color: var(--text); }

/* Image inside a chat bubble */
.msg__img {
  display: block; max-width: 100%; border-radius: 12px;
  margin: 2px 0 0;
}
.input { position: relative; flex: 1; }
.input input {
  width: 100%;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 23px;
  padding: 13px 46px 13px 17px;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease;
}
.input input::placeholder { color: var(--text-faint); }
.input input:focus { border-color: rgba(124,92,255,.5); }
.send {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-faint);
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  transition: color .15s ease;
}
.send.active { color: var(--accent); }
.send svg { width: 18px; height: 18px; }

.mic {
  flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  background: #fff; color: #141414;
  border: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px -6px rgba(0,0,0,.6);
  transition: transform .15s ease;
}
.mic:hover  { transform: scale(1.05); }
.mic:active { transform: scale(.96);  }
.mic svg { width: 20px; height: 20px; }

/* Legacy video button — kept in markup, hidden in CSS until Marketing
   wants the LiveAvatar demo back. */
.video-btn { display: none !important; }

/* ── VOICE overlay (covers .frame__inner while active) ─────────── */
.overlay {
  position: absolute; inset: 0; z-index: 6;
  background: rgba(8,8,11,.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  border-radius: inherit;
  animation: overlay-rise .26s cubic-bezier(.2,.8,.3,1);
}
@keyframes overlay-rise { from { transform: scale(1.015); } to { transform: none; } }

/* The call screen is split into fixed REGIONS that never overlap:
   status (top) · presence orb (grows) · captions (safe area) · controls
   (bottom). The caption feed gets its own bounded zone so it can never
   collide with the orb above or the buttons below. */
.voice {
  align-items: center; justify-content: flex-start; gap: 14px;
  padding: 22px 20px 20px;
  text-align: center;
}
.voice__status {
  flex: none;
  font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-dim);
  padding-top: 2px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 18px;
  transition: color .25s ease;
}
/* Status dot reflects the state at a glance. */
.livedot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim); display: inline-block;
  transition: background .25s ease, box-shadow .25s ease;
}
.voice[data-state="listening"] .voice__status { color: #59d98e; }
.voice[data-state="listening"] .livedot { background: #27c46b; box-shadow: 0 0 0 3px rgba(39,196,107,.16); }
.voice[data-state="thinking"]  .voice__status { color: #f0b54a; }
.voice[data-state="thinking"]  .livedot { background: #f0b54a; box-shadow: 0 0 0 3px rgba(240,181,74,.16); animation: dot-think 1s ease-in-out infinite; }
.voice[data-state="speaking"]  .voice__status { color: color-mix(in srgb, var(--accent, #7c5cff) 80%, #fff); }
.voice[data-state="speaking"]  .livedot { background: var(--accent, #7c5cff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #7c5cff) 22%, transparent); }
@keyframes dot-think { 0%,100% { opacity: .4; } 50% { opacity: 1; } }
.voice__center {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
}

/* ── The "soul" orb — a living aura that breathes, drifts and glows ──────
   Built from layered radial gradients + slow transforms so it reads as a
   presence speaking, not a static disc. Tinted to the agent's accent
   (--accent / --accent-2). Reacts to state via [data-state] on the wrap. */
.voice__avatar {
  position: relative;
  width: 168px; height: 168px;
  display: grid; place-items: center;
  --orb-a: var(--accent, #7c5cff);
  --orb-b: var(--accent-2, #d946ef);
}

/* Outer soft halo (the "aura"). Calm + dim by default; brighter only while
   speaking. */
.voice__avatar::before {
  content: "";
  position: absolute; inset: -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--orb-a) 55%, transparent) 0%,
    color-mix(in srgb, var(--orb-b) 28%, transparent) 38%,
    transparent 70%);
  filter: blur(14px);
  opacity: .42;
  animation: soul-halo 6s ease-in-out infinite;
}
@keyframes soul-halo {
  0%,100% { transform: scale(.95); opacity: .38; }
  50%     { transform: scale(1.04); opacity: .58; }
}

/* Concentric ripple rings — the "sound going out" cue. OFF unless speaking. */
.ring {
  position: absolute; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--orb-a) 70%, transparent);
  opacity: 0; width: 150px; height: 150px;
  animation: none;
}
@keyframes voice-ripple {
  0%   { transform: scale(.75); opacity: .45; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* The orb itself — replaces the flat monogram disc with a fluid aura.
   We hide the letter and paint living gradient layers instead. A gentle,
   slow breathe by default (a calm living presence). */
.voice__avatar .avatar {
  position: relative;
  width: 120px; height: 120px; border-radius: 50%;
  color: transparent;                 /* hide the monogram letter */
  background:
    radial-gradient(120% 120% at 30% 25%, #fff6 0%, transparent 40%),
    radial-gradient(120% 120% at 70% 80%, color-mix(in srgb, var(--orb-b) 80%, #000) 0%, transparent 55%),
    radial-gradient(140% 140% at 50% 40%, var(--orb-a) 0%, color-mix(in srgb, var(--orb-b) 90%, #000) 100%) !important;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.10) inset,
    0 0 48px -6px color-mix(in srgb, var(--orb-a) 65%, transparent) !important;
  overflow: hidden;
  animation: soul-breathe 6s ease-in-out infinite;   /* gentle by default */
}
/* A second drifting blob inside the orb — drifts only while speaking. */
.voice__avatar .avatar::after {
  content: "";
  position: absolute; inset: -20%;
  background: radial-gradient(40% 40% at 50% 50%,
    color-mix(in srgb, #fff 70%, var(--orb-a)) 0%, transparent 60%);
  opacity: .3; mix-blend-mode: screen;
  animation: none;
}
@keyframes soul-breathe {
  0%,100% { transform: scale(.98); }
  50%     { transform: scale(1.035); }
}
@keyframes soul-drift {
  0%   { transform: translate(-12%, 8%)  scale(1); }
  33%  { transform: translate(14%, -10%) scale(1.15); }
  66%  { transform: translate(-8%, -6%)  scale(.9); }
  100% { transform: translate(-12%, 8%)  scale(1); }
}
/* THINKING pulse — a clear "processing" beat (scale + brightness). */
@keyframes soul-think {
  0%,100% { transform: scale(.97); filter: brightness(.9); }
  50%     { transform: scale(1.06); filter: brightness(1.18); }
}

/* ── STATE REACTIONS — thinking / listening / speaking, unmistakable ─────
   PJ: the audio animations move ONLY when Salvador speaks. So ripples + the
   wave dance + the orb drift are gated to [data-state="speaking"]. Listening
   is calm; thinking is a distinct processing pulse. */

/* LISTENING — calm and steady; mic is open, Sal is quiet. Nothing "audio". */
.voice[data-state="listening"] .voice__avatar .avatar { animation-duration: 6.5s; }

/* THINKING — orb pulses (processing); still no ripples / no audio motion. */
.voice[data-state="thinking"] .voice__avatar .avatar { animation: soul-think 1.3s ease-in-out infinite; }
.voice[data-state="thinking"] .voice__avatar::before  { animation-duration: 2.6s; opacity: .55; }

/* SPEAKING — fully alive: faster breathe + drift + ripple rings emanate. */
.voice[data-state="speaking"] .voice__avatar::before { animation-duration: 2s; opacity: .68; }
.voice[data-state="speaking"] .voice__avatar .avatar { animation-duration: 2.3s; }
.voice[data-state="speaking"] .voice__avatar .avatar::after { animation: soul-drift 6.5s ease-in-out infinite; opacity: .5; }
.voice[data-state="speaking"] .ring--1 { animation: voice-ripple 3s ease-out infinite; }
.voice[data-state="speaking"] .ring--2 { animation: voice-ripple 3s ease-out infinite 1.5s; }

/* Waveform under the orb — the clearest "audio out" indicator. It is FLAT and
   dim by default; it only dances while SPEAKING (a gentle shimmer while
   thinking). Each bar carries its own inline duration/delay (set in JS) so the
   dance reads organic; we just toggle the animation-name per state. */
.wave { display: flex; align-items: center; gap: 4px; height: 42px; }
.wave i {
  width: 4px; border-radius: 99px;
  background: linear-gradient(180deg, var(--accent, #a78bfa), var(--accent-2, #ec4899));
  transform-origin: center; display: block;
  transform: scaleY(.2); opacity: .4;          /* flat + dim = quiet */
  animation-name: none;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  transition: opacity .25s ease;
}
.voice[data-state="listening"] .wave i { transform: scaleY(.18); opacity: .38; }
.voice[data-state="thinking"]  .wave i { animation-name: wave-think; opacity: .7; }
.voice[data-state="speaking"]  .wave i { animation-name: voice-wv;  opacity: 1; }
@keyframes voice-wv {
  0%, 100% { transform: scaleY(.45); }
  50%      { transform: scaleY(1.05); }
}
@keyframes wave-think {
  0%, 100% { transform: scaleY(.22); }
  50%      { transform: scaleY(.5); }
}

.voice__name { font-size: 19px; font-weight: 700; }
.voice__role { font-size: 13px;  color: var(--text-dim); margin-top: 2px; }
/* ── Live call captions — a rolling 2-speaker feed (player + Sal) ────────
   Subtitle-style: the player's lines sit to the right (accent-tinted), Sal's
   to the left (neutral). This is its OWN fixed-height region (a safe area) —
   a sibling of the orb, never overlapping it or the controls. Newest line
   sits at the bottom; older lines scroll up and fade out at the top edge. */
.voice__transcript {
  flex: 0 1 auto;                       /* dedicated region; may shrink if tight */
  width: 100%; max-width: 380px;
  height: 150px; max-height: 36vh;      /* safe area (~5-6 lines), bounded on short panels */
  margin: 0 auto;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 7px;
  overflow-y: auto; overflow-x: hidden;
  padding: 10px 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
}
.voice__transcript::-webkit-scrollbar { width: 4px; }
.voice__transcript::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.cap {
  display: flex; flex-direction: column; gap: 5px;
  max-width: 84%;
  animation: cap-in .18s ease;
}
.cap + .cap { margin-top: 4px; }   /* clear separation between turns */
.cap--you   { align-self: flex-end;   align-items: flex-end;   text-align: right; }
.cap--agent { align-self: flex-start; align-items: flex-start; text-align: left; }
.cap__who {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-dim); opacity: .85;
  padding: 0 6px;
}
.cap--agent .cap__who { color: var(--accent, #7c5cff); opacity: 1; }
.cap__txt {
  font-size: 14px; line-height: 1.45; text-wrap: pretty;
  padding: 6px 11px; border-radius: 13px;
  background: var(--surface-2, rgba(255,255,255,.05));
  color: #e7e7ee;
  overflow-wrap: anywhere;             /* long tokens wrap, never clip sideways */
  white-space: normal;
}
.cap--you .cap__txt {
  background: color-mix(in srgb, var(--accent, #7c5cff) 22%, transparent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cap--agent .cap__txt { border-bottom-left-radius: 4px; }
@keyframes cap-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.voice__controls {
  display: flex; gap: 16px;
  margin-top: auto; padding-bottom: 4px;
}
.vbtn {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all .15s ease;
}
.vbtn:hover { background: var(--surface-2); }
.vbtn svg   { width: 22px; height: 22px; }
.vbtn--end  { background: #e5484d; border-color: #e5484d; color: #fff; }
.vbtn--end:hover { filter: brightness(1.1); }
.vbtn--active { background: #fff; color: #141414; }
.voice__transferhint {
  font-size: 11.5px; color: var(--text-faint);
  padding-top: 8px;
}
.avatar-morph { animation: voice-morph 1.7s ease; }
@keyframes voice-morph {
  0%   { transform: scale(1); }
  45%  { transform: scale(.8); filter: blur(1.5px); opacity: .7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Toast (transient notices, e.g. errors) */
.toast {
  position: absolute; bottom: 90px; left: 16px; right: 16px;
  background: rgba(8,8,11,.92);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 12px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 12;
}
.toast.visible { opacity: 1; transform: none; }

/* ── Feedback & rewards tab ─────────────────────────────────────────── */
.fb-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent, #0efda8); margin-left: 6px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #0efda8) 22%, transparent);
}
#paneFeedback { display: flex; flex-direction: column; gap: 16px; position: relative; }
#paneFeedback.fb-form-open > *:not(.fb-form) { display: none; }

/* Rewards points card */
.rewards {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px; border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(130% 150% at 100% 0%, color-mix(in srgb, var(--accent, #0efda8) 16%, transparent), transparent 60%),
    var(--surface-2, #1b1b20);
}
.rewards__l { flex: 1; min-width: 0; }
.rewards__label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }
.rewards__pts { font-size: 30px; font-weight: 800; line-height: 1.1; margin-top: 3px; }
.rewards__unit { font-size: 14px; font-weight: 700; color: var(--accent, #0efda8); margin-left: 6px; }
.rewards__redeem {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center;
  color: #04140d; background: var(--accent, #0efda8);
  box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--accent, #0efda8) 80%, transparent);
  transition: filter .15s ease, transform .12s ease;
}
.rewards__redeem:hover  { filter: brightness(1.08); }
.rewards__redeem:active { transform: scale(.94); }
.rewards__redeem:disabled { opacity: .5; cursor: default; }
.rewards__redeem svg { width: 20px; height: 20px; }

.fb-intro__title { font-size: 17px; font-weight: 700; }
.fb-intro__sub   { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-top: 4px; }
.fb-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }

.fb-earn, .fb-recent { display: flex; flex-direction: column; gap: 10px; }

/* Earn rows + recent rows share the card shell */
.earn, .rct {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2, #1b1b20);
  color: var(--text); font-family: inherit;
}
.earn { cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .12s ease; }
.earn:hover  { border-color: color-mix(in srgb, var(--accent, #0efda8) 45%, transparent); background: rgba(255,255,255,.03); }
.earn:active { transform: scale(.99); }
.earn__icon, .rct__icon {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--accent, #0efda8);
  background: color-mix(in srgb, var(--accent, #0efda8) 14%, transparent);
}
.rct__icon { color: var(--text-dim); background: rgba(255,255,255,.05); }
.earn__icon svg, .rct__icon svg { width: 19px; height: 19px; }
.earn__meta, .rct__meta { flex: 1; min-width: 0; }
.earn__title, .rct__title { font-size: 14px; font-weight: 650; }
.rct__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.earn__desc, .rct__sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.fb-pts {
  flex: none; font-size: 12px; font-weight: 800;
  color: var(--accent, #0efda8);
  background: color-mix(in srgb, var(--accent, #0efda8) 14%, transparent);
  border-radius: 999px; padding: 4px 10px;
}
.fb-pts--spend { color: #f6a93b; background: rgba(246,169,59,.14); }

/* Inline form (replaces the list while open) */
.fb-form { display: flex; flex-direction: column; gap: 12px; }
.fb-form__back {
  align-self: flex-start; background: transparent; border: 0; cursor: pointer;
  color: var(--text-dim); font-size: 13px; font-family: inherit; padding: 0;
}
.fb-form__back:hover { color: var(--text); }
.fb-form__head { display: flex; align-items: center; gap: 12px; }
.fb-form__icon {
  flex: none; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: var(--accent, #0efda8); background: color-mix(in srgb, var(--accent, #0efda8) 14%, transparent);
}
.fb-form__icon svg { width: 19px; height: 19px; }
.fb-form__title { font-size: 16px; font-weight: 700; }
.fb-form__sub   { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.fb-form__head .fb-pts { margin-left: auto; }
.fb-stars { display: flex; gap: 6px; }
.star {
  background: transparent; border: 0; cursor: pointer; font-size: 26px; line-height: 1;
  color: rgba(255,255,255,.18); padding: 2px; transition: color .12s ease, transform .12s ease;
}
.star:hover  { transform: scale(1.1); }
.star--on    { color: var(--accent, #0efda8); }
.fb-form__input {
  width: 100%; box-sizing: border-box; resize: none;
  background: var(--surface-2, #1b1b20); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.5; outline: none;
}
.fb-form__input:focus { border-color: color-mix(in srgb, var(--accent, #0efda8) 50%, transparent); }
.fb-form__submit {
  width: 100%; border: 0; cursor: pointer; margin-top: 2px;
  background: var(--accent, #0efda8); color: #04140d;
  font-weight: 700; font-size: 14px; font-family: inherit;
  padding: 13px; border-radius: 12px; transition: filter .15s ease;
}
.fb-form__submit:hover    { filter: brightness(1.08); }
.fb-form__submit:disabled { opacity: .6; cursor: default; }

/* Utility */
.hidden { display: none !important; }
