/* XiaoWen geometry repair — isolated from page and dashboard layouts. */
html:not(.react-student-embedded) body #companionDock.companion-dock {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  right: 24px !important;
  bottom: 24px !important;
  z-index: 1500 !important;
  margin: 0 !important;
  transform: none !important;
  overflow: visible !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-collapsed {
  display: block !important;
  width: 56px !important;
  min-width: 56px !important;
  max-width: 56px !important;
  height: 56px !important;
  min-height: 56px !important;
  max-height: 56px !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-collapsed #companionMini {
  position: relative !important;
  inset: auto !important;
  display: grid !important;
  width: 56px !important;
  min-width: 56px !important;
  max-width: 56px !important;
  height: 56px !important;
  min-height: 56px !important;
  max-height: 56px !important;
  padding: 0 !important;
  place-items: center !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: linear-gradient(135deg, #6366f1, #7c3aed 58%, #ec4899) !important;
  background-image: none !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-collapsed #companionMiniAvatarStage::before {
  content: "问" !important;
  position: absolute !important;
  inset: 0 !important;
  display: grid !important;
  place-items: center !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: #ffffff !important;
  font-size: 22px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  opacity: 1 !important;
  transform: none !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-collapsed #companionMiniAvatarStage::after {
  display: none !important;
  content: none !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-collapsed #companionMiniAvatarStage {
  position: absolute !important;
  inset: 4px !important;
  display: block !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-collapsed #companionMiniCharacter {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-expanded {
  display: block !important;
  width: min(390px, calc(100vw - 32px)) !important;
  min-width: min(390px, calc(100vw - 32px)) !important;
  max-width: min(390px, calc(100vw - 32px)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100vh - 48px) !important;
  overflow: visible !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-expanded #companionMini {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

html:not(.react-student-embedded) body #companionDock.companion-dock.companion-expanded #companionPanel.companion-panel {
  position: static !important;
  inset: auto !important;
  display: grid !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: min(620px, calc(100vh - 48px)) !important;
  margin: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  border-radius: 20px !important;
  transform: none !important;
}

html:not(.react-student-embedded) body #companionPanel.companion-panel[hidden] {
  display: none !important;
}

html:not(.react-student-embedded) body #companionPanel .companion-model-fallback {
  position: relative !important;
  display: grid !important;
  grid-template-columns: 132px minmax(0, 1fr) !important;
  width: calc(100% - 28px) !important;
  min-height: 160px !important;
  margin: 14px !important;
  padding: 12px 16px 0 !important;
  align-items: end !important;
  overflow: hidden !important;
  border: 1px solid rgba(124, 58, 237, 0.16) !important;
  border-radius: 18px !important;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(59, 130, 246, 0.08)) !important;
}

html:not(.react-student-embedded) body #companionPanel .companion-model-fallback-glow {
  position: absolute !important;
  left: 20px !important;
  bottom: 8px !important;
  width: 116px !important;
  height: 116px !important;
  border-radius: 50% !important;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.3), transparent 70%) !important;
  filter: blur(8px) !important;
}

html:not(.react-student-embedded) body #companionPanel .companion-model-fallback img {
  position: relative !important;
  z-index: 1 !important;
  display: block !important;
  width: 124px !important;
  height: 148px !important;
  align-self: end !important;
  object-fit: cover !important;
  object-position: center top !important;
  filter: drop-shadow(0 10px 16px rgba(45, 35, 90, 0.2)) !important;
  transform-origin: 50% 100% !important;
  animation: companionModelBreathe 3.4s ease-in-out infinite !important;
}

html:not(.react-student-embedded) body #companionPanel .companion-model-fallback > span {
  position: relative !important;
  z-index: 1 !important;
  display: flex !important;
  min-height: 72px !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-self: center !important;
  color: #64748b !important;
  font-size: 12px !important;
  font-weight: 800 !important;
}

html:not(.react-student-embedded) body #companionPanel .companion-model-fallback > span b {
  color: #172033 !important;
  font-size: 20px !important;
}

html[data-theme="dark"]:not(.react-student-embedded) body #companionPanel .companion-model-fallback > span b {
  color: #f1f5f9 !important;
}

@keyframes companionModelBreathe {
  0%, 100% { transform: translateY(2px) scale(1); }
  50% { transform: translateY(-3px) scale(1.015); }
}

@media (prefers-reduced-motion: reduce) {
  html:not(.react-student-embedded) body #companionPanel .companion-model-fallback img {
    animation: none !important;
  }
}

@media (max-width: 700px) {
  html:not(.react-student-embedded) body #companionDock.companion-dock {
    right: 12px !important;
    bottom: 12px !important;
  }

  html:not(.react-student-embedded) body #companionDock.companion-dock.companion-expanded {
    width: calc(100vw - 24px) !important;
    min-width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
  }

  html:not(.react-student-embedded) body #companionDock.companion-dock.companion-expanded #companionPanel.companion-panel {
    max-height: calc(100vh - 24px) !important;
  }
}
