/* 鲸鱼娘 · 站点挂件 */
.wg {
  position: fixed;
  left: 22px;
  bottom: 18px;
  z-index: 900;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 320px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #28415e;
  font: 12px/1.45 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  transition: opacity 0.3s ease, transform 2.4s cubic-bezier(0.34, 0.08, 0.2, 1);
}

html[data-theme="dark"] .wg {
  color: #dbe7f5;
}

.wg[hidden] {
  display: none;
}

.wg-pet {
  flex: none;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
}

.wg-pet svg {
  display: block;
  width: 96px;
  height: 96px;
  overflow: visible;
  animation: wg-bob 3.4s ease-in-out infinite;
}

.wg-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  padding: 7px 11px;
  border-radius: 15px;
  background-color: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 20px rgba(31, 66, 110, 0.1);
}

html[data-theme="dark"] .wg-body {
  background-color: rgba(29, 38, 52, 0.94);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38);
}

.wg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.wg-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #35c07a;
}

.wg[data-phase="slack"] .wg-dot {
  background: #f0a500;
}

.wg-state {
  font-weight: 600;
}

.wg-shift {
  margin-left: auto;
  opacity: 0.6;
  font-size: 10px;
}

.wg-bubble {
  max-width: 208px;
  padding: 3px 8px;
  border-radius: 10px;
  background: #f2f7fd;
  border: 1px solid #e3ecf6;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="dark"] .wg-bubble {
  background: #24303f;
  border-color: #2d3c50;
}

.wg-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.wg-coins {
  color: #c99513;
  white-space: nowrap;
}

.wg-coins b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.wg-tip {
  padding: 1px 9px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.wg-tip:hover {
  border-color: #4b97dd;
  color: #2f7fd0;
}

.wg-close {
  position: absolute;
  top: -4px;
  right: -2px;
  opacity: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  opacity: 0.35;
  cursor: pointer;
}

.wg-close:hover {
  opacity: 0.8;
}

/* 尾巴 / 眼睛 / 小鱼 / 睡意 / 爱心 */
.wg-tail {
  transform-origin: 22px 60px;
  animation: wg-wag 2.6s ease-in-out infinite;
}

.wg-eyes {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.2s ease;
}

.wg[data-mood="happy"] .wg-eyes {
  transform: scaleY(0.3);
}

.wg[data-mood="sly"] .wg-eyes {
  transform: scaleY(0.35);
}

.wg-fish {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.wg[data-phase="slack"] .wg-fish {
  opacity: 1;
  animation: wg-float 2.2s ease-in-out infinite;
}

.wg-zzz {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.wg[data-phase="slack"] .wg-zzz {
  opacity: 1;
  animation: wg-zzz 2.4s ease-in-out infinite;
}

.wg-heart {
  opacity: 0;
}

.wg[data-hearts="on"] .wg-heart {
  animation: wg-heart 1s ease-out 3;
}

@keyframes wg-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes wg-wag {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-8deg); }
}

@keyframes wg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes wg-zzz {
  0% { opacity: 0; transform: translateY(2px); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-5px); }
}

@keyframes wg-heart {
  0% { opacity: 0; transform: scale(0.6) translateY(4px); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.1) translateY(-12px); }
}

@media (max-width: 767px) {
  .wg {
    left: 12px;
    bottom: 12px;
    padding: 6px;
  }

  .wg-body,
  .wg-close {
    display: none;
  }

  .wg[data-open="on"] .wg-body {
    display: flex;
  }

  .wg[data-open="on"] .wg-close {
    display: block;
  }

  .wg[data-open="on"] {
    max-width: calc(100vw - 24px);
  }

  .wg-pet,
  .wg-pet svg {
    width: 52px;
    height: 52px;
  }
}

/* 注：这里原本会响应系统的"减少动态效果"并关掉所有动画，
   导致部分 Windows 用户完全看不到动作，已移除。 */

/* ---- ??????? ---- */
.wg-boss-art {
  position: absolute;
  right: 10px;
  top: -42px;
  width: 42px;
  height: 42px;
  opacity: 0;
  transform: scale(0.6) translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(120, 40, 20, 0.18));
}

.wg[data-boss="on"] .wg-boss-art {
  opacity: 1;
  transform: scale(1) translateY(0);
  animation: wg-boss-shake 1.2s ease-in-out infinite;
}

.wg-chip {
  display: none;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: #e0553a;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.wg[data-boss="on"] .wg-shift { display: none; }

.wg[data-boss="on"] .wg-chip {
  display: inline-flex;
  animation: wg-pulse 1s ease-in-out infinite;
}

@keyframes wg-boss-shake {
  0%, 100% { transform: scale(1) rotate(-3deg); }
  50% { transform: scale(1.05) rotate(3deg); }
}

@keyframes wg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (max-width: 767px) {
  .wg-boss-art { display: none; }
}

/* ---- ????????????? ---- */
.wg[data-shift="on"] .wg-pet {
  animation: wg-shift-pop 0.7s ease;
}

@keyframes wg-shift-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.045); }
  100% { transform: scale(1); }
}

/* ?????????????????????? */
@media (max-width: 767px) {
  .wg-tip { display: none; }
}

/* ---- ???? / ?? / ?? / ?? / ?? ---- */
.wg-coins i {
  font-style: normal;
  opacity: 0.55;
}

.wg-msg {
  padding: 1px 9px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  color: inherit;
  font-size: 11px;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.wg-msg:hover {
  border-color: #4b97dd;
  color: #2f7fd0;
}

.wg-fx {
  position: absolute;
  left: 48px;
  top: 14px;
  font-size: 11px;
  font-weight: 600;
  color: #c99513;
  pointer-events: none;
  animation: wg-fx-up 1.05s ease-out forwards;
}

.wg-fx-bad {
  color: #e0553a;
}

@keyframes wg-fx-up {
  0% { opacity: 0; transform: translateY(6px) scale(0.9); }
  25% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-20px) scale(1); }
}

.wg[data-hit="on"] .wg-pet {
  animation: wg-hit 0.55s ease;
}

@keyframes wg-hit {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.wg[data-blink="on"] .wg-eyes {
  transform: scaleY(0.08);
}

/* ---- ????? ---- */
.wg[data-sleep="on"] .wg-eyes {
  transform: scaleY(0.08);
}

.wg[data-sleep="on"] .wg-zzz {
  opacity: 1;
  animation: wg-zzz 3.4s ease-in-out infinite;
}

.wg[data-sleep="on"] .wg-pet svg {
  animation-duration: 6.5s;
}

.wg[data-sleep="on"] .wg-tail {
  animation-duration: 5.5s;
}

.wg[data-sleep="on"] .wg-dot {
  background: #8496ab;
}

.wg[data-sleep="on"] .wg-bubble {
  opacity: 0.85;
  font-style: italic;
}

/* ---- 被点一下：甩尾游开 ---- */
.wg[data-dodge="on"] {
  transition: transform 0.8s cubic-bezier(0.22, 0.85, 0.3, 1), opacity 0.3s ease;
}

.wg[data-dodge="on"] .wg-tail {
  animation: wg-wag 0.5s ease-in-out infinite;
}

.wg[data-dodge="on"] .wg-pet svg {
  animation-duration: 1.1s;
}

/* ---- 被连点戳急了 ---- */
.wg[data-angry="on"] .wg-body {
  box-shadow: 0 8px 24px rgba(224, 85, 58, 0.24);
}

.wg[data-angry="on"] .wg-dot {
  background: #e0553a;
}

.wg[data-angry="on"] .wg-tail {
  animation: wg-wag 0.35s ease-in-out infinite;
}

.wg[data-angry="on"] .wg-eyes {
  transform: scaleY(0.5) rotate(-4deg);
}

.wg[data-angry="on"] .wg-bubble {
  border-color: #ffc9b8;
  background: #fff3ef;
  color: #b8432a;
}

html[data-theme="dark"] .wg[data-angry="on"] .wg-bubble {
  background: #3a2420;
  border-color: #5a3730;
  color: #ffb9a4;
}

.wg:hover .wg-close {
  opacity: 0.55;
}

.wg-close:hover {
  opacity: 1 !important;
}

/* 气泡可拖动换位置 */
.wg-body {
  cursor: grab;
  touch-action: none;
}

.wg-body:active {
  cursor: grabbing;
}

.wg-body:hover {
  box-shadow: 0 8px 24px rgba(31, 66, 110, 0.15);
}

/* 整块都能拖：鲸鱼本体 + 气泡 */
.wg {
  user-select: none;
  touch-action: none;
}

.wg-pet {
  cursor: grab;
}

.wg-pet:active {
  cursor: grabbing;
}

/* ---------- 对话输入条 ---------- */
.wg-chat {
  display: flex;
  gap: 6px;
  margin: 0 0 8px;
}

.wg-chat[hidden] { display: none; }

.wg-chat-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  background: #f8fbfe;
  font: 12px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #2c3e50;
  outline: none;
}

.wg-chat-input:focus { border-color: #7fb8dc; background: #fff; }

.wg-chat-send {
  flex: none;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: #4b97dd;
  color: #fff;
  font: 12px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-weight: 600;
  cursor: pointer;
}

.wg-chat-send:hover { background: #2f7fd0; }

.wg-chatbtn {
  padding: 3px 10px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #3a556d;
  font: 11px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  cursor: pointer;
}

.wg-chatbtn:hover { border-color: #4b97dd; color: #2f7fd0; }


/* ========== 说话独立：鲸鱼头上的贴纸气泡 ========== */
.wg-say {
  position: absolute;
  left: 74px;
  bottom: calc(100% - 4px);
  width: 250px;
  max-width: calc(100vw - 40px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.wg-say > * {
  pointer-events: auto;
}

.wg-bubble {
  position: relative;
  max-width: 250px;
  padding: 11px 15px 12px;
  border: 2px solid #21456f;
  border-radius: 16px 16px 16px 6px;
  background: #fffdf4;
  color: #1b2f52;
  font-family: "Yuanti SC", "YouYuan", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: 0.015em;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  box-shadow: 4px 4px 0 rgba(33, 69, 111, 0.16);
  transform: rotate(-1.2deg);
  transform-origin: left bottom;
}

/* 气泡尾巴，指向下面的鲸鱼 */
.wg-bubble::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -12px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-top-color: #fffdf4;
  border-right-width: 10px;
  filter: drop-shadow(0 2px 0 #21456f);
}

/* 引号装饰 */
.wg-bubble::before {
  content: "“";
  position: absolute;
  left: 6px;
  top: -12px;
  font-size: 30px;
  line-height: 1;
  color: #8fb6dc;
  opacity: 0.55;
}

html[data-theme="dark"] .wg-bubble {
  background: #1b2536;
  color: #e6eefb;
  border-color: #6f9cc9;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .wg-bubble::after {
  border-top-color: #1b2536;
}

/* 深夜睡觉时别喊了 */
.wg[data-sleep="on"] .wg-bubble {
  opacity: 0.55;
}

/* 卡片瘦一点，让气泡当主角 */
.wg-body {
  padding: 6px 10px;
  gap: 2px;
}

.wg-meta {
  font-size: 10.5px;
}

@media (max-width: 767px) {
  .wg-say {
    left: 0;
    width: min(78vw, 300px);
    bottom: calc(100% + 2px);
  }

  .wg-bubble {
    font-size: 14px;
    padding: 9px 12px 10px;
    border-radius: 14px 14px 14px 6px;
  }
}


/* 动作行：小、斜、淡，像旁白 */
.wg-act {
  display: block;
  margin-bottom: 3px;
  font-family: "Yuanti SC", "YouYuan", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.02em;
  color: #7d93ad;
  white-space: normal;
}

.wg-act[hidden] { display: none; }

.wg-act::before { content: "（"; }
.wg-act::after { content: "）"; }

.wg-line {
  display: block;
  white-space: normal;
}

html[data-theme="dark"] .wg-act {
  color: #93a9c2;
}


/* ===== v2 外观 ===== */
/* 气泡：贴在鲸鱼头顶，干净的圆角 + 柔和投影 */
.wg {
  max-width: 380px;
  align-items: flex-end;
}

.wg-say {
  left: 4px;
  bottom: calc(100% + 2px);
  width: min(300px, calc(100vw - 44px));
  gap: 8px;
}

.wg-bubble {
  position: relative;
  max-width: none;
  padding: 12px 16px 13px;
  border: 1px solid #d9e8f6;
  border-radius: 18px 18px 18px 6px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f9ff 100%);
  color: #1d3552;
  font-family: "Yuanti SC", "YouYuan", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 28px rgba(28, 64, 104, 0.16), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  transform: none;
  white-space: normal;
  overflow: visible;
}

/* 尾巴：指向下面的鲸鱼 */
.wg-bubble::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -8px;
  width: 15px;
  height: 15px;
  background: #f6fbff;
  border-right: 1px solid #d9e8f6;
  border-bottom: 1px solid #d9e8f6;
  border-bottom-right-radius: 3px;
  transform: rotate(45deg);
  filter: none;
}

/* 左上角一点点装饰，不再用大引号 */
.wg-bubble::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 9px;
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #9fd0f5, rgba(159, 208, 245, 0));
  opacity: 0.9;
}

.wg-bubble .wg-act {
  margin: 2px 0 4px;
  padding-left: 0;
  font-size: 11.5px;
  font-style: italic;
  font-weight: 600;
  color: #7d94ae;
  letter-spacing: 0.02em;
}

.wg-bubble .wg-line {
  display: block;
}

/* 卡片：更轻，更像工牌照 */
.wg-body {
  gap: 5px;
  margin-bottom: 14px;
  padding: 9px 12px 8px;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(28, 64, 104, 0.12);
  backdrop-filter: blur(6px);
}

html[data-theme="dark"] .wg-body {
  background-color: rgba(24, 33, 46, 0.94);
}

.wg-meta {
  font-size: 11px;
  letter-spacing: 0.01em;
}

.wg-foot {
  gap: 6px;
}

.wg-coins {
  margin-right: 2px;
  font-variant-numeric: tabular-nums;
}

/* 按钮：轻胶囊，打赏用暖色强调 */
.wg-tip,
.wg-chatbtn {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.wg-tip {
  border: 1px solid #ffd7a8;
  background: #fff6e8;
  color: #b56a12;
}

.wg-tip:hover {
  background: #ffedcf;
  border-color: #ffb85c;
  color: #93530a;
}

.wg-chatbtn {
  border: 1px solid #cfe4f7;
  background: #eef7ff;
  color: #2b6ea8;
}

.wg-chatbtn:hover {
  background: #ddefff;
  border-color: #9fcbe8;
  color: #1f5b8f;
}

.wg-tip:active,
.wg-chatbtn:active {
  transform: scale(0.96);
}

.wg-chat {
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(28, 64, 104, 0.12);
}

.wg-chat-input {
  border: 0;
  background: transparent;
  padding: 4px 6px;
}

.wg-chat-input:focus {
  background: transparent;
  border: 0;
}

.wg-chat-send {
  padding: 5px 12px;
  font-size: 11.5px;
}

html[data-theme="dark"] .wg-bubble {
  background: linear-gradient(180deg, #1e2a3a 0%, #1a2432 100%);
  border-color: #33465e;
  color: #e8f0fb;
}

html[data-theme="dark"] .wg-bubble::after {
  background: #1a2432;
  border-color: #33465e;
}

/* 手机：气泡在头像上方，展开后卡片照常有打赏 */
@media (max-width: 767px) {
  .wg-say {
    left: 0;
    width: min(76vw, 320px);
    bottom: calc(100% + 4px);
  }

  .wg-bubble {
    font-size: 14px;
    padding: 10px 13px 11px;
    border-radius: 16px 16px 16px 6px;
  }

  .wg-body {
    margin-bottom: 10px;
    padding: 8px 10px 7px;
  }

  .wg[data-open="on"] .wg-foot {
    gap: 5px;
  }
}

/* ===== v2.1 微调：气泡贴合文字，去掉多余装饰 ===== */
.wg-say {
  width: auto;
  max-width: min(320px, calc(100vw - 44px));
}

.wg-bubble {
  width: fit-content;
  max-width: min(320px, calc(100vw - 44px));
}

.wg-bubble::before {
  display: none;
}

@media (max-width: 767px) {
  .wg-say {
    max-width: min(80vw, 320px);
  }

  .wg-bubble {
    max-width: min(80vw, 320px);
  }
}

/* ===== v2.2 输入框回到卡片内部，气泡只负责说话 ===== */
.wg-body .wg-chat {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  padding: 5px 6px 5px 10px;
  border-radius: 999px;
  background: #f4f9ff;
  border: 1px solid #dbe8f6;
  box-shadow: none;
}

.wg-body .wg-chat[hidden] { display: none; }

.wg-body .wg-chat-input {
  flex: 1;
  min-width: 90px;
  border: 0;
  background: transparent;
  padding: 3px 2px;
  font-size: 12px;
}

.wg-body .wg-chat-input:focus {
  border: 0;
  background: transparent;
}

.wg-body .wg-chat-send {
  flex: none;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11.5px;
}

/* 生气时气泡配色（保留尾巴形状） */
.wg[data-angry="on"] .wg-bubble {
  border-color: #ffc9b8;
  background: linear-gradient(180deg, #fff7f4 0%, #ffeee8 100%);
  color: #b8432a;
}

.wg[data-angry="on"] .wg-bubble::after {
  background: #ffeee8;
  border-color: #ffc9b8;
}

/* ===== v2.3 修手机端气泡被挤成竖条 ===== */
/* 绝对定位容器不能在 width:auto 下 shrink-to-fit，必须给明确宽度 */
.wg-say {
  width: min(300px, calc(100vw - 44px));
  max-width: none;
}

.wg-bubble {
  width: fit-content;
  max-width: 100%;
}

@media (max-width: 767px) {
  .wg-say {
    width: min(74vw, 300px);
    max-width: none;
    left: 0;
  }

  .wg-bubble {
    max-width: 100%;
    font-size: 14px;
  }
}

/* ===== v2.4 手机端恢复打赏按钮，并给卡片足够宽度 ===== */
@media (max-width: 767px) {
  .wg-tip {
    display: inline-flex;
    align-items: center;
  }

  .wg[data-open="on"] .wg-body {
    max-width: calc(100vw - 86px);
    padding: 8px 10px 7px;
  }

  .wg[data-open="on"] .wg-foot {
    flex-wrap: wrap;
    gap: 5px;
  }

  .wg[data-open="on"] .wg-foot .wg-coins {
    margin-right: 0;
  }
}

/* ============================================================
   v3 手机适配修正（2026-11-02）
   问题：对话气泡太长会顶出屏幕，拖到右边气泡会溢出右侧
   做法：气泡限高可滚动 + 靠边自动翻转 + 拖动按控件实际尺寸夹紧
   ============================================================ */

.wg {
  touch-action: none;            /* 拖动时不要带着页面一起滚 */
}

.wg-say {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* 靠近右边缘时，气泡改成右对齐，尾巴也跟着翻 */
.wg[data-edge="right"] .wg-say {
  left: auto;
  right: 4px;
}

.wg[data-edge="right"] .wg-bubble {
  border-radius: 18px 18px 6px 18px;
}

.wg[data-edge="right"] .wg-bubble::after {
  left: auto;
  right: 20px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 3px;
}

@media (max-width: 767px) {
  .wg-say {
    left: 6px;
    right: 6px;
    width: auto;
    max-width: none;
    max-height: 44vh;             /* 留一半屏幕给鲸鱼和输入框 */
  }

  .wg[data-edge="right"] .wg-say {
    right: 6px;
  }

  .wg-bubble {
    font-size: 13.5px;
    line-height: 1.6;
  }

  .wg-chat-input,
  .wg-chat-send {
    font-size: 13px;              /* 小于 16px 时 iOS 会强制放大页面 */
  }
}

/* 底部安全区（iPhone 的横条） */
.wg {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* 键盘弹出时：整块往上顶，气泡先收起来，只留输入框 */
.wg {
  margin-bottom: var(--kb, 0px);
  transition: margin-bottom 0.18s ease;
}

@media (max-width: 767px) {
  .wg[data-typing="on"] .wg-say {
    display: none;
  }

  .wg[data-typing="on"] .wg-body {
    box-shadow: 0 8px 22px rgba(28, 64, 104, 0.18);
  }
}

/* v3.1 覆盖：手机气泡贴视口，避免被 .wg 容器挤成竖排 */
@media (max-width: 767px) {
  .wg-say {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    bottom: calc(88px + var(--kb, 0px)) !important;
    max-height: 44vh;
  }
  .wg-chat-input, .wg-chat-send { font-size: 16px; }
}

/* ============================================================
   v3.2 手机键盘：聚焦时把鲸鱼收起来，输入框贴底
   ============================================================ */
@media (max-width: 767px) {
  .wg {
    bottom: 16px !important;      /* 原来 12px 会被底边裁掉一点 */
  }

  .wg[data-typing="on"] {
    bottom: calc(8px + var(--kb, 0px)) !important;
  }

  .wg[data-typing="on"] .wg-pet {
    display: none;                /* 键盘一出来，鲸鱼先让位 */
  }

  .wg[data-typing="on"] .wg-body {
    margin: 0;
  }
}
