/* =================================================================
   ASSISTANT: the avatar in the bottom-right corner and its chat panel.
   Shared with public/assistant.js. Colours come from theme.css, so light and dark
   follow the page; the avatar is drawn in the three brand colours (--onyx, --green, --purple).
   ================================================================= */

.as-launch {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  width: 80px; height: 80px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  filter: drop-shadow(0 6px 10px rgba(20, 26, 34, 0.22));
  }
/* No grow on hover (owner, 15 Oct): the smile is the hover cue. */
.as-launch:focus-visible { outline: 3px solid var(--purple, #6F8EFF); outline-offset: 3px; }
.as-launch[hidden], .as-panel[hidden] { display: none; }
.as-launch svg, .as-avatar svg { display: block; width: 100%; height: 100%; }
.as-avatar { display: inline-block; width: 36px; height: 36px; flex: none; }

/* Avatar: one drawing, a face per state (data-state on the svg). */
.as-face { display: none; }
svg[data-state="idle"] .as-face-idle,
svg[data-state="happy"] .as-face-happy,
svg[data-state="think"] .as-face-think,
svg[data-state="error"] .as-face-error,
svg[data-state="limit"] .as-face-limit { display: inline; }
.as-eye { transform-box: fill-box; transform-origin: center; animation: as-blink 9s infinite; }
.as-eye + .as-eye { animation-delay: 0s; }
.as-dot { animation: as-dot 1.1s infinite ease-in-out; }
.as-dot:nth-child(2) { animation-delay: .16s; }
.as-dot:nth-child(3) { animation-delay: .32s; }
/* Personality (owner, 15 Oct; previewed on /dexi-motion-test): a blink, and every 9 seconds a quick double blink. */
@keyframes as-blink { 0%, 30%, 34%, 88%, 100% { transform: scaleY(1); } 32% { transform: scaleY(.12); }
  90%, 94.5% { transform: scaleY(.12); } 92% { transform: scaleY(1); } }
/* A look around every 14 seconds: left, right, back. */
.as-glance { animation: as-glance 14s infinite ease-in-out; }
@keyframes as-glance { 0%, 60%, 100% { transform: translate(0, 0); } 63%, 70% { transform: translate(-4px, 0); }
  73%, 80% { transform: translate(4px, -1px); } 83% { transform: translate(0, 0); } }
/* Happy to see you: smiling eyes while the pointer is on the launcher. */
.as-launch:hover svg[data-state="idle"] .as-face-idle { display: none; }
.as-launch:hover svg[data-state="idle"] .as-face-happy { display: inline; }
/* Leans towards the pointer (assistant.js sets the transform). */
.as-look { transition: transform .25s ease-out; }
/* Pleased with an answer: a small bounce. */
.as-bounce { animation: as-bounce .6s ease-out; }
@keyframes as-bounce { 0% { transform: scale(1); } 35% { transform: scale(1.08); } 70% { transform: scale(.98); } 100% { transform: scale(1); } }
/* Wakes up once a visit: eyes open from closed with a small hop. */
.as-face-idle { transform-box: fill-box; transform-origin: center bottom; transition: transform 1.4s ease-in-out; }
.as-waking { animation: as-hop .9s ease-out; }
.as-waking .as-face-idle { transform-origin: center; animation: as-open .9s ease-out; }
@keyframes as-open { 0%, 35% { transform: scaleY(.1); } 55% { transform: scaleY(1.15); } 70%, 100% { transform: scaleY(1); } }
@keyframes as-hop { 0%, 40% { transform: translateY(0); } 58% { transform: translateY(-7px); } 76% { transform: translateY(0); } 86% { transform: translateY(-2px); } 100% { transform: translateY(0); } }
/* Dozes off after a few quiet minutes: eyes half closed, no blinking; any movement wakes it. */
.as-dozing .as-eye { animation: none; }
.as-dozing .as-face-idle { transform: scaleY(.3); }
@keyframes as-dot { 0%, 70%, 100% { opacity: .35; } 35% { opacity: 1; } }

/* The chat panel: "Sky" (owner, 15 Oct 2026, after a reference image and a few rounds on /dexi-style-test). A soft blue and violet
   glow at the top that drifts slowly and fades into the panel, glass bubbles over it, and the message box in a soft grey frame
   with the allowance and a small meter on top. Light and dark follow theme.css. */
.as-panel {
  position: fixed; right: 20px; bottom: calc(112px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  width: 380px; max-width: calc(100vw - 24px); height: min(600px, calc(100vh - 144px));
  display: flex; flex-direction: column; overflow: hidden; isolation: isolate;
  background: var(--surface, #fff); color: var(--ink, #16191C);
  border-radius: 26px; box-shadow: 0 0 0 1px rgba(20, 26, 34, .06), 0 30px 70px -22px rgba(40, 60, 140, .45);
  font: 14px/1.5 'IBM Plex Sans', system-ui, sans-serif;
  animation: as-in .18s ease-out;
  --as-glow-1: rgba(111, 142, 255, .80); --as-glow-2: rgba(111, 142, 255, .95); --as-glow-3: rgba(140, 160, 255, .75); --as-glow-4: rgba(162, 139, 255, .80);
  --as-fade-from: 26%; --as-fade-to: 58%;
}
[data-theme="dark"] .as-panel { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 30px 70px -22px rgba(0, 0, 0, .8);
  --as-glow-1: rgba(111, 142, 255, .40); --as-glow-2: rgba(111, 142, 255, .50); --as-glow-3: rgba(140, 160, 255, .34); --as-glow-4: rgba(162, 139, 255, .42); }
/* A new chat (no questions yet): the glow reaches further down behind the greeting. */
.as-panel.as-start { --as-fade-from: 40%; --as-fade-to: 70%; }
/* The glow: soft blobs blurred into one wash at 50% (owner, 15 Oct: 80% was still too strong), drifting slowly. */
.as-panel::before { content: ''; position: absolute; inset: -25%; z-index: -2; pointer-events: none; opacity: .5;
  background:
    radial-gradient(36% 26% at 26% 30%, var(--as-glow-1), transparent 72%),
    radial-gradient(40% 30% at 66% 38%, var(--as-glow-2), transparent 74%),
    radial-gradient(38% 28% at 44% 56%, var(--as-glow-3), transparent 74%),
    radial-gradient(32% 24% at 80% 24%, var(--as-glow-4), transparent 72%),
    radial-gradient(30% 22% at 50% 22%, var(--as-glow-3), transparent 72%);
  filter: blur(26px); animation: as-drift 22s ease-in-out infinite alternate; }
/* Fades the glow into the panel's own colour towards the bottom. */
.as-panel::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, transparent var(--as-fade-from), var(--surface, #fff) var(--as-fade-to)); }
@keyframes as-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes as-drift { 0% { transform: translate(0, 0) rotate(0deg); } 50% { transform: translate(4%, 3%) rotate(7deg); } 100% { transform: translate(-3%, 5%) rotate(-5deg); } }

.as-head { display: flex; align-items: center; gap: 10px; padding: 16px 14px 6px 16px; }
.as-head .as-avatar { width: 38px; height: 38px; }
.as-title { flex: 1; min-width: 0; }
.as-title b { display: block; font-size: 14px; font-weight: 600; }
.as-title span { display: block; font-size: 12px; opacity: .72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-x { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--ink, #16191C); cursor: pointer; font-size: 19px; line-height: 1;
  background: rgba(255, 255, 255, .78); box-shadow: 0 2px 8px rgba(20, 26, 34, .12), inset 0 0 0 1px rgba(255, 255, 255, .9); }
.as-x:hover { background: #fff; }
[data-theme="dark"] .as-x { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
[data-theme="dark"] .as-x:hover { background: rgba(255, 255, 255, .18); }
.as-x:focus-visible, .as-send:focus-visible, .as-chip:focus-visible { outline: 2px solid var(--purple, #6F8EFF); outline-offset: 2px; }

.as-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
/* A new chat opens on a big greeting instead of a bubble. */
.as-hello { padding: 8px 4px 0; }
.as-hello p { margin: 0 0 6px; font-size: 15px; }
.as-hello .as-big { margin: 0; max-width: 300px; font-size: 31px; line-height: 1.08; letter-spacing: -.025em; font-weight: 700; }
.as-msg { max-width: 88%; padding: 9px 12px; border-radius: 18px; overflow-wrap: anywhere; }
.as-msg p { margin: 0; }
.as-msg p + p, .as-msg ul + p, .as-msg p + ul { margin-top: 6px; }
.as-msg ul { margin: 0; padding-left: 18px; }
.as-msg li + li { margin-top: 3px; }
.as-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* Dexi's answers: glass over the glow. Your questions: onyx (white in dark mode). */
.as-bot, .as-typing { align-self: flex-start; background: rgba(255, 255, 255, .74); border: 1px solid rgba(255, 255, 255, .9); border-bottom-left-radius: 6px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 4px 16px -6px rgba(20, 26, 34, .14); }
[data-theme="dark"] .as-bot, [data-theme="dark"] .as-typing { background: rgba(28, 33, 38, .72); border-color: rgba(255, 255, 255, .09); box-shadow: none; }
.as-me { align-self: flex-end; background: #16191C; color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 6px 16px -8px rgba(20, 26, 34, .6); }
[data-theme="dark"] .as-me { background: #F3F6F8; color: #16191C; }
.as-note { align-self: stretch; text-align: center; font-size: 13px; color: var(--muted, #6B7278); padding: 6px 10px; }
.as-note.as-bad { color: var(--down, #C4503C); }
.as-typing { display: flex; gap: 4px; padding: 12px 14px; border-radius: 18px; border-bottom-left-radius: 6px; }
.as-typing i { width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, #4BE891, #6F8EFF); animation: as-dot 1.1s infinite ease-in-out; }
.as-typing i:nth-child(2) { animation-delay: .16s; }
.as-typing i:nth-child(3) { animation-delay: .32s; }

.as-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; }
.as-chip { padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .85); border-radius: 999px; color: var(--ink, #16191C); font: inherit; font-size: 13px; cursor: pointer;
  background: rgba(255, 255, 255, .62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 2px 8px rgba(20, 26, 34, .06); }
.as-chip:hover { background: rgba(255, 255, 255, .9); }
[data-theme="dark"] .as-chip { border-color: rgba(255, 255, 255, .12); background: rgba(25, 29, 33, .55); }
[data-theme="dark"] .as-chip:hover { background: rgba(25, 29, 33, .85); }

/* The message box: a soft grey frame with the allowance and a meter on top, a white box inside. */
.as-dock { margin: 0 12px 12px; padding: 0 5px 5px; border-radius: 22px; border: 1px solid rgba(255, 255, 255, .7);
  background: linear-gradient(160deg, #EEF1F4 0%, #E2E6EA 55%, #D3D9DE 100%);
  box-shadow: 0 12px 28px -16px rgba(20, 26, 34, .3), 0 1px 3px rgba(20, 26, 34, .05); }
[data-theme="dark"] .as-dock { border-color: rgba(255, 255, 255, .08); background: linear-gradient(160deg, #2A3035 0%, #252A2F 55%, #20252A 100%);
  box-shadow: 0 12px 28px -16px rgba(0, 0, 0, .7); }
.as-meta { display: flex; align-items: center; gap: 8px; padding: 8px 9px 7px; font-size: 12.5px; color: #16191C; }
[data-theme="dark"] .as-meta { color: #E7EBED; }
.as-meta b { font-weight: 700; }
.as-meter { flex: none; width: 46px; height: 5px; margin-left: auto; border-radius: 3px; overflow: hidden; background: rgba(22, 25, 28, .12); }
/* Mid grey (owner, 15 Oct; was onyx): 3:1 against the frame. */
.as-meter i { display: block; height: 100%; border-radius: 3px; background: #7A838A; }
[data-theme="dark"] .as-meter { background: rgba(255, 255, 255, .12); }
[data-theme="dark"] .as-meter i { background: #8E979E; }
.as-form { padding: 12px 12px 10px 14px; border-radius: 18px; background: var(--surface, #fff); box-shadow: 0 1px 2px rgba(20, 26, 34, .05); }
[data-theme="dark"] .as-form { background: #14171A; }
.as-form:focus-within { box-shadow: inset 0 0 0 2px rgba(111, 142, 255, .55); }
.as-input { display: block; width: 100%; min-height: 44px; max-height: 96px; resize: none; padding: 0; border: 0; outline: 0; background: transparent;
  color: var(--ink, #16191C); font: inherit; font-size: 16px; line-height: 1.35; }
.as-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.as-row small { font-size: 12px; color: var(--muted, #6B7278); }
.as-send { flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: #fff;
  background: radial-gradient(120% 120% at 30% 20%, #4A5254, #16191C 70%); box-shadow: 0 4px 10px rgba(20, 26, 34, .3), inset 0 0 0 1px rgba(255, 255, 255, .14); }
[data-theme="dark"] .as-send { color: #16191C; background: linear-gradient(160deg, #F3F6F8, #B9C3C8); box-shadow: 0 2px 8px rgba(0, 0, 0, .4), inset 0 1px 0 #fff; }
.as-send:hover { filter: brightness(1.12); }
.as-send:disabled, .as-input:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 480px) {
  .as-launch { right: 14px; width: 68px; height: 68px; }
  .as-panel { right: 12px; left: 12px; width: auto; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); height: min(600px, calc(100vh - 116px)); }
}
@media (prefers-reduced-motion: reduce) {
  .as-eye, .as-dot, .as-typing i, .as-panel, .as-panel::before, .as-glance, .as-bounce, .as-waking, .as-waking .as-face-idle { animation: none; }
  .as-look, .as-face-idle { transition: none; }
  .as-launch, .as-launch:hover { transition: none; transform: none; }
}
@media print { .as-launch, .as-panel { display: none; } }
