/* 软萌小熊 — 骨骼分层动画 */
#pet-root {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  inset: 0;
}
#pet-root .pet-wrap {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  width: 140px;
  height: 180px;
}
#pet-root .pet-wrap:active { cursor: grabbing; }

#pet-root .pet-stage {
  position: relative;
  width: 140px;
  height: 180px;
  overflow: visible;
}

#pet-root .pet-glb-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#pet-root .pet-glb-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
}

.bear-home-bear-slot .pet-glb-canvas,
.bear-home-bear-slot .pet-glb-canvas canvas {
  width: 100%;
  height: 100%;
}

/* 动态投影 */
#pet-root .pet-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 72px;
  height: 14px;
  margin-left: -36px;
  background: radial-gradient(ellipse, rgba(60,40,20,0.28) 0%, transparent 72%);
  border-radius: 50%;
  pointer-events: none;
  transform-origin: center;
  will-change: transform, filter, opacity;
}

/* 骨骼舞台 */
#pet-root .pet-rig {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}
#pet-root .pet-part {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}
#pet-root .pet-part.pet-nested {
  z-index: 1;
}
#pet-root .pet-bone {
  position: relative;
  width: 100%;
  height: 100%;
  will-change: transform;
}
#pet-root .pet-bone img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* 眨眼遮罩（挂在头部骨骼内，随头动） */
#pet-root .pet-eye {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(180deg, #3d2810 0%, #1a1208 100%);
  transform-origin: center center;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

#pet-root .pet-bubble.hidden { display: none; }
#pet-root .pet-bubble {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  max-width: 200px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary);
  background: linear-gradient(135deg, #FFF9E5, #FFE5EC);
  border: 1px solid #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  animation: petBubbleIn 0.3s ease forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes petBubbleIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#pet-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: transparent;
  pointer-events: none;
}
#pet-chat-panel.hidden { display: none; }
.pet-chat-box {
  position: absolute;
  width: 540px;
  height: 440px;
  min-width: 280px;
  min-height: 320px;
  max-width: 92vw;
  max-height: 88vh;
  pointer-events: auto;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
@media (max-width: 640px) {
  .pet-chat-box {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
}
.pet-chat-resize-handles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.pet-chat-resize-handle {
  position: absolute;
  pointer-events: auto;
  background: transparent;
}
.pet-chat-resize-handle.n,
.pet-chat-resize-handle.s {
  left: 12px;
  right: 12px;
  height: 8px;
}
.pet-chat-resize-handle.n { top: -2px; cursor: n-resize; }
.pet-chat-resize-handle.s { bottom: -2px; cursor: s-resize; }
.pet-chat-resize-handle.e,
.pet-chat-resize-handle.w {
  top: 12px;
  bottom: 12px;
  width: 8px;
}
.pet-chat-resize-handle.e { right: -2px; cursor: e-resize; }
.pet-chat-resize-handle.w { left: -2px; cursor: w-resize; }
.pet-chat-resize-handle.ne,
.pet-chat-resize-handle.nw,
.pet-chat-resize-handle.se,
.pet-chat-resize-handle.sw {
  width: 14px;
  height: 14px;
}
.pet-chat-resize-handle.ne { top: -2px; right: -2px; cursor: ne-resize; }
.pet-chat-resize-handle.nw { top: -2px; left: -2px; cursor: nw-resize; }
.pet-chat-resize-handle.se { bottom: -2px; right: -2px; cursor: se-resize; }
.pet-chat-resize-handle.sw { bottom: -2px; left: -2px; cursor: sw-resize; }
.pet-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  touch-action: none;
  flex-shrink: 0;
}
.pet-chat-header:active { cursor: grabbing; }
.pet-chat-drag-icon {
  color: var(--text-hint, #b0b0c0);
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.pet-chat-header h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.pet-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 80px;
}
.pet-chat-msg {
  margin-bottom: 8px;
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}
.pet-chat-msg.user { margin-left: auto; background: rgba(51,51,51,0.06); }
.pet-chat-msg.assistant { background: linear-gradient(135deg, #FFF9E5, #FFE5EC); }
.pet-chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  align-items: center;
}
.pet-chat-voice-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.pet-chat-voice-btn.is-active {
  background: linear-gradient(135deg, #FFF3E0, #FFE5EC);
  border-color: #FACC5C;
  box-shadow: 0 0 0 2px rgba(250, 204, 92, 0.25);
}
.pet-chat-voice-status {
  padding: 6px 14px 0;
  font-size: 12px;
  color: var(--text-secondary, #888899);
  text-align: center;
}
.pet-chat-voice-status.hidden { display: none; }
.pet-chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px 0;
}
.pet-chat-tool-btn,
.pet-chat-voice-link {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary, #888899);
  white-space: nowrap;
}
.pet-chat-tool-btn.is-active,
.pet-chat-voice-link.is-active {
  background: linear-gradient(135deg, #FFF3E0, #FFE5EC);
  border-color: #FACC5C;
  color: var(--text-dark, #1F2041);
}
.pet-chat-voice-menu {
  position: fixed;
  z-index: 10002;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #eee);
  border-radius: 12px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.12));
}
.pet-chat-voice-opt-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}
.pet-chat-voice-opt-row.is-active {
  background: rgba(250, 204, 92, 0.18);
}
.pet-chat-voice-opt-row:hover {
  background: rgba(250, 204, 92, 0.12);
}
.pet-chat-voice-opt {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 8px 8px 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary, #333);
}
.pet-chat-voice-opt:hover,
.pet-chat-voice-opt-row.is-active .pet-chat-voice-opt {
  background: transparent;
}
.pet-chat-voice-preview-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border, #eee);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-sec, #666);
}
.pet-chat-voice-preview-btn:hover,
.pet-chat-voice-preview-btn.is-playing {
  border-color: #FACC5C;
  background: linear-gradient(135deg, #FFF3E0, #FFE5EC);
  color: var(--text-dark, #1F2041);
}
.pet-chat-voice-link {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary, #888899);
}
.pet-chat-voice-link.is-active {
  background: linear-gradient(135deg, #FFF3E0, #FFE5EC);
  border-color: #FACC5C;
  color: var(--text-dark, #1F2041);
}
.pet-chat-input input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
}
.pet-chat-input button {
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  #pet-root .pet-bone { transition: none !important; }
  #pet-root .pet-shadow { filter: blur(10px) !important; }
  #pet-root .pet-note { animation: none !important; opacity: 0 !important; }
}

/* 背景音乐 — 耳机旁飘动音符 */
#pet-root .pet-music-notes {
  position: absolute;
  left: 50%;
  top: 2%;
  width: 104px;
  height: 96px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 4;
}
#pet-root .pet-music-notes.is-active {
  opacity: 1;
}
#pet-root .pet-note {
  position: absolute;
  bottom: 0;
  font-size: 30px;
  line-height: 1;
  color: #FACC5C;
  text-shadow: 0 2px 8px rgba(60, 40, 20, 0.45), 0 0 12px rgba(250, 204, 92, 0.35);
  opacity: 0;
  animation: petNoteRise 2.2s ease-out infinite;
}
#pet-root .pet-note:nth-child(1) { left: 0; animation-delay: 0s; }
#pet-root .pet-note:nth-child(2) { left: 32px; animation-delay: 0.65s; font-size: 26px; color: #FFE08A; }
#pet-root .pet-note:nth-child(3) { left: 64px; animation-delay: 1.3s; font-size: 28px; }

@keyframes petNoteRise {
  0%   { opacity: 0; transform: translate(0, 4px) scale(0.65); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(14px, -72px) scale(1.15); }
}

.pet-bgm-menu {
  position: fixed;
  z-index: 10001;
  min-width: 132px;
  padding: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #eee);
  border-radius: 12px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.12));
  transform: translate(-8px, -8px);
}
.pet-bgm-menu button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary, #333);
}
.pet-bgm-menu button:hover {
  background: rgba(250, 204, 92, 0.18);
}
