.paipai-pet {
  --pet-coral: #ff6658;
  --pet-navy: #10213e;
  --pet-line: #eadfd5;
  position: fixed;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 120;
  width: 112px;
  height: 128px;
  pointer-events: none;
  filter: drop-shadow(0 16px 25px rgba(66, 43, 27, .18));
}

.paipai-pet-avatar {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 104px;
  height: 118px;
  padding: 0;
  pointer-events: auto;
  cursor: pointer;
  background: transparent;
  border: 0;
  transition: transform .2s ease;
  animation: paipai-pet-float 2.7s ease-in-out infinite alternate;
}
.paipai-pet-avatar:hover { transform: translateY(-4px) scale(1.03); }
.paipai-pet-avatar img { width: 100%; height: 100%; object-fit: contain; }
.paipai-pet-avatar::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 5px;
  left: 15px;
  height: 13px;
  z-index: -1;
  background: rgba(45, 36, 26, .16);
  border-radius: 50%;
  filter: blur(6px);
}

.paipai-pet-notice {
  position: absolute;
  top: 5px;
  right: 4px;
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--pet-coral);
  border: 3px solid #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
}
.paipai-pet-notice[hidden] { display: none; }

.paipai-pet-dialog {
  position: absolute;
  right: 78px;
  bottom: 78px;
  width: min(310px, calc(100vw - 142px));
  display: grid;
  gap: 7px;
  padding: 17px 18px 16px;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  background: rgba(255, 254, 251, .98);
  border: 1px solid var(--pet-line);
  border-radius: 22px 22px 6px 22px;
  box-shadow: 0 18px 48px rgba(68, 46, 30, .16);
  transform: translate(10px, 8px) scale(.96);
  transform-origin: right bottom;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.paipai-pet-dialog::after {
  content: "";
  position: absolute;
  right: -9px;
  bottom: 17px;
  width: 17px;
  height: 17px;
  background: #fffefb;
  border-top: 1px solid var(--pet-line);
  border-right: 1px solid var(--pet-line);
  transform: rotate(45deg);
}
.paipai-pet.is-open .paipai-pet-dialog { opacity: 1; visibility: visible; transform: none; }
.paipai-pet-kicker { color: #b96f15; font-size: 11px; font-weight: 900; letter-spacing: .07em; }
.paipai-pet-title { padding-right: 22px; color: var(--pet-navy); font: 800 16px/1.35 Georgia, "Songti SC", serif; }
.paipai-pet-copy { margin: 0; color: #596574; font-size: 13px; line-height: 1.6; }
.paipai-pet-action {
  width: max-content;
  min-height: 40px;
  margin-top: 2px;
  padding: 0 14px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #ff7163, #ff5548);
  border: 0;
  border-radius: 11px;
  box-shadow: 0 8px 18px rgba(255, 92, 78, .22);
  font-size: 12px;
  font-weight: 900;
}
.paipai-pet-action[hidden] { display: none; }
.paipai-pet-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
.paipai-pet-consult {
  min-height: 40px;
  padding: 0 13px;
  color: var(--pet-navy);
  cursor: pointer;
  background: #fff6df;
  border: 1px solid #f0dcae;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 900;
}
.paipai-pet-close {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #9a928b;
  cursor: pointer;
  background: #f5f0eb;
  border: 0;
  border-radius: 50%;
  font-size: 15px;
}

.paipai-pet-sparkles i { position: absolute; width: 6px; height: 6px; background: #ffb51f; transform: rotate(45deg); animation: paipai-sparkle 1.8s ease-in-out infinite; }
.paipai-pet-sparkles i:nth-child(1) { top: 8px; left: 7px; }
.paipai-pet-sparkles i:nth-child(2) { top: 28px; left: -1px; width: 4px; height: 4px; animation-delay: .45s; }
.paipai-pet-sparkles i:nth-child(3) { top: 2px; left: 31px; width: 4px; height: 4px; animation-delay: .8s; }
.paipai-pet.is-nudging .paipai-pet-dialog { animation: paipai-dialog-nudge .38s ease both; }

.paipai-consultant {
  position: absolute;
  right: 78px;
  bottom: 78px;
  width: min(410px, calc(100vw - 150px));
  max-height: min(600px, calc(100vh - 38px));
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto auto auto;
  gap: 12px;
  padding: 19px;
  overflow: hidden;
  pointer-events: auto;
  background: rgba(255,254,251,.99);
  border: 1px solid var(--pet-line);
  border-radius: 24px 24px 7px 24px;
  box-shadow: 0 24px 70px rgba(50,36,25,.22);
}
.paipai-consultant[hidden] { display: none; }
.paipai-pet.is-consulting .paipai-pet-dialog { opacity: 0; visibility: hidden; pointer-events: none; }
.paipai-consultant > header { display: flex; align-items: start; justify-content: space-between; gap: 15px; padding-bottom: 12px; border-bottom: 1px solid #eee5dc; }
.paipai-consultant > header > div { display: grid; gap: 3px; }
.paipai-consultant > header span { color: #b96f15; font-size: 10px; font-weight: 900; letter-spacing: .09em; }
.paipai-consultant > header strong { color: var(--pet-navy); font: 800 18px/1.25 Georgia, "Songti SC", serif; }
.paipai-consultant > header small { color: #737c87; font-size: 11px; }
.paipai-consultant-close { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; color: #8c8b8a; cursor: pointer; background: #f5f0eb; border: 0; border-radius: 50%; font-size: 16px; }
.paipai-chat-messages { min-height: 150px; max-height: 230px; display: grid; align-content: start; gap: 8px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.paipai-chat-message { width: fit-content; max-width: 88%; padding: 10px 12px; border-radius: 14px; font-size: 12px; line-height: 1.65; white-space: pre-line; }
.paipai-chat-message.assistant { justify-self: start; color: #53606f; background: #fff6e4; border: 1px solid #f0dfba; border-bottom-left-radius: 4px; }
.paipai-chat-message.user { justify-self: end; color: #fff; background: linear-gradient(135deg, #ff7567, #ff594c); border-bottom-right-radius: 4px; }
.paipai-chat-quick { display: flex; flex-wrap: wrap; gap: 6px; scrollbar-width: none; }
.paipai-chat-quick::-webkit-scrollbar { display: none; }
.paipai-chat-quick button { min-height: 34px; padding: 0 10px; color: #515d6c; cursor: pointer; background: #fff; border: 1px solid #e9dfd6; border-radius: 999px; font-size: 11px; font-weight: 800; }
.paipai-chat-quick button:hover { color: var(--pet-coral); border-color: #ffc2b9; }
.paipai-chat-form { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.paipai-chat-form input { width: 100%; min-width: 0; min-height: 40px; padding: 0 12px; color: var(--pet-navy); background: #fff; border: 1px solid #e5dbd2; border-radius: 11px; font-size: 12px; outline: none; }
.paipai-chat-form input:focus { border-color: #ffa99e; box-shadow: 0 0 0 3px rgba(255,102,88,.1); }
.paipai-chat-form button { min-width: 58px; color: #fff; cursor: pointer; background: var(--pet-navy); border: 0; border-radius: 11px; font-size: 12px; font-weight: 900; }
.paipai-course-link { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 13px; color: #fff; background: linear-gradient(135deg, #ff7163, #ff5548); border-radius: 12px; box-shadow: 0 9px 20px rgba(255,92,78,.2); font-size: 12px; font-weight: 900; }
.paipai-course-link[hidden] { display: none; }
.paipai-course-link span { font: 800 19px/1 Georgia, serif; }
.paipai-course-link.is-highlighted { animation: paipai-course-highlight 1.15s ease 2; }
.paipai-consultant-note { margin: -4px 0 0; color: #747d88; font-size: 10px; line-height: 1.45; text-align: center; }
.paipai-contact-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; background: rgba(16,33,62,.5); backdrop-filter: blur(5px); }
.paipai-contact-overlay[hidden] { display: none; }
.paipai-contact-overlay > section { position: relative; width: min(310px, 100%); display: grid; justify-items: center; gap: 8px; padding: 22px; background: #fffefb; border-radius: 20px; box-shadow: 0 20px 55px rgba(16,33,62,.22); text-align: center; }
.paipai-contact-overlay span { color: #b96f15; font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.paipai-contact-overlay strong { color: var(--pet-navy); font: 800 18px/1.3 Georgia, "Songti SC", serif; }
.paipai-contact-overlay img { width: min(220px, 78%); aspect-ratio: 1; object-fit: cover; margin-top: 3px; padding: 7px; background: #fff; border: 1px solid #e9dfd6; border-radius: 14px; }
.paipai-contact-overlay p { margin: 1px 0 0; color: #626d7a; font-size: 12px; line-height: 1.55; }
.paipai-contact-close { position: absolute; top: 10px; right: 10px; width: 27px; height: 27px; display: grid; place-items: center; padding: 0; color: #8c8b8a; cursor: pointer; background: #f5f0eb; border: 0; border-radius: 50%; font-size: 16px; }

@keyframes paipai-pet-float { to { translate: 0 -7px; rotate: 1deg; } }
@keyframes paipai-sparkle { 0%, 100% { opacity: .28; scale: .72; } 50% { opacity: 1; scale: 1.18; } }
@keyframes paipai-dialog-nudge { 0% { translate: 8px 4px; } 60% { translate: -2px -1px; } 100% { translate: 0; } }
@keyframes paipai-course-highlight { 0%, 100% { transform: scale(1); box-shadow: 0 9px 20px rgba(255,92,78,.2); } 50% { transform: scale(1.025); box-shadow: 0 0 0 6px rgba(255,102,88,.16), 0 12px 25px rgba(255,92,78,.28); } }

@media (max-width: 820px) {
  .paipai-pet {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: 80px;
    height: 92px;
  }
  .paipai-pet-avatar { width: 76px; height: 88px; }
  .paipai-pet-dialog {
    right: 54px;
    bottom: 58px;
    width: min(270px, calc(100vw - 78px));
    gap: 5px;
    padding: 14px 15px 13px;
    border-radius: 18px 18px 5px 18px;
  }
  .paipai-pet-title { font-size: 14px; }
  .paipai-pet-title { padding-right: 38px; }
  .paipai-pet-copy { font-size: 12px; line-height: 1.55; }
  .paipai-pet-action, .paipai-pet-consult { min-height: 44px; padding-inline: 13px; }
  .paipai-pet-close, .paipai-consultant-close, .paipai-contact-close { width: 44px; height: 44px; font-size: 20px; }
  .paipai-pet-close { top: 5px; right: 5px; }
  .paipai-pet-notice { top: 0; right: 0; }
  .paipai-pet[data-context="shadow"][data-stage="active"] {
    bottom: calc(220px + env(safe-area-inset-bottom));
  }
  .paipai-pet.is-consulting { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .paipai-consultant {
    right: 0;
    bottom: 84px;
    width: calc(100vw - 24px);
    max-height: min(64vh, 560px);
    gap: 9px;
    padding: 16px;
    border-radius: 21px 21px 6px 21px;
  }
  .paipai-chat-messages { min-height: 120px; max-height: 190px; }
  .paipai-chat-quick { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
  .paipai-chat-quick button { min-height: 44px; flex: 0 0 auto; }
  .paipai-chat-form input, .paipai-chat-form button, .paipai-course-link { min-height: 44px; }
  .paipai-contact-overlay { padding: 14px; }
  .paipai-contact-overlay > section { padding: 19px 16px 17px; }
  .paipai-contact-overlay img { width: min(205px, 72%); }
}

@media (prefers-reduced-motion: reduce) {
  .paipai-pet-avatar, .paipai-pet-sparkles i, .paipai-pet.is-nudging .paipai-pet-dialog { animation: none !important; }
}
