.slh-avatar-widget,
.slh-avatar-widget * {
  box-sizing: border-box;
}

.slh-avatar-widget {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 86;
  width: min(214px, calc(100vw - 18px));
  pointer-events: none;
  font-family: var(--font-body, "IBM Plex Sans", system-ui, sans-serif);
}

.slh-avatar-shell {
  position: relative;
  min-height: 154px;
}

.slh-avatar-button {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 92px;
  height: 168px;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 18px 28px rgba(9, 34, 79, 0.18));
  transition: transform 0.18s ease, filter 0.18s ease;
}

.slh-avatar-button:hover,
.slh-avatar-button:focus-visible {
  transform: translateY(-2px);
  filter: drop-shadow(0 22px 34px rgba(9, 34, 79, 0.22));
  outline: none;
}

.slh-avatar-stage {
  position: absolute;
  inset: 0;
  animation: slhAvatarFloat 5.8s ease-in-out infinite;
}

.slh-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

.slh-avatar-figure {
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.slh-avatar-figure.is-static {
  opacity: 1;
  animation:slhAvatarRest 10s ease-in-out infinite;
}

.slh-avatar-figure.is-wave {
  opacity: 0;
  transform: translateY(2px) scale(0.99);
  animation:slhAvatarWave 10s ease-in-out infinite;
}

/* Two poses, with a quiet pause in each pose between transitions. */
@keyframes slhAvatarRest { 0%,52%,100% { opacity:1; } 58%,88% { opacity:0; } }
@keyframes slhAvatarWave { 0%,52%,100% { opacity:0; transform:translateY(2px) scale(.99); } 58%,88% { opacity:1; transform:translateY(0) scale(1.01); } }

.slh-avatar-bubble {
  position: absolute;
  right: 54px;
  bottom: 96px;
  width: min(224px, calc(100vw - 30px));
  padding: 13px 13px 11px;
  border-radius: 20px;
  border: 1px solid rgba(15, 74, 166, 0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(246,250,255,0.96));
  box-shadow: 0 18px 42px rgba(9, 34, 79, 0.14);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.slh-avatar-bubble::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: rgba(247, 250, 255, 0.98);
  border-right: 1px solid rgba(15, 74, 166, 0.14);
  border-bottom: 1px solid rgba(15, 74, 166, 0.14);
  transform: rotate(45deg);
}

.slh-avatar-widget.is-open .slh-avatar-bubble {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.slh-avatar-bubble-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.slh-avatar-bubble-copy {
  display: grid;
  gap: 4px;
}

.slh-avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f4aa6, #2cb36a);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 20px rgba(15, 74, 166, 0.2);
}

.slh-avatar-title {
  margin: 0;
  font-family: var(--font-display, "Archivo", sans-serif);
  font-size: 0.96rem;
  line-height: 1.14;
  letter-spacing: -0.02em;
  color: var(--text, #13253f);
}

.slh-avatar-subtitle {
  margin: 0;
  color: var(--text-muted, #7f8fa5);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.slh-avatar-close {
  border: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(15, 74, 166, 0.07);
  color: var(--text, #13253f);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
}

.slh-avatar-message {
  margin: 0 0 10px;
  color: var(--text-soft, #59708d);
  font-size: 0.84rem;
  line-height: 1.5;
}

.slh-avatar-hints {
  display: grid;
  gap: 7px;
}

.slh-avatar-hint {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(15, 74, 166, 0.05);
  color: var(--text-soft, #59708d);
  font-size: 0.8rem;
  line-height: 1.4;
}

.slh-avatar-hint-dot {
  width: 18px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 74, 166, 0.12);
  color: #0f4aa6;
  font-size: 0.72rem;
  font-weight: 800;
}

.slh-avatar-status {
  position: absolute;
  right: 10px;
  bottom: 18px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #35d46a;
  box-shadow: 0 0 0 4px rgba(53, 212, 106, 0.18), 0 0 0 1px #fff inset;
}

@keyframes slhAvatarFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@media (max-width: 960px) {
  .slh-avatar-widget {
    width: min(198px, calc(100vw - 16px));
    right: 6px;
    bottom: 6px;
  }

  .slh-avatar-shell {
    min-height: 140px;
  }

  .slh-avatar-button {
    width: 82px;
    height: 148px;
  }

  .slh-avatar-bubble {
    right: 42px;
    bottom: 88px;
    width: min(204px, calc(100vw - 24px));
  }
}

@media (max-width: 640px) {
  .slh-avatar-widget {
    width: min(178px, calc(100vw - 14px));
    right: 4px;
    bottom: 4px;
  }

  .slh-avatar-button {
    width: 68px;
    height: 122px;
  }

  .slh-avatar-shell {
    min-height: 114px;
  }

  .slh-avatar-bubble {
    right: 4px;
    bottom: 102px;
    width: min(180px, calc(100vw - 12px));
    border-radius: 18px;
    padding: 11px 11px 10px;
  }

  .slh-avatar-bubble::after {
    display: none;
  }

  .slh-avatar-title {
    font-size: 0.9rem;
  }

  .slh-avatar-message,
  .slh-avatar-hint {
    font-size: 0.76rem;
  }
}

@media (max-width: 480px) {
  .slh-avatar-widget {
    width: min(160px, calc(100vw - 12px));
  }

  .slh-avatar-button {
    width: 58px;
    height: 104px;
  }

  .slh-avatar-shell {
    min-height: 102px;
  }

  .slh-avatar-bubble {
    bottom: 92px;
    width: min(168px, calc(100vw - 10px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .slh-avatar-figure { animation:none!important; }
  .slh-avatar-stage {
    animation: none !important;
  }

  .slh-avatar-widget,
  .slh-avatar-button,
  .slh-avatar-bubble {
    transition: none !important;
  }
}
