:host {
  all: initial;
  --chat-ink: #050607;
  --chat-surface: #0c1011;
  --chat-raised: #192123;
  --chat-text: #f4f4e9;
  --chat-muted: #b5c0bc;
  --chat-acid: #f3ee16;
  --chat-cyan: #00e1ef;
  --chat-line: #384344;
  --chat-layer: 70;
  position: relative;
  z-index: var(--allooao-chat-layer, var(--chat-layer));
  color: var(--chat-text);
  font: 400 14px/1.5 "Onest", Arial, sans-serif;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
button, textarea, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, a, textarea { outline: none; }
:focus-visible { outline: 2px solid var(--chat-cyan); outline-offset: 4px; }
svg { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.launcher {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: calc(var(--chat-launcher-bottom, 24px) + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  color: var(--chat-ink);
  background: var(--chat-acid);
  font-weight: 700;
  box-shadow: 0 3px 0 #737006;
  transition: transform 180ms cubic-bezier(.16,1,.3,1), background 180ms;
}
.launcher:hover { background: #fff943; transform: translateY(-2px); }
.launcher:active { transform: translateY(1px); }
.launcher[aria-expanded="true"] { background: var(--chat-raised); color: var(--chat-text); box-shadow: none; }
.launcher-icon { display: flex; }
.panel {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: calc(var(--chat-launcher-bottom, 24px) + 72px + env(safe-area-inset-bottom));
  width: min(408px, calc(100vw - 32px));
  height: min(656px, calc(var(--chat-vh, 100dvh) - var(--chat-launcher-bottom, 24px) - 88px));
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 14px;
  background: var(--chat-surface);
  animation: chat-enter 220ms cubic-bezier(.16,1,.3,1);
}
.panel.contact-only { height: auto; }
.panel.contact-only .thread { flex: 0 0 auto; }
.header { display: flex; align-items: center; gap: 12px; padding: 18px 14px 17px 20px; flex-shrink: 0; border-bottom: 1px solid var(--chat-line); }
.avatar { display: grid; place-items: center; width: 42px; height: 42px; overflow: hidden; flex-shrink: 0; color: var(--chat-cyan); background: #112629; border-radius: 9px; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.identity { min-width: 0; flex: 1; }
.identity h2 { margin: 0; color: var(--chat-text); font: 700 17px/1.3 "Onest", Arial, sans-serif; letter-spacing: -.02em; }
.identity p { margin: 3px 0 0; font-size: 12px; color: var(--chat-muted); }
.icon-button { display: grid; place-items: center; flex-shrink: 0; width: 44px; min-height: 44px; padding: 0; color: var(--chat-muted); border: 0; border-radius: 8px; background: transparent; transition: background 160ms, color 160ms; }
.icon-button:hover { background: var(--chat-raised); color: var(--chat-text); }
.human-route { display: flex; align-items: center; gap: 12px; min-height: 74px; margin: 0; padding: 13px 20px; color: var(--chat-text); background: #141c1e; text-decoration: none; flex-shrink: 0; border-bottom: 1px solid var(--chat-line); transition: background 160ms; }
.human-route:hover { background: #202d30; }
.human-route > svg:first-child { color: var(--chat-cyan); }
.human-route > svg:last-child { margin-left: auto; width: 18px; }
.human-route strong { display: block; font-size: 13px; font-weight: 600; }
.human-route small { display: block; font-size: 11px; color: var(--chat-muted); margin-top: 2px; }
.thread { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding-block: 16px; padding: 23px 20px 20px; scrollbar-gutter: stable; }
.welcome { margin-bottom: 24px; }
.welcome h3 { margin: 0 0 10px; font-size: 24px; font-weight: 600; letter-spacing: -.035em; line-height: 1.17; }
.welcome p { margin: 0; color: var(--chat-muted); font-size: 13px; line-height: 1.65; }
.suggestions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 20px; }
.suggestion { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 10px; min-height: 44px; border: 1px solid var(--chat-line); border-radius: 7px; background: transparent; color: var(--chat-text); padding: 9px 12px; font-size: 13px; transition: border-color 150ms, background 150ms; }
.suggestion svg { width: 15px; height: 15px; color: var(--chat-muted); }
.suggestion:hover { border-color: var(--chat-cyan); background: #112326; }
.messages { margin: 0; padding: 0; list-style: none; }
.message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 20px; gap: 6px; min-width: 0; }
.message:last-child { margin-bottom: 0; }
.message-label { font-size: 11px; color: var(--chat-muted); line-height: 1.4; }
.message-body { margin: 0; min-width: 0; max-width: 100%; color: var(--chat-text); white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; font-size: 14px; line-height: 1.6; }
.message.user { align-items: flex-end; }
.message.user .message-body { padding: 11px 14px; border-radius: 10px 10px 2px 10px; background: var(--chat-raised); }
.message.assistant .message-label { color: var(--chat-cyan); }
.message.error .message-body { color: #ffd0c6; }
.message-note { color: var(--chat-muted); font-size: 12px; margin: 0; }
.retry { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; background: transparent; color: var(--chat-text); border: 1px solid var(--chat-line); border-radius: 7px; padding: 8px 12px; }
.retry:hover { background: var(--chat-raised); }
.retry svg { width: 16px; height: 16px; }
.fallback { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--chat-cyan); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.fallback svg { width: 16px; height: 16px; }
.pending { color: var(--chat-muted); font-size: 13px; display: flex; align-items: center; gap: 9px; margin-top: 19px; }
.pending-bars { display: flex; align-items: center; gap: 3px; height: 20px; }
.pending-bars i { display: block; width: 3px; height: 10px; background: var(--chat-cyan); animation: chat-wait 1200ms ease-in-out infinite; }
.pending-bars i:nth-child(2) { animation-delay: 120ms; height: 16px; }
.pending-bars i:nth-child(3) { animation-delay: 240ms; }
.new-message { position: sticky; bottom: 0; display: block; min-height: 44px; margin: 12px auto 0; padding: 9px 14px; border: 1px solid var(--chat-cyan); border-radius: 8px; color: var(--chat-text); background: #10272a; }
.composer { flex-shrink: 0; padding: 13px 16px 12px; border-top: 1px solid var(--chat-line); background: var(--chat-surface); }
.input-wrap { display: flex; align-items: flex-end; gap: 8px; background: #192123; border: 1px solid #526161; border-radius: 9px; padding: 5px; }
.input-wrap:focus-within { border-color: var(--chat-cyan); }
textarea { width: 100%; min-width: 0; display: block; resize: none; padding: 10px 8px; min-height: 44px; max-height: 112px; height: 44px; margin: 0; border: 0; border-radius: 4px; outline: none; background: transparent; color: var(--chat-text); font-size: 16px; line-height: 24px; overflow-y: auto; }
textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--chat-muted); opacity: 1; }
.send { display: grid; place-items: center; width: 44px; min-height: 44px; flex-shrink: 0; border: 0; border-radius: 6px; background: var(--chat-acid); color: var(--chat-ink); transition: opacity 150ms, background 150ms; }
.send:hover:not(:disabled) { background: #fff943; }
.send:disabled { opacity: .35; }
.composer-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 8px 1px 0; }
.disclaimer { color: var(--chat-muted); font-size: 10px; margin: 0; }
.count { font-size: 10px; color: var(--chat-muted); white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes chat-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes chat-wait { 0%,80%,100% { opacity: .35; } 40% { opacity: 1; } }
@media (max-width: 600px) {
  .launcher { right: max(16px, env(safe-area-inset-right)); min-height: 52px; padding: 0 18px; }
  .launcher[aria-expanded="true"] { visibility: hidden; }
  .panel { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); width: auto; bottom: auto; top: calc(var(--chat-vtop, 0px) + max(8px, env(safe-area-inset-top))); height: calc(var(--chat-vh, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)) - var(--chat-obstruction-bottom, 0px)); max-height: 740px; border-radius: 12px; }
  .header { padding: 13px 12px 13px 16px; }
  .human-route { padding: 12px 16px; min-height: 70px; }
  .thread { padding: 21px 16px 18px; }
  .composer { padding-bottom: 12px; }
}
.panel.compact .header { padding-top: 8px; padding-bottom: 8px; }
.panel.compact .human-route { min-height: 58px; padding-top: 8px; padding-bottom: 8px; }
.panel.compact .human-route small, .panel.compact .identity p { display: none; }
.panel.compact .composer { padding-top: 8px; padding-bottom: 8px; }
.panel.compact .thread { padding-top: 14px; }
@media (max-height: 500px) {
  .panel { top: calc(var(--chat-vtop, 0px) + 6px); bottom: auto; height: calc(var(--chat-vh, 100dvh) - 12px - var(--chat-obstruction-bottom, 0px)); }
  .header { padding-top: 8px; padding-bottom: 8px; }
  .human-route { min-height: 58px; padding-top: 8px; padding-bottom: 8px; }
  .human-route small, .identity p { display: none; }
  .composer { padding-top: 8px; padding-bottom: 8px; }
  .thread { padding-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .launcher, .send, .avatar, .panel, .input-wrap, .suggestion, .retry { border: 1px solid ButtonText; }
}
