:root {
  --zw-mascot-x: 18px;
  --zw-mascot-y: calc(100vh - 198px);
  --zw-mascot-w: 184px;
  --zw-mascot-h: 204px;
  --zw-mascot-blue: #2fb8ff;
  --zw-mascot-panel: #07111f;
  --zw-mascot-travel: 900ms;
}

.zw-ai-mascot {
  position: fixed;
  z-index: 38;
  left: var(--zw-mascot-x);
  top: var(--zw-mascot-y);
  width: var(--zw-mascot-w);
  height: var(--zw-mascot-h);
  pointer-events: none;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition: left var(--zw-mascot-travel) cubic-bezier(.22,.76,.2,1), top var(--zw-mascot-travel) cubic-bezier(.22,.76,.2,1), transform .45s ease, opacity .3s ease;
  contain: layout style;
  will-change: left, top;
}

.zw-ai-mascot[data-state="hidden"] {
  opacity: 0;
  transform: translate3d(-125%, 20%, 0) rotate(-8deg);
}

.zw-ai-mascot[data-placement="behind"] { z-index: 30; }

.zw-ai-mascot[data-placement="behind"][data-facing="left"] .zw-ai-mascot__character {
  clip-path: inset(0 62% 0 0);
}

.zw-ai-mascot[data-placement="behind"][data-facing="right"] .zw-ai-mascot__character {
  clip-path: inset(0 0 0 62%);
}

.zw-ai-mascot__character {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(102, 196, 255, .58);
  border-radius: 32px 32px 44px 44px;
  background: #f7f9fc;
  box-shadow: 0 15px 42px rgba(0, 0, 0, .34), 0 0 0 4px rgba(47, 184, 255, .09), 0 0 28px rgba(47, 184, 255, .22);
  cursor: pointer;
  pointer-events: auto;
  transform-origin: 50% 100%;
  transition: transform .22s ease, filter .22s ease;
  clip-path: inset(0);
}

.zw-ai-mascot__character:hover,
.zw-ai-mascot__character:focus-visible {
  transform: translateY(-5px) scale(1.025);
  outline: 2px solid var(--zw-mascot-blue);
  outline-offset: 3px;
}

.zw-ai-mascot[data-placement="perch"] .zw-ai-mascot__character,
.zw-ai-mascot[data-placement="behind"] .zw-ai-mascot__character {
  pointer-events: none;
}

.zw-ai-mascot__visual,
.zw-ai-mascot__sprite,
.zw-ai-mascot-restore > span {
  position: absolute;
  inset: 0;
  display: block;
}

.zw-ai-mascot__sprite,
.zw-ai-mascot-restore > span {
  background-image: url("/ai-mascot/zonabot-poses.webp");
  background-repeat: no-repeat;
  background-size: 300% 300%;
  background-position: 0 0;
}

.zw-ai-mascot__sprite {
  transform: scaleX(var(--zw-mascot-facing, 1));
  transition: transform .24s ease;
}

.zw-ai-mascot[data-pose="wave"] .zw-ai-mascot__sprite { background-position: 50% 0; }
.zw-ai-mascot[data-pose="point"] .zw-ai-mascot__sprite { background-position: 100% 0; }
.zw-ai-mascot[data-pose="walk"] .zw-ai-mascot__sprite { background-position: 0 50%; }
.zw-ai-mascot[data-pose="peek"] .zw-ai-mascot__sprite { background-position: 50% 50%; }
.zw-ai-mascot[data-pose="celebrate"] .zw-ai-mascot__sprite { background-position: 100% 50%; }
.zw-ai-mascot[data-pose="confident"] .zw-ai-mascot__sprite { background-position: 0 100%; }
.zw-ai-mascot[data-pose="think"] .zw-ai-mascot__sprite { background-position: 50% 100%; }
.zw-ai-mascot[data-pose="sit"] .zw-ai-mascot__sprite { background-position: 100% 100%; filter: saturate(.75); }

.zw-ai-mascot__visual canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.zw-ai-mascot[data-renderer="three"] .zw-ai-mascot__character {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 13px 10px rgba(0, 0, 0, .32));
}

.zw-ai-mascot[data-renderer="three"] .zw-ai-mascot__visual::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 28%;
  right: 28%;
  bottom: 5px;
  height: 10px;
  border-radius: 50%;
  background: rgba(24, 176, 255, .25);
  filter: blur(7px);
}

.zw-ai-mascot[data-renderer="three"] .zw-ai-mascot__online { display: none; }

.zw-ai-mascot__online {
  position: absolute;
  right: 11px;
  bottom: 10px;
  width: 10px;
  height: 10px;
  border: 2px solid #06101d;
  border-radius: 50%;
  background: #38e0aa;
  box-shadow: 0 0 12px rgba(56, 224, 170, .8);
}

.zw-ai-mascot__minimize,
.zw-ai-mascot__bubble-close {
  display: grid;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, .28);
  color: #e5f5ff;
  background: #07111f;
  cursor: pointer;
  pointer-events: auto;
}

.zw-ai-mascot__minimize {
  position: absolute;
  z-index: 4;
  top: 2px;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 19px;
  line-height: 1;
  opacity: .62;
}

.zw-ai-mascot:hover .zw-ai-mascot__minimize,
.zw-ai-mascot.has-message .zw-ai-mascot__minimize,
.zw-ai-mascot__minimize:focus-visible { opacity: 1; }

.zw-ai-mascot__minimize:hover,
.zw-ai-mascot__bubble-close:hover,
.zw-ai-mascot__minimize:focus-visible,
.zw-ai-mascot__bubble-close:focus-visible {
  color: white;
  border-color: var(--zw-mascot-blue);
  outline: 2px solid var(--zw-mascot-blue);
  outline-offset: 2px;
}

.zw-ai-mascot__bubble {
  position: absolute;
  z-index: 5;
  left: 72%;
  top: 18px;
  width: min(272px, calc(100vw - 40px));
  min-height: 62px;
  padding: 14px 42px 14px 16px;
  border: 1px solid rgba(87, 185, 255, .38);
  border-radius: 8px;
  color: #ecf8ff;
  background: rgba(5, 15, 29, .97);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .38), inset 3px 0 0 var(--zw-mascot-blue);
  font: 600 14px/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(10px) scale(.97);
  transform-origin: 0 30px;
  transition: opacity .25s ease, transform .28s ease;
}

.zw-ai-mascot[data-facing="right"] .zw-ai-mascot__bubble {
  right: 72%;
  left: auto;
  transform-origin: 100% 30px;
}

.zw-ai-mascot[data-placement="dock"] .zw-ai-mascot__bubble {
  top: auto;
  right: auto;
  bottom: 112%;
  left: 58%;
  transform-origin: 0 100%;
}

.zw-ai-mascot__bubble[aria-hidden="false"] {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.zw-ai-mascot__bubble-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  font-size: 18px;
}

.zw-ai-mascot-restore {
  position: fixed;
  z-index: 38;
  left: 14px;
  bottom: 14px;
  width: 48px;
  height: 48px;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(74, 190, 255, .6);
  border-radius: 50%;
  background: #f7f9fc;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 0 22px rgba(47, 184, 255, .25);
  cursor: pointer;
}

.zw-ai-mascot-restore > span {
  transform: scale(2.25) translateY(13%);
  transform-origin: 50% 24%;
}

.zw-ai-mascot-restore:focus-visible {
  outline: 2px solid var(--zw-mascot-blue);
  outline-offset: 3px;
}

.zw-ai-mascot[data-renderer="sprite"][data-state="entering"] .zw-ai-mascot__character { animation: zw-mascot-enter .8s cubic-bezier(.2,.9,.25,1.2) both; }
.zw-ai-mascot[data-renderer="sprite"][data-state="idle"] .zw-ai-mascot__character { animation: zw-mascot-idle 4.4s ease-in-out infinite; }
.zw-ai-mascot[data-renderer="sprite"][data-state="observing"] .zw-ai-mascot__character,
.zw-ai-mascot[data-renderer="sprite"][data-state="recommending"] .zw-ai-mascot__character { animation: zw-mascot-observe 1.8s ease-in-out infinite; }
.zw-ai-mascot[data-renderer="sprite"][data-state="celebrating"] .zw-ai-mascot__character { animation: zw-mascot-celebrate .48s ease-in-out 3; }

.zw-mascot-target-active {
  position: relative;
  isolation: isolate;
  outline: 2px solid rgba(47, 184, 255, .82) !important;
  outline-offset: 5px !important;
  box-shadow: 0 0 0 8px rgba(47, 184, 255, .1), 0 0 28px rgba(47, 184, 255, .24) !important;
  transition: outline-color .2s ease, box-shadow .2s ease !important;
}

.zw-mascot-layer-front {
  position: relative !important;
  z-index: 39 !important;
  isolation: isolate;
}

@keyframes zw-mascot-enter {
  0% { transform: translateX(-130%) rotate(-9deg) scale(.76); }
  72% { transform: translateX(7%) rotate(2deg) scale(1.03); }
  100% { transform: translateX(0) rotate(0) scale(1); }
}

@keyframes zw-mascot-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  45% { transform: translateY(-4px) rotate(-1deg); }
  58% { transform: translateY(-5px) rotate(1deg); }
}

@keyframes zw-mascot-observe {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

@keyframes zw-mascot-celebrate {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.03); }
}

@media (max-width: 720px) {
  :root {
    --zw-mascot-x: 8px;
    --zw-mascot-y: calc(100vh - 118px);
    --zw-mascot-w: 102px;
    --zw-mascot-h: 116px;
  }
  .zw-ai-mascot__character { border-radius: 24px 24px 30px 30px; }
  .zw-ai-mascot__bubble { top: auto; bottom: 82%; left: 2px; width: min(218px, calc(100vw - 24px)); padding: 12px 38px 12px 14px; font-size: 13px; transform-origin: 22px 100%; }
  .zw-ai-mascot[data-placement="dock"] .zw-ai-mascot__bubble { bottom: 92%; left: 2px; }
  .zw-ai-mascot[data-facing="right"] .zw-ai-mascot__bubble { right: 2px; left: auto; }
  .zw-ai-mascot__minimize { width: 25px; height: 25px; top: 0; right: -2px; }
  .zw-ai-mascot__online { right: 7px; bottom: 7px; }
  .zw-mascot-target-active { outline-offset: 3px !important; box-shadow: 0 0 0 5px rgba(47, 184, 255, .09) !important; }
}

@media (prefers-reduced-motion: reduce) {
  .zw-ai-mascot,
  .zw-ai-mascot__character,
  .zw-ai-mascot__bubble,
  .zw-mascot-target-active {
    animation: none !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .zw-ai-mascot,
  .zw-ai-mascot-restore { display: none !important; }
}
