@keyframes leo-bob   { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes leo-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes leo-mane  { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes leo-tilt  { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@keyframes leo-jaw   { to { transform: scaleY(1.5); } }
@keyframes leo-wave  {
  0%, 55%, 100% { transform: rotate(0deg); }
  62% { transform: rotate(-16deg); }
  70% { transform: rotate(10deg); }
  78% { transform: rotate(-12deg); }
  86% { transform: rotate(6deg); }
}
@keyframes leo-pop {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.leo { display: block; width: 100%; height: auto; overflow: visible; }

.leo .leo-bob { animation: leo-bob 3.2s ease-in-out infinite; }

.leo .leo-head { transform-box: fill-box; transform-origin: 50% 90%; animation: leo-tilt 6s ease-in-out infinite; }

.leo .leo-mane { transform-box: fill-box; transform-origin: center; animation: leo-mane 6s ease-in-out infinite; }

.leo .leo-eyes { transform-box: fill-box; transform-origin: center; animation: leo-blink 4.6s infinite; }

.leo .leo-arm-r { transform-origin: 170px 196px; animation: leo-wave 4s ease-in-out infinite; }

.leo .leo-mouth { transform-box: fill-box; transform-origin: center top; }
.leo.is-talking .leo-mouth { animation: leo-jaw .2s ease-in-out infinite alternate; }

.leo-launch {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.leo-btn,
.leo-nudge { pointer-events: auto; }

.leo-btn {
  position: relative;
  flex: none;
  width: 78px;
  height: 78px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  background: #0A0F25;
  box-shadow: 0 14px 32px -8px rgba(10, 15, 37, .5);
  cursor: pointer;
}
.leo-btn:hover { transform: scale(1.07); }

.leo-btn__art {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
}

.leo-btn__art img,
.leo-avatar img,
.leo-welcome__art img { display: block; width: 100%; height: 100%; }

.leo-dot {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FE00FD;
  border: 2px solid #FFFFFF;
}

.leo-nudge {
  max-width: 230px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 18px 18px 6px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
  animation: leo-pop .5s ease 1.2s both;
}

.leo-panel {
  position: fixed;
  right: 24px;
  bottom: 118px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: 384px;
  height: min(600px, calc(100vh - 142px));
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px -20px rgba(10, 15, 37, .45);
  overflow: hidden;
  transform-origin: bottom right;
  animation: leo-pop .35s cubic-bezier(.2, .7, .2, 1) both;
}
.leo-panel:focus { outline: none; }

.leo-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: #0A0F25;
  color: #FFFFFF;
}

.leo-avatar {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1A2350;
  border: 2px solid #3EDFCF;
  overflow: hidden;
}

.leo-header__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.leo-header__name {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
}

.leo-header__sub { font-size: 12.5px; color: #C4C9DB; }

.leo-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #2C3768;
  background: transparent;
  color: #FFFFFF;
  cursor: pointer;
}
.leo-close:hover { background: #1A2350; }
.leo-close:focus-visible { outline-color: #3EDFCF; }

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg);
}

.leo-welcome {
  display: flex;
  justify-content: center;
  padding: 4px 0 6px;
}

.leo-welcome__circle {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: #1A2350;
  border: 2px solid #3EDFCF;
  overflow: hidden;
}
.leo-welcome__art { width: 104px; aspect-ratio: 230 / 250; }

.msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-line;
  animation: leo-pop .3s ease both;
}

.msg-leo {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.msg-user {
  align-self: flex-end;
  background: var(--btn-bg);
  color: var(--btn-text);
  border-bottom-right-radius: 6px;
}

.typing {
  display: inline-flex;
  gap: 5px;
  align-self: flex-start;
  padding: 14px 16px;
  border-radius: 18px 18px 18px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.typing span[aria-hidden] {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: leo-bob .9s ease-in-out infinite;
}
.typing span[aria-hidden]:nth-child(2) { animation-delay: .15s; }
.typing span[aria-hidden]:nth-child(3) { animation-delay: .3s; }

.leo-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.qchips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 40%;
  overflow-y: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.qchips__title {
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
}

.qchips__list { display: contents; }

.qchip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.qchip:hover { border-color: var(--accent); color: var(--accent); }
.qchip[aria-disabled="true"] { cursor: wait; }

.leo-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  background: var(--surface);
}

.leo-action {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.leo-action--primary,
.leo-action--primary:hover { background: var(--btn-bg); color: var(--btn-text); }

.leo-action--ghost,
.leo-action--ghost:hover { border: 1px solid var(--ghost-border); color: var(--text); }

.leo-note {
  margin: 0;
  padding: 0 16px 14px;
  background: var(--surface);
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 600px) {
  .leo-launch { right: 16px; bottom: 16px; }
  .leo-nudge { display: none; }
  .leo-btn { width: 66px; height: 66px; }

  .leo-panel {
    left: 10px;
    right: 10px;
    bottom: 94px;
    width: auto;
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .leo *,
  .leo-launch *,
  .leo-panel,
  .leo-panel * {
    animation: none !important;
    transition: none !important;
  }
  .leo-btn:hover { transform: none; }
}
