/* ===== Live2D 派蒙桌宠 ===== */
.l2d-pet{
  position:fixed;
  right:16px;
  bottom:96px;
  width:220px;
  height:300px;
  z-index:5000;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
  cursor:grab;
}
.l2d-pet.dragging{cursor:grabbing;transition:none!important;}
.l2d-pet.hidden{display:none;}

.l2d-pet-stage{
  position:absolute;
  inset:0;
  overflow:visible;
  transform-origin:50% 100%;
  will-change:transform;
}
.l2d-pet-stage canvas{
  width:100%;
  height:100%;
  display:block;
  filter:drop-shadow(0 8px 18px rgba(160,120,30,.28));
  animation:l2dBob 4.2s ease-in-out infinite;
}
.l2d-pet.moving .l2d-pet-stage canvas{animation:none;}
@keyframes l2dBob{0%,100%{transform:translateY(0);}50%{transform:translateY(-4px);}}
.l2d-pet-glow{
  position:absolute;
  left:50%;
  bottom:2%;
  width:66%;
  height:20%;
  transform:translateX(-50%);
  background:radial-gradient(ellipse at center,rgba(230,184,74,.32),rgba(230,184,74,0) 70%);
  filter:blur(7px);
  pointer-events:none;
  z-index:-1;
}

/* 加载 / 失败回退 */
.l2d-pet-loading{
  position:absolute;
  left:50%;
  bottom:34%;
  transform:translateX(-50%);
  padding:5px 12px;
  border-radius:999px;
  background:rgba(255,255,255,.86);
  border:1px solid rgba(230,184,74,.55);
  color:#8a6500;
  font-size:12px;
  white-space:nowrap;
  box-shadow:0 2px 8px rgba(0,0,0,.08);
  pointer-events:none;
  transition:opacity .3s;
}
.l2d-pet-loading.gone{opacity:0;}
.l2d-pet-fallback{
  position:absolute;
  inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  padding-bottom:6px;
}
.l2d-pet-fallback img{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  animation:l2dFloat 3.2s ease-in-out infinite;
  filter:drop-shadow(0 7px 14px rgba(160,120,30,.35));
}
@keyframes l2dFloat{0%,100%{transform:translateY(0);}50%{transform:translateY(-7px);}}

/* 话气泡 */
.l2d-pet-bubble{
  position:absolute;
  left:50%;
  bottom:calc(100% - 26px);
  transform:translate(-50%,6px);
  max-width:240px;
  padding:9px 12px;
  border-radius:13px;
  border:1px solid rgba(230,184,74,.65);
  background:linear-gradient(160deg,#fffdf6,#fff4d9);
  color:#6b4e00;
  font-size:13px;
  line-height:1.55;
  box-shadow:0 6px 18px rgba(150,110,20,.18);
  opacity:0;
  pointer-events:none;
  transition:opacity .22s,transform .22s;
  z-index:3;
  word-break:break-word;
}
.l2d-pet-bubble::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:-7px;
  width:12px;
  height:12px;
  transform:translateX(-50%) rotate(45deg);
  background:#fff8e6;
  border-right:1px solid rgba(230,184,74,.65);
  border-bottom:1px solid rgba(230,184,74,.65);
}
.l2d-pet-bubble.show{opacity:1;transform:translate(-50%,0);}
.l2d-pet-bubble .l2d-pet-link{
  display:inline-block;
  margin-top:6px;
  padding:3px 10px;
  border-radius:999px;
  background:linear-gradient(135deg,#1668dc,#0f4fa8);
  color:#fff;
  font-size:12px;
  cursor:pointer;
  pointer-events:auto;
  text-decoration:none;
}
.l2d-pet-bubble .l2d-pet-link:hover{filter:brightness(1.08);}

/* 悬浮操作条 */
.l2d-pet-bar{
  position:absolute;
  left:2px;
  right:auto;
  bottom:6px;
  display:flex;
  flex-direction:column;
  gap:6px;
  opacity:0;
  transform:translateX(6px);
  transition:.2s;
  z-index:4;
}
.l2d-pet:hover .l2d-pet-bar,
.l2d-pet.bar-open .l2d-pet-bar{opacity:1;transform:translateX(0);}
.l2d-pet-btn{
  width:32px;
  height:32px;
  border-radius:50%;
  border:1px solid rgba(230,184,74,.75);
  background:rgba(255,255,255,.93);
  color:#8a6500;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:0 3px 10px rgba(150,110,20,.16);
  padding:0;
  transition:.18s;
}
.l2d-pet-btn:hover{background:#fff8e6;transform:scale(1.06);}
.l2d-pet-btn svg{width:16px;height:16px;display:block;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.l2d-pet-btn.on{background:linear-gradient(135deg,#ffe9b3,#ffd77a);color:#7a5a00;}
.l2d-pet-btn.off{opacity:.6;}

/* 深色模式 */
html[data-theme="dark"] .l2d-pet-bubble{
  background:linear-gradient(160deg,#2a2416,#332a15);
  border-color:rgba(230,184,74,.45);
  color:#f3d99a;
  box-shadow:0 6px 18px rgba(0,0,0,.45);
}
html[data-theme="dark"] .l2d-pet-bubble::after{background:#302713;border-color:rgba(230,184,74,.45);}
html[data-theme="dark"] .l2d-pet-btn{background:rgba(38,33,22,.92);color:#f0cd77;border-color:rgba(230,184,74,.45);}
html[data-theme="dark"] .l2d-pet-loading{background:rgba(38,33,22,.9);color:#f0cd77;border-color:rgba(230,184,74,.45);}

@media (hover:none){
  .l2d-pet-bar{opacity:1;transform:none;}
}
@media (max-width:1000px){
  .l2d-pet{width:104px!important;height:138px!important;right:6px!important;bottom:84px!important;}
  .l2d-pet-bubble{max-width:170px;font-size:12px;}
}
@media (max-width:600px){
  .l2d-pet{width:86px!important;height:114px!important;right:4px!important;bottom:82px!important;}
  .l2d-pet-bubble{max-width:150px;font-size:12px;}
}
@media (prefers-reduced-motion:reduce){
  .l2d-pet-fallback img{animation:none;}
  .l2d-pet-stage canvas{animation:none;}
  .l2d-pet-stage{transition:none;}
}
