﻿/* 杏林平台 · 桌面宠物（dsh-pet 素材移植，MIT）
   默认只在 ≥1024px 的电脑/大平板显示；手机与竖屏平板自动隐藏。 */

#msPetLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  contain: layout style;
}
#msPetLayer[hidden] { display: none; }

.msPet {
  position: fixed;
  width: 230px;
  height: 230px;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 10px 18px rgba(16, 27, 42, .18));
  transition: filter .2s ease;
}
.msPet:hover { filter: drop-shadow(0 16px 30px rgba(16, 27, 42, .28)); }
.msPet.dragging .msPetHit { cursor: grabbing; } .msPet.dragging { filter: drop-shadow(0 18px 30px rgba(16, 27, 42, .28)); }
.msPetStage { position: absolute; inset: 0; pointer-events: none; }
.msPetHit { position: absolute; left: 16%; right: 16%; top: 8%; bottom: 2%; pointer-events: auto; cursor: grab; }
.msPet video,
.msPet img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  background: transparent;
}
.msPet video { opacity: 0; transition: opacity .18s linear; }
.msPet video.on { opacity: 1; }

/* 气泡 */
.msPetBubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 18px);
  transform: translateX(-50%) translateY(6px);
  max-width: 240px;
  padding: 9px 12px;
  background: #fff;
  color: #243247;
  border: 1px solid #dcd7cc;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(16, 27, 42, .12);
  font: 13px/1.55 "Microsoft YaHei", system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: pre-wrap;
  word-break: break-word;
}
.msPetBubble.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.msPetBubble, .msPetMini { pointer-events: auto; }
.msPetBubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px; height: 10px;
  margin-left: -5px;
  background: #fff;
  border-right: 1px solid #dcd7cc;
  border-bottom: 1px solid #dcd7cc;
  transform: rotate(45deg);
}

/* 关闭/折叠小按钮 */
.msPetMini {
  position: absolute;
  top: 2px; right: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid #dcd7cc;
  background: #fff;
  color: #6e7c8a;
  font-size: 12px; line-height: 20px; text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: auto;
}
.msPet:hover .msPetMini { opacity: 1; }

/* 对话面板 */
.msPetPanel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 348px;
  max-height: min(64vh, 520px);
  display: none;
  flex-direction: column;
  background: #fff;
  border: 1px solid #dcd7cc;
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(16, 27, 42, .2);
  overflow: hidden;
  pointer-events: auto;
  font-family: "Microsoft YaHei", system-ui, sans-serif;
}
.msPetPanel { pointer-events: auto; }
.msPetPanel.on { display: flex; }
.msPetPanelHead {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #f6fbfa, #fff);
  border-bottom: 1px solid #eef1ee;
}
.msPetPanelHead img { position: static; inset: auto; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 50%; background: #e6f3ef; }
.msPetPanelHead > div { display: flex; flex-direction: column; line-height: 1.25; }
.msPetPanelHead b { font-size: 13.5px; color: #101b2a; }
.msPetPanelHead span { font-size: 11px; color: #6e7c8a; }
.msPetPanelHead .msPetSpacer { flex: 1; }
.msPetPanelHead button {
  border: none; background: transparent; cursor: pointer;
  color: #6e7c8a; font-size: 15px; padding: 2px 4px; border-radius: 8px;
}
.msPetPanelHead button:hover { background: #f1f4f2; color: #0e7c6b; }
.msPetMsgs {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 9px;
  background: #fbfbf9;
}
.msPetMsg {
  max-width: 86%;
  padding: 8px 11px;
  border-radius: 13px;
  font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.msPetMsg.bot { align-self: flex-start; background: #fff; border: 1px solid #e7e3d9; color: #243247; border-bottom-left-radius: 5px; }
.msPetMsg.me { align-self: flex-end; background: #0e7c6b; color: #fff; border-bottom-right-radius: 5px; }
.msPetMsg.tip { align-self: center; background: transparent; color: #9aa6b2; font-size: 11.5px; padding: 2px; }
.msPetTyping { display: inline-flex; gap: 3px; align-items: center; }
.msPetTyping i { width: 5px; height: 5px; border-radius: 50%; background: #9fb1c4; animation: msPetDot 1s infinite ease-in-out; }
.msPetTyping i:nth-child(2) { animation-delay: .15s; }
.msPetTyping i:nth-child(3) { animation-delay: .3s; }
@keyframes msPetDot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.msPetChips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; background: #fbfbf9; }
.msPetChips button {
  border: 1px solid #dfe6e2; background: #fff; color: #2a3648;
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; cursor: pointer;
}
.msPetChips button:hover { border-color: #0e7c6b; color: #0e7c6b; }
.msPetInputRow { display: flex; gap: 7px; padding: 10px 12px; background: #fff; border-top: 1px solid #eef1ee; }
.msPetInputRow input {
  flex: 1; min-width: 0; border: 1px solid #dfe6e2; border-radius: 11px;
  padding: 8px 10px; font-size: 13px; color: #243247; outline: none;
  font-family: inherit;
}
.msPetInputRow input:focus { border-color: #0e7c6b; box-shadow: 0 0 0 3px rgba(14, 124, 107, .1); }
.msPetInputRow button {
  border: none; border-radius: 11px; padding: 0 14px; cursor: pointer;
  background: #0e7c6b; color: #fff; font-size: 13px; font-weight: 700;
}
.msPetInputRow button:disabled { background: #b9c7d4; cursor: default; }

/* 拖动时禁用视频过渡闪烁 */
.msPet.reduce video { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .msPet video { transition: none; }
  .msPetBubble { transition: none; }
}
/* Safari 不支持 VP9 透明通道：降级为静态形象徽标，避免黑底方块 */
.msPet.poster .msPetStage video { display: none !important; }
.msPet.poster .msPetStage .msPetPoster {
  position: absolute; inset: 0; display: block !important; opacity: 1 !important;
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(16, 27, 42, .18));
}

/* 右键动作菜单 */
.msPetMenu {
  position: fixed;
  z-index: 1200;
  width: 340px;
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #dcd7cc;
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(16, 27, 42, .22);
  overflow: hidden;
  font-family: "Microsoft YaHei", system-ui, sans-serif;
}
.msPetMenuHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-bottom: 1px solid #eef1ee;
  background: linear-gradient(180deg, #f6fbfa, #fff);
}
.msPetMenuHead b { font-size: 12.5px; color: #101b2a; }
.msPetMenuHead button { border: 0; background: transparent; color: #6e7c8a; cursor: pointer; font-size: 14px; }
.msPetMenuBody { overflow-y: auto; padding: 8px 10px 12px; }
.msPetMenuRandom {
  width: 100%; border: 1px dashed #cfe3dd; background: #f4faf7; color: #0e7c6b;
  border-radius: 9px; padding: 7px 10px; font-size: 12.5px; cursor: pointer; margin: 2px 0 8px;
}
.msPetMenuRandom:hover { background: #e6f3ef; }
.msPetMenuSec { margin-bottom: 8px; }
.msPetMenuSec > span { display: block; font-size: 11px; color: #9aa6b2; margin: 6px 2px 4px; }
.msPetMenuGrid { display: flex; flex-wrap: wrap; gap: 5px; }
.msPetMenuGrid button {
  border: 1px solid #e3e9e5; background: #fff; color: #2a3648;
  border-radius: 7px; padding: 4px 8px; font-size: 11px; cursor: pointer;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msPetMenuGrid button:hover { border-color: #0e7c6b; color: #0e7c6b; background: #f4faf7; }

/* 大小调节 */
.msPetMenuSizes { display: flex; gap: 6px; padding: 0 10px 8px; }
.msPetMenuSizes button {
  flex: 1; border: 1px solid #e3e9e5; background: #fff; color: #2a3648;
  border-radius: 8px; padding: 6px 4px; font-size: 11.5px; cursor: pointer;
}
.msPetMenuSizes button.on { border-color: #0e7c6b; color: #0e7c6b; background: #f4faf7; font-weight: 700; }
.msPetMenuSizes button:hover { border-color: #0e7c6b; }

