/* ARIELA voice assistant: black notched glass, lime #B8FF2C, spinning dashed rings, avatar in a lime ring. */
.avb-ai {
  --ai-lime: #b8ff2c; --ai-lime-a: rgba(184,255,44,.55); --ai-lime-b: rgba(184,255,44,.22);
  --ai-text: #e6ece3; --ai-muted: #869088; --ai-dim: #5b645d;
  --ai-mono: ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --lvl: 0;
  position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1.1rem, calc(env(safe-area-inset-bottom) + 1rem));
  z-index: 9000; display: flex; flex-direction: column; align-items: flex-end; gap: .75rem;
  font-family: var(--font-sans, "Sora", system-ui, sans-serif); color: var(--ai-text);
}
.avb-ai button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* rings (shared) */
.avb-ai-rings { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.avb-ai-rings g { transform-origin: 50px 50px; transform-box: view-box; }
.avb-ai-rings .r1 { animation: avb-ai-spin 9s linear infinite; }
.avb-ai-rings .r2 { animation: avb-ai-spin 6s linear infinite reverse; }
.avb-ai-rings .r3 { animation: avb-ai-spin 14s linear infinite; }
.avb-ai-rings circle, .avb-ai-rings path { fill: none; stroke: var(--ai-lime); }
.avb-ai-rings .thin { stroke-width: .7; opacity: .25; }
.avb-ai-rings .d1 { stroke-width: 1.8; opacity: .75; stroke-dasharray: 30 9 3 9 60 20 2 5; filter: drop-shadow(0 0 2px var(--ai-lime)); }
.avb-ai-rings .d2 { stroke-width: 3.5; opacity: .22; stroke-dasharray: 1.5 4; }
.avb-ai-rings .d3 { stroke-width: 1.1; opacity: .5; stroke-dasharray: 60 10 14 10 3 10; }
.avb-ai-rings .tick { stroke-width: 1.4; opacity: .7; }
.avb-ai.is-listening .avb-ai-rings .r1, .avb-ai.is-speaking .avb-ai-rings .r1 { animation-duration: 2.6s; }
.avb-ai.is-listening .avb-ai-rings .r2, .avb-ai.is-speaking .avb-ai-rings .r2 { animation-duration: 1.8s; }
.avb-ai.is-thinking .avb-ai-rings .r3 { animation-duration: 1.4s; }
@keyframes avb-ai-spin { to { transform: rotate(360deg); } }

/* avatar */
.avb-ai-avatar { display: block; flex: none; border-radius: 50%; overflow: hidden; position: relative;
  box-shadow: 0 0 0 1.5px var(--ai-lime), 0 0 0 3.5px #050806, 0 0 16px rgba(184,255,44,.45); }
.avb-ai-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }

/* launcher: avatar inside spinning rings */
.avb-ai-launch { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: radial-gradient(circle, #0c140a 0%, #040605 72%); box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 26px rgba(184,255,44,.16);
  transition: transform .25s cubic-bezier(.2,.7,.2,1), box-shadow .25s; }
.avb-ai-launch:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 34px rgba(0,0,0,.6), 0 0 34px rgba(184,255,44,.32); }
.avb-ai-launch:focus-visible, .avb-ai-big:focus-visible { outline: 2px solid var(--ai-lime); outline-offset: 4px; }
.avb-ai-launch::after { content: ""; position: absolute; right: 4px; bottom: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ai-lime); box-shadow: 0 0 0 2px #050806, 0 0 10px var(--ai-lime); animation: avb-ai-breathe 2.6s ease-in-out infinite; }

/* panel: notched glass like ARIELA .panel */
.avb-ai-panel { --cut: 14px; position: relative; width: min(360px, calc(100vw - 2rem)); display: flex; flex-direction: column; padding: 12px 14px 10px;
  clip-path: polygon(var(--cut) 0,100% 0,100% calc(100% - var(--cut)),calc(100% - var(--cut)) 100%,0 100%,0 var(--cut));
  background: linear-gradient(135deg, rgba(184,255,44,.45), rgba(184,255,44,.12) 18%, rgba(184,255,44,.08) 80%, rgba(184,255,44,.38));
  animation: avb-ai-in .35s cubic-bezier(.2,.7,.2,1) both; filter: drop-shadow(0 18px 40px rgba(0,0,0,.7)); }
.avb-ai-panel::before { content: ""; position: absolute; inset: 1px; z-index: 0; background-color: #070a08;
  background-image: radial-gradient(260px 220px at 50% 42%, rgba(184,255,44,.07), transparent 70%), linear-gradient(rgba(184,255,44,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(184,255,44,.035) 1px, transparent 1px), linear-gradient(180deg, #0b0f0c, #050806);
  background-size: auto, 24px 24px, 24px 24px, auto;
  clip-path: polygon(calc(var(--cut) - .4px) 0,100% 0,100% calc(100% - var(--cut) + .4px),calc(100% - var(--cut) + .4px) 100%,0 100%,0 calc(var(--cut) - .4px)); }
.avb-ai-panel::after { content: ""; position: absolute; left: 0; top: 0; width: calc(var(--cut) + 18px); height: calc(var(--cut) + 18px); z-index: 1; pointer-events: none;
  background: linear-gradient(135deg, transparent calc(50% - 1px), var(--ai-lime) calc(50% - 1px), var(--ai-lime) calc(50% + .6px), transparent calc(50% + .6px)) 0 0 / calc(var(--cut) * 2) calc(var(--cut) * 2) no-repeat;
  filter: drop-shadow(0 0 4px var(--ai-lime)); }
.avb-ai-panel > * { position: relative; z-index: 1; }
@keyframes avb-ai-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.avb-ai-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "avatar id" "avatar tools";
  column-gap: 12px; row-gap: 8px;
  align-items: center;
  padding: 2px 0 10px 2px;
  border-bottom: 1px solid rgba(184,255,44,.12);
}
.avb-ai-avatar-head { grid-area: avatar; width: 56px; height: 56px; }
.avb-ai-id { grid-area: id; min-width: 0; }
.avb-ai-name {
  font-family: var(--ai-mono); font-weight: 700; font-size: 15px;
  letter-spacing: .16em; color: #fff;
  text-shadow: 0 0 14px rgba(184,255,44,.45);
  line-height: 1.2;
}
.avb-ai-state {
  font-family: var(--ai-mono); font-size: 10px; letter-spacing: .12em;
  color: var(--ai-lime); display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 8px; margin-top: 5px;
}
.avb-ai-count {
  color: var(--ai-dim); letter-spacing: .08em;
  margin-left: 0; flex: none;
  border: 1px solid var(--ai-lime-b); padding: 1px 6px; border-radius: 999px;
}
.avb-ai-tools {
  grid-area: tools; display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 8px; min-width: 0;
}
.avb-ai-actions { display: flex; align-items: center; gap: 4px; flex: none; margin-left: auto; }
.avb-ai-pulse { display: inline-block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ai-lime); box-shadow: 0 0 8px var(--ai-lime); position: relative; }
.avb-ai-pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--ai-lime); animation: avb-ai-ping 2.4s ease-out infinite; }
@keyframes avb-ai-ping { from { transform: scale(.6); opacity: .9; } to { transform: scale(2.3); opacity: 0; } }
.avb-ai-lang { display: flex; flex: none; border: 1px solid var(--ai-lime-b); clip-path: polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px); }
.avb-ai-lang button { font-family: var(--ai-mono) !important; font-size: 10.5px !important; font-weight: 700; letter-spacing: .1em; padding: 5px 7px; color: var(--ai-muted) !important; transition: color .2s, background .2s; }
.avb-ai-lang button:hover { color: #fff !important; }
.avb-ai-lang button.on { color: #0a0f04 !important; background: var(--ai-lime) !important; box-shadow: 0 0 12px rgba(184,255,44,.4); }
.avb-ai-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--ai-muted); border: 1px solid transparent; flex: none;
  clip-path: polygon(7px 0,100% 0,100% calc(100% - 7px),calc(100% - 7px) 100%,0 100%,0 7px); transition: color .2s, background .2s, border-color .2s; }
.avb-ai-icon:hover { color: #fff; background: rgba(184,255,44,.08); border-color: var(--ai-lime-b); }

/* stage: big tap-to-talk orb */
.avb-ai-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 4px 8px; text-align: center; }
.avb-ai-big { position: relative; width: 196px; height: 196px; border-radius: 50%; display: grid; place-items: center;
  transform: scale(calc(1 + var(--lvl) * .06)); transition: transform .08s linear; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.avb-ai-big:disabled { cursor: default; }
.avb-ai-big-core { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; color: #0a0f04;
  background: radial-gradient(circle at 40% 35%, #f0ffc8, var(--ai-lime) 48%, #6a9a10 100%);
  box-shadow: 0 0 22px rgba(184,255,44,.7), 0 0 60px rgba(184,255,44,.35), inset 0 -6px 14px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s; animation: avb-ai-breathe 3.2s ease-in-out infinite; }
.avb-ai-big:hover .avb-ai-big-core { transform: scale(1.05); }
.avb-ai-big:active .avb-ai-big-core { transform: scale(.95); }
.avb-ai.is-listening .avb-ai-big-core { animation: none; box-shadow: 0 0 calc(22px + var(--lvl) * 30px) rgba(184,255,44,.85), 0 0 calc(60px + var(--lvl) * 50px) rgba(184,255,44,.45); }
.avb-ai.is-listening .avb-ai-big::before { content: ""; position: absolute; inset: 40px; border-radius: 50%; border: 1.5px solid var(--ai-lime); animation: avb-ai-wave 1.4s ease-out infinite; }
.avb-ai.is-speaking .avb-ai-big-core { animation-duration: .7s; }
.avb-ai.is-thinking .avb-ai-big-core { animation-duration: 1.2s; filter: saturate(.8); }
.avb-ai-big:disabled .avb-ai-big-core { filter: grayscale(.2) brightness(.85); }
@keyframes avb-ai-breathe { 50% { transform: scale(1.08); box-shadow: 0 0 30px rgba(184,255,44,.85), 0 0 74px rgba(184,255,44,.45), inset 0 -6px 14px rgba(0,0,0,.25); } }
@keyframes avb-ai-wave { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
.avb-ai-dots { display: flex; gap: 5px; }
.avb-ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: #0a0f04; animation: avb-ai-blink 1s ease-in-out infinite; }
.avb-ai-dots i:nth-child(2) { animation-delay: .15s; } .avb-ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes avb-ai-blink { 50% { opacity: .25; transform: translateY(-2px); } }

.avb-ai-label { font-family: var(--ai-mono); font-size: 11px; letter-spacing: .22em; color: var(--ai-lime); text-shadow: 0 0 10px rgba(184,255,44,.35); min-height: 1.4em; }
.avb-ai-heard { font-size: 12px; color: var(--ai-muted); font-style: italic; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.avb-ai-caption { font-size: 13.5px; line-height: 1.5; color: #dfe7dc; max-width: 100%; min-height: 3em; max-height: 7.6em; overflow-y: auto; padding: 0 4px; overscroll-behavior: contain; }
.avb-ai-caption a { color: var(--ai-lime); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }

/* one-line text fallback (no speech recognition and no platform STT) */
.avb-ai-form { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid rgba(184,255,44,.12); }
.avb-ai-form input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; font: inherit; font-size: 13.5px; color: var(--ai-text);
  background: rgba(0,0,0,.45); border: 1px solid rgba(184,255,44,.18); outline: none; border-radius: 0; }
.avb-ai-form input:focus { border-color: var(--ai-lime-a); box-shadow: 0 0 0 3px rgba(184,255,44,.08); }
.avb-ai-form input::placeholder { color: var(--ai-dim); }
.avb-ai-send { height: 36px; padding: 0 14px; font-family: var(--ai-mono) !important; font-size: 11.5px !important; letter-spacing: .12em; text-transform: uppercase; font-weight: 700;
  color: #0a0f04 !important; background: var(--ai-lime) !important; clip-path: polygon(8px 0,100% 0,100% calc(100% - 8px),calc(100% - 8px) 100%,0 100%,0 8px); }
.avb-ai-send:disabled { opacity: .4; cursor: default; }
.avb-ai-foot { font-family: var(--ai-mono); font-size: 9.5px; letter-spacing: .06em; color: var(--ai-dim); padding-top: 8px; text-align: center; }
.avb-ai-foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.avb-ai-foot a:hover, .avb-ai-foot a:focus { color: var(--ai-lime); }


.avb-ai.is-soon .avb-ai-launch::after { background: var(--ai-dim); box-shadow: 0 0 0 2px #050806; animation: none; }
.avb-ai.is-soon .avb-ai-pulse { background: var(--ai-dim); box-shadow: none; }
.avb-ai.is-soon .avb-ai-pulse::after { display: none; }
.avb-ai.is-soon .avb-ai-state { color: var(--ai-muted); }
.avb-ai.is-soon .avb-ai-count { display: none; }

@media (max-width: 520px) {
  .avb-ai { right: .75rem; bottom: max(1rem, calc(env(safe-area-inset-bottom) + .75rem)); }
  .avb-ai-panel { width: calc(100vw - 1.5rem); }
  .avb-ai-launch { width: 64px; height: 64px; }
  .avb-ai-launch .avb-ai-avatar-launch { width: 44px !important; height: 44px !important; }
  .avb-ai-avatar-head { width: 52px !important; height: 52px !important; }
  .avb-ai-form input { font-size: 16px; } /* no iOS zoom */
}
@media (prefers-reduced-motion: reduce) {
  .avb-ai *, .avb-ai *::before, .avb-ai *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}

.avb-ai-panel[hidden] { display: none !important; }
