/* Web Baize companion — portal floating pet */
#baize-web-pet {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2147483000;
  width: 148px;
  pointer-events: none;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  animation: bwp-enter 0.55s ease-out;
}
#baize-web-pet * { box-sizing: border-box; }
#baize-web-pet .bwp-stage {
  position: relative;
  width: 148px;
  height: 148px;
  pointer-events: auto;
  cursor: grab;
  transform-origin: 50% 85%;
  /* 不用整层 drop-shadow，避免「抠在黑卡片里」的硬框感 */
  filter: none;
  background: transparent;
  will-change: transform;
}
#baize-web-pet.is-petting .bwp-stage {
  cursor: grabbing;
}
#baize-web-pet.is-petting:not(.is-dragging):not(.perf-on) .bwp-img {
  animation: bwp-purr 0.55s ease-in-out infinite;
}
#baize-web-pet.is-petting .bwp-eyes {
  display: block;
  height: 10%;
  top: 28%;
  opacity: 0.55;
  border-radius: 8px;
}
/* 景深：近大时脚底影略加重、略放大 */
#baize-web-pet.is-petting .bwp-stage::after {
  transform: scale(calc(0.85 + var(--bwp-depth, 0.5) * 0.45));
  opacity: calc(0.55 + var(--bwp-depth, 0.5) * 0.55);
  transition: transform 85ms linear, opacity 85ms linear;
}
#baize-web-pet.is-petting .bwp-img,
#baize-web-pet.is-petting .bwp-perf {
  filter: drop-shadow(0 calc(4px + var(--bwp-depth, 0.5) * 4px) calc(5px + var(--bwp-depth, 0.5) * 6px) rgba(24, 18, 12, calc(0.10 + var(--bwp-depth, 0.5) * 0.14)));
}
#baize-web-pet .bwp-stage::after {
  content: "";
  position: absolute;
  left: 28%;
  right: 28%;
  bottom: 1%;
  height: 10%;
  /* 只留脚底一抹接触影，融入页面背景 */
  background: radial-gradient(ellipse at 50% 50%, rgba(30, 24, 18, 0.16) 0%, rgba(30, 24, 18, 0.05) 45%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}
#baize-web-pet .bwp-img,
#baize-web-pet .bwp-perf,
#baize-web-pet .bwp-eyes { z-index: 1; }
#baize-web-pet .bwp-stage:active { cursor: grabbing; }
#baize-web-pet .bwp-img,
#baize-web-pet .bwp-perf {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: none;
  transform-origin: 50% 100%;
  /* 极轻脚底投影贴在像素上，不造矩形光晕 */
  filter: drop-shadow(0 5px 6px rgba(24, 18, 12, 0.14));
}
#baize-web-pet .bwp-perf {
  position: absolute;
  left: 0;
  top: 0;
}
#baize-web-pet .bwp-perf[hidden] { display: none !important; }
#baize-web-pet.perf-on .bwp-img { visibility: hidden; }
#baize-web-pet.perf-on .bwp-eyes { display: none !important; }
#baize-web-pet.is-dragging .bwp-img,
#baize-web-pet.is-napping .bwp-img,
#baize-web-pet.is-yawning .bwp-img,
#baize-web-pet.is-squashing .bwp-img,
#baize-web-pet.is-patting .bwp-img { animation: none; }
#baize-web-pet.pose-stand:not(.is-dragging):not(.is-napping):not(.is-yawning):not(.is-squashing):not(.perf-on) .bwp-img {
  animation: bwp-breath 2.5s ease-in-out infinite;
}
#baize-web-pet.pose-think:not(.is-dragging):not(.perf-on) .bwp-img {
  animation: bwp-floaty 2s ease-in-out infinite;
}
#baize-web-pet.pose-alert:not(.is-dragging):not(.perf-on) .bwp-img,
#baize-web-pet.is-patting:not(.perf-on) .bwp-img {
  animation: bwp-sway 0.6s ease-in-out infinite;
}
#baize-web-pet.pose-sit .bwp-img,
#baize-web-pet.pose-rest .bwp-img {
  transform: translateY(4px) scale(0.96);
}
#baize-web-pet.is-napping:not(.perf-on) .bwp-img {
  transform: translateY(6px) scale(0.94);
}
#baize-web-pet.is-yawning:not(.perf-on) .bwp-img {
  transform: translateY(4px) scaleY(0.97);
}
#baize-web-pet.is-squashing .bwp-img {
  animation: bwp-squash 180ms ease-out forwards;
}
#baize-web-pet.is-debug .bwp-badge {
  color: #e8c97a;
  border-color: rgba(201, 154, 46, 0.55);
}
#baize-web-pet.is-minimized { display: none !important; }
#bwp-restore {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2147483000;
  border: 1px solid rgba(201, 154, 46, 0.45);
  background: rgba(28, 24, 20, 0.94);
  color: #e8c97a;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  letter-spacing: 2px;
  cursor: pointer;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
#bwp-restore:hover { background: rgba(40, 34, 28, 0.96); }
#baize-web-pet .bwp-eyes {
  display: none;
  position: absolute;
  left: 22%;
  top: 26%;
  width: 56%;
  height: 14%;
  background: rgba(28, 24, 20, 0.72);
  border-radius: 6px;
  pointer-events: none;
}
#baize-web-pet.is-blink .bwp-eyes,
#baize-web-pet.is-napping .bwp-eyes,
#baize-web-pet.is-yawning .bwp-eyes,
#baize-web-pet.is-patting .bwp-eyes { display: block; }
#baize-web-pet .bwp-confess {
  display: none;
  margin-bottom: 8px;
  width: 220px;
  margin-left: -36px;
  pointer-events: auto;
}
#baize-web-pet .bwp-confess:not([hidden]) { display: block; }
#baize-web-pet .bwp-confess textarea {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-radius: 10px;
  padding: 8px;
  background: rgba(28, 24, 20, 0.94);
  color: #dddacc;
  font-size: 12px;
  resize: none;
  outline: none;
  font-family: inherit;
}
#baize-web-pet .bwp-confess-ask {
  margin-top: 6px;
  font-size: 12px;
  color: #dddacc;
  display: flex;
  align-items: center;
  gap: 8px;
}
#baize-web-pet .bwp-confess-ask[hidden] { display: none !important; }
#baize-web-pet .bwp-confess-ask button {
  font-size: 11px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  background: rgba(201, 168, 76, 0.12);
  color: #e8c97a;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
}
#baize-web-pet .bwp-menu {
  display: none;
  margin-bottom: 8px;
  width: 148px;
  pointer-events: auto;
  flex-direction: column;
  gap: 4px;
}
#baize-web-pet .bwp-menu:not([hidden]) { display: flex; }
#baize-web-pet .bwp-menu button {
  font-size: 11px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  background: rgba(28, 24, 20, 0.94);
  color: #e8c97a;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
#baize-web-pet .bwp-badge {
  position: absolute;
  left: 0;
  bottom: -2px;
  font-size: 10px;
  letter-spacing: 1px;
  color: #9a9278;
  background: rgba(22, 20, 15, 0.82);
  border: 1px solid rgba(201, 154, 46, 0.22);
  border-radius: 8px;
  padding: 1px 6px;
  pointer-events: none;
  white-space: nowrap;
}
#baize-web-pet:not(.is-guest) .bwp-badge { display: none; }
#baize-web-pet .bwp-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(201, 154, 46, 0.35);
  border-radius: 50%;
  background: rgba(22, 20, 15, 0.88);
  color: #9a9278;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s;
}
#baize-web-pet:hover .bwp-close,
#baize-web-pet:focus-within .bwp-close { opacity: 1; }
#baize-web-pet .bwp-close:hover { color: #e2b84a; border-color: rgba(201, 154, 46, 0.55); }
#baize-web-pet .bwp-bubble {
  display: none;
  margin-bottom: 8px;
  width: 220px;
  margin-left: -46px;
  padding: 10px 12px;
  background: rgba(28, 24, 20, 0.94);
  color: #dddacc;
  border: 1px solid rgba(201, 154, 46, 0.22);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.55;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
#baize-web-pet .bwp-bubble.is-open { display: block; }
#baize-web-pet .bwp-bubble p { margin: 0 0 8px; }
#baize-web-pet .bwp-disclaimer {
  margin: 0 0 8px !important;
  font-size: 10px;
  color: #8b8376;
}
#baize-web-pet .bwp-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
#baize-web-pet .bwp-actions a,
#baize-web-pet .bwp-actions button {
  font-size: 11px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  background: rgba(201, 168, 76, 0.12);
  color: #e8c97a;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
#baize-web-pet .bwp-actions a.solid,
#baize-web-pet .bwp-actions a.bwp-primary {
  background: rgba(201, 154, 46, 0.92);
  color: #120c00;
  border-color: transparent;
  font-weight: 600;
}
#baize-web-pet .bwp-actions a:hover,
#baize-web-pet .bwp-actions button:hover {
  background: rgba(201, 168, 76, 0.22);
}
#baize-web-pet .bwp-actions a.solid:hover,
#baize-web-pet .bwp-actions a.bwp-primary:hover {
  opacity: 0.9;
  background: rgba(201, 154, 46, 0.92);
}

/* Rest / breath overlays (page-level, like desktop companion) */
#bwp-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9995;
  background: rgba(12, 10, 8, 0.62);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 1s ease;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
#bwp-overlay.is-on {
  display: flex;
  opacity: 1;
}
#bwp-overlay.is-breath { background: rgba(12, 10, 8, 0.34); }
#bwp-overlay .bwp-ov-card {
  width: min(420px, 88vw);
  color: #dddacc;
  text-align: center;
  font-size: 16px;
  line-height: 1.7;
  padding: 28px 20px;
}
#bwp-overlay .bwp-ov-hint {
  margin-top: 22px;
  font-size: 12px;
  color: #8b8376;
}
#bwp-overlay .bwp-hold {
  margin: 12px auto 0;
  width: 180px;
  height: 6px;
  background: #2a2a38;
  border-radius: 4px;
  overflow: hidden;
}
#bwp-overlay .bwp-hold > i {
  display: block;
  height: 100%;
  width: 0;
  background: #c9a84c;
}
#bwp-breath-card {
  position: relative;
  width: min(400px, 92vw);
  border-radius: 24px;
  background: rgba(28, 24, 20, 0.94);
  color: #dddacc;
  padding: 20px 14px 18px;
  text-align: center;
}
#bwp-breath-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  color: #8b8376;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}
#bwp-breath-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 0 28px 10px;
}
#bwp-breath-modes button {
  appearance: none;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(201,168,76,.28);
  background: transparent;
  color: #8b8376;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: .5px;
  line-height: 1.3;
}
#bwp-breath-modes button:hover { color: #e8c97a; border-color: rgba(201,168,76,.5); }
#bwp-breath-modes button.on {
  color: #120c00;
  background: linear-gradient(135deg, #e8c97a, #c9a84c);
  border-color: transparent;
  font-weight: 600;
}
#bwp-breath-phase {
  font-size: 28px;
  color: #e8c97a;
  letter-spacing: 4px;
  min-height: 36px;
}
#bwp-breath-stage {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 8px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
#bwp-breath-ring { position: absolute; inset: 0; pointer-events: none; }
#bwp-breath-baize {
  width: 110px;
  height: 110px;
  object-fit: contain;
  pointer-events: none;
}
#bwp-breath-params { font-size: 12px; color: #8b8376; margin-top: 4px; }
#bwp-breath-cue { font-size: 12px; color: #b0ad9e; margin-top: 6px; min-height: 18px; }
#bwp-breath-dots { margin-top: 10px; display: flex; gap: 8px; justify-content: center; }
#bwp-breath-dots i {
  width: 8px; height: 8px; border-radius: 50%; background: #4a4438; display: block;
}
#bwp-breath-dots i.on { background: #c9a84c; }

@keyframes bwp-breath {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.015); }
}
@keyframes bwp-floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes bwp-sway {
  0%, 100% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
}
@keyframes bwp-purr {
  0%, 100% { transform: scaleY(1) translateY(0); }
  50% { transform: scaleY(0.975) translateY(1.5px); }
}
@keyframes bwp-squash {
  0% { transform: scaleY(0.94); }
  100% { transform: scaleY(1); }
}
@keyframes bwp-enter {
  0% { opacity: 0; transform: translateY(24px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  #baize-web-pet {
    right: 8px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    width: 112px;
  }
  #baize-web-pet .bwp-stage {
    width: 112px;
    height: 112px;
    filter: none;
  }
  #baize-web-pet .bwp-img,
  #baize-web-pet .bwp-perf,
  #baize-web-pet.is-petting .bwp-img,
  #baize-web-pet.is-petting .bwp-perf {
    /* 手机上整层 filter 易裂图；脚底影交给 ::after */
    filter: none !important;
  }
  #baize-web-pet .bwp-bubble {
    width: 180px;
    margin-left: -40px;
  }
  #baize-web-pet .bwp-img,
  #baize-web-pet .bwp-perf {
    /* 避免空 src 时露出浏览器默认裂图图标 */
    background-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  #baize-web-pet .bwp-img { animation: none !important; }
  #bwp-overlay { transition: none; }
}
