* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: transparent; user-select: none; -webkit-app-region: no-drag; }
#petCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; cursor: grab; }
#petCanvas:active { cursor: grabbing; }
#bubbleContainer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

/* ===== 气泡样式 ===== */
.bubble {
  position: absolute;
  background: #fff;
  border: 1.5px solid #f0c8d4;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: 'Microsoft YaHei','PingFang SC',sans-serif;
  font-size: 13px;
  color: #333;
  text-align: left;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(232, 138, 159, 0.15);
  z-index: 100;
  transition: opacity .25s, transform .25s;
  max-width: 220px;
  overflow-x: hidden;
  line-height: 1.5;
  word-break: break-word;
}
/* 主动发起对话的粉色高亮气泡 */
.bubble-initiative {
  background: linear-gradient(135deg, #fff5f7 0%, #ffe8ee 100%);
  border: 2px solid #e88a9f;
  box-shadow: 0 4px 16px rgba(232, 138, 159, 0.35);
  animation: initiative-pulse 2s ease-in-out infinite;
}
@keyframes initiative-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(232, 138, 159, 0.35); }
  50% { box-shadow: 0 4px 24px rgba(232, 138, 159, 0.55); }
}
/* 气泡滚动条样式：仅内容超长时显示（由 JS 动态添加 overflow-y: auto） */
.bubble::-webkit-scrollbar {
  width: 8px;
}
.bubble::-webkit-scrollbar-track {
  background: transparent;
}
.bubble::-webkit-scrollbar-thumb {
  background: #e8c8d4;
  border-radius: 2px;
}
.bubble::-webkit-scrollbar-thumb:hover {
  background: #d9a8b8;
}
.bubble.hidden { display: none; }
.bubble-pop { animation: bubblePop .35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes bubblePop {
  0% { transform: scale(0.7) translateY(24px); opacity: 0; }
  60% { transform: scale(1.05) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.bubble-fade-out { animation: bubbleFadeOut .25s ease forwards; }
@keyframes bubbleFadeOut {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95) translateY(-4px); }
}

/* ===== 交互按钮栏 ===== */
.interact-bar {
  position:absolute;
  display:flex;
  gap:6px;
  z-index:99;
  pointer-events:auto;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(232, 138, 159, 0.18);
  border: 1px solid #f5d8e0;
}
.interact-bar.hidden { display:none; }
.interact-bar-show { animation: barSlideUp .3s ease-out; }
@keyframes barSlideUp {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.interact-bar-hide { animation: barSlideDown .2s ease forwards; }
@keyframes barSlideDown {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(6px); }
}

/* ===== 交互按钮 ===== */
.interact-btn {
  padding: 5px 14px;
  border: 1px solid #e8b8c8;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff 0%, #fdf2f5 100%);
  color: #c46a82;
  font-family:'Microsoft YaHei','PingFang SC',sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor:pointer;
  transition: all .15s ease;
}
.interact-btn:hover {
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
  color: #fff;
  border-color: #e88a9f;
  box-shadow: 0 2px 8px rgba(232, 138, 159, 0.3);
}
.interact-btn:active { transform: scale(0.96); }
.interact-btn:nth-child(1) { animation: btnPop .25s ease .03s both; }
.interact-btn:nth-child(2) { animation: btnPop .25s ease .08s both; }
.interact-btn:nth-child(3) { animation: btnPop .25s ease .13s both; }
.interact-btn-highlight {
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
  color: #fff;
  border-color: #e88a9f;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(232, 138, 159, 0.3);
}
.interact-btn-highlight:hover {
  background: linear-gradient(180deg, #e88a9f 0%, #d97088 100%);
  box-shadow: 0 3px 12px rgba(232, 138, 159, 0.4);
}
@keyframes btnPop {
  0% { opacity: 0; transform: scale(0.8) translateY(4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== 设置按钮 ===== */
.settings-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #f0c8d4;
  color: #c46a82;
  font-size: 16px;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 2px 10px rgba(232, 138, 159, 0.18);
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.settings-btn:hover {
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
  color: #fff;
  border-color: #e88a9f;
  box-shadow: 0 4px 14px rgba(232, 138, 159, 0.35);
}
.settings-btn:active { transform: scale(0.95); }

/* ===== 遮罩层 ===== */
.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 250;
  opacity: 0;
  transition: opacity .2s ease;
}
.settings-overlay.hidden { display: none; }
.settings-overlay.overlay-show { opacity: 1; }
.settings-overlay.overlay-hide { opacity: 0; }

/* ===== 浮动设置面板（横版 4:3，自适应） ===== */
.settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(720px, 88vw);
  height: min(540px, 82vh);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.06);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: all .25s ease;
  pointer-events: auto;
}
.settings-panel.hidden { display: none; }
.settings-panel.panel-show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.settings-panel.panel-hide {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
}

/* 面板头部 */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #f5e8ed;
  flex-shrink: 0;
  background: linear-gradient(135deg, #fdf6f8 0%, #fff 100%);
  position: relative;
}
.settings-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  background: linear-gradient(90deg, #e88a9f, transparent);
  border-radius: 1px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8b8cc 0%, #f0a0b8 50%, #e888a8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(232, 136, 168, 0.35);
  flex-shrink: 0;
  overflow: hidden;
}
.header-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}
.settings-title {
  font-size: 17px;
  font-weight: 600;
  color: #c46a82;
  letter-spacing: 0.5px;
}
.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #b08898;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
  line-height: 1;
}
.close-btn:hover {
  background: #f8e8ed;
  color: #c46a82;
  transform: rotate(90deg);
}

/* 面板主体（左右两栏） */
.settings-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.settings-left {
  width: 280px;
  padding: 20px 22px;
  border-right: 1px solid #f5e8ed;
  overflow-y: auto;
  flex-shrink: 0;
  background: #fdfafb;
}
.settings-right {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
}

/* 设置区块 */
.settings-section {
  margin-bottom: 24px;
}
.settings-section:last-child { margin-bottom: 0; }
.settings-section h3 {
  font-size: 13px;
  color: #c46a82;
  margin-bottom: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #fdf2f5 0%, #f5e0e8 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* 角色预览 */
.char-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #fff 0%, #fdf6f8 100%);
  border-radius: 10px;
  border: 1px solid #f5e0e8;
  margin-bottom: 14px;
}
.char-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f5a5b8 0%, #e88a9f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(232, 138, 159, 0.3);
  flex-shrink: 0;
}
.char-meta { flex: 1; min-width: 0; }
.char-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}
.char-desc {
  font-size: 11px;
  color: #999;
}

/* 设置行 */
.settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.settings-row label {
  font-size: 12px;
  color: #888;
  font-weight: 500;
}
.settings-row select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e8c8d4;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: #333;
  cursor: pointer;
  outline: none;
  transition: all .2s ease;
}
.settings-row select:hover { border-color: #e88a9f; }
.settings-row select:focus { border-color: #e88a9f; box-shadow: 0 0 0 3px rgba(232, 138, 159, 0.12); }

/* 滑块 */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, #f5d8e0, #e8c8d4);
  outline: none;
  cursor: pointer;
}
.settings-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #e88a9f;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(232, 138, 159, 0.3);
  transition: transform .15s ease;
}
.settings-row input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
.settings-row span {
  min-width: 42px;
  font-size: 13px;
  color: #e88a9f;
  font-weight: 600;
  text-align: right;
}

/* 设置提示 */
.setting-tip {
  font-size: 11px;
  color: #b0b0b0;
  padding: 6px 10px;
  background: #f8f8f8;
  border-radius: 6px;
  border-left: 2px solid #e0e0e0;
  margin-top: 4px;
}

/* 消息文案 */
.msg-group { margin-bottom: 12px; }
.msg-group label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 5px;
  font-weight: 500;
}
.msg-group input[type="text"] {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid #e8c8d4;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  transition: all .2s ease;
  background: #fff;
  color: #333;
}
.msg-group input[type="text"]:hover { border-color: #e88a9f; }
.msg-group input[type="text"]:focus { border-color: #e88a9f; box-shadow: 0 0 0 3px rgba(232, 138, 159, 0.1); }

/* 互动按钮标签 */
.interact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.interact-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: linear-gradient(180deg, #fff 0%, #fdf2f5 100%);
  border: 1px solid #e8c8d4;
  border-radius: 12px;
  font-size: 11px;
  color: #c46a82;
  font-weight: 500;
}

/* 互动按钮回应 */
.response-group {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fdfafb;
  border-radius: 8px;
  border: 1px solid #f5e8ed;
}
.response-group label {
  display: block;
  font-size: 11px;
  color: #c46a82;
  margin-bottom: 5px;
  font-weight: 600;
}
.response-group textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #e8c8d4;
  border-radius: 6px;
  font-size: 11px;
  resize: vertical;
  font-family: inherit;
  outline: none;
  transition: all .2s ease;
  background: #fff;
  line-height: 1.5;
  color: #333;
}
.response-group textarea:focus { border-color: #e88a9f; box-shadow: 0 0 0 3px rgba(232, 138, 159, 0.1); }

/* 底部操作区 */
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 14px 24px;
  border-top: 1px solid #f5e8ed;
  flex-shrink: 0;
  background: #fdfafb;
}
.footer-hint {
  font-size: 11px;
  color: #b0b0b0;
  margin-right: auto;
}
.save-btn {
  padding: 8px 22px;
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
  color: #fff;
  border: 1px solid #e88a9f;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: 0 2px 8px rgba(232, 138, 159, 0.25);
  display: flex;
  align-items: center;
  gap: 6px;
}
.save-btn:hover {
  background: linear-gradient(180deg, #e88a9f 0%, #d97088 100%);
  box-shadow: 0 4px 12px rgba(232, 138, 159, 0.35);
  transform: translateY(-1px);
}
.save-btn:active { transform: translateY(0) scale(0.98); }
.save-status {
  font-size: 12px;
  color: #52c41a;
  font-weight: 500;
}
.save-status.error { color: #ff4d4f; }

/* 滚动条 */
.settings-left::-webkit-scrollbar,
.settings-right::-webkit-scrollbar { width: 5px; }
.settings-left::-webkit-scrollbar-track,
.settings-right::-webkit-scrollbar-track { background: transparent; }
.settings-left::-webkit-scrollbar-thumb,
.settings-right::-webkit-scrollbar-thumb {
  background: #f0c8d4;
  border-radius: 3px;
}
.settings-left::-webkit-scrollbar-thumb:hover,
.settings-right::-webkit-scrollbar-thumb:hover { background: #e88a9f; }

/* ===== 聊天输入框（简洁版） ===== */
.chat-box {
  position: absolute;
  width: 300px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(232, 138, 159, 0.25);
  border: 1px solid #f0c8d4;
  z-index: 150;
  overflow: hidden;
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  padding: 8px 10px;
  pointer-events: auto; /* 覆盖父元素 bubbleContainer 的 pointer-events: none */
}
.chat-box.hidden { display: none; }

.chat-input-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.chat-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #e8c8d4;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  transition: all .2s ease;
  background: #fff;
  color: #333;
}
.chat-input:focus {
  border-color: #e88a9f;
  box-shadow: 0 0 0 3px rgba(232, 138, 159, 0.1);
}
.chat-send {
  padding: 6px 10px;
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
  color: #fff;
  border: 1px solid #e88a9f;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-send:hover:not(:disabled) {
  background: linear-gradient(180deg, #e88a9f 0%, #d97088 100%);
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-exit {
  padding: 7px 10px;
  background: #faf7f8;
  color: #999;
  border: 1px solid #e8e0e4;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.chat-exit:hover {
  background: #f0e8ed;
  color: #666;
}

.chat-status {
  padding-top: 6px;
  font-size: 11px;
  color: #999;
  min-height: 16px;
}

/* ===== 右键菜单 ===== */
.context-menu {
  position: fixed;
  min-width: 140px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #f0e8ed;
  z-index: 500;
  overflow: hidden;
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  padding: 4px;
}
.context-menu.hidden { display: none; }
.context-item {
  padding: 8px 14px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  border-radius: 6px;
  transition: all .15s ease;
}
.context-item:hover {
  background: #fdf2f5;
  color: #c46a82;
}
