/* Live2D 看板娘 · AI 聊天面板（v1） */

/* 位置默认贴右下角，chat.js 拿到 #waifu-web 的真实矩形后会改成「贴着模型旁边」。 */
#kl2d-chat-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #9BE3C9, #BFE3F5);
  box-shadow: 0 6px 18px rgba(61, 190, 150, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
#kl2d-chat-btn:hover { transform: translateY(-2px); box-shadow: 0 9px 22px rgba(61, 190, 150, .42); }
#kl2d-chat-btn svg { width: 24px; height: 24px; }
#kl2d-chat-btn[data-side="left"] { left: 24px; right: auto; }

#kl2d-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 84px;
  z-index: 9998;
  width: 320px;
  max-height: min(62vh, 460px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #E4F4ED;
  border-radius: 18px;
  box-shadow: 0 16px 42px rgba(31, 84, 66, .16);
  overflow: hidden;
  font-size: 14px;
  line-height: 1.6;
  color: #2b3b36;
}
#kl2d-chat-panel[hidden] { display: none; }
#kl2d-chat-panel[data-side="left"] { left: 24px; right: auto; }

#kl2d-chat-panel header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #EAF9F2, #EAF4FB);
  border-bottom: 1px solid #E4F4ED;
}
.kl2d-chat-title { font-weight: 600; color: #2f6b57; letter-spacing: .02em; }
#kl2d-chat-close {
  border: 0; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; color: #8aa89c; padding: 2px 4px; border-radius: 8px;
}
#kl2d-chat-close:hover { background: rgba(0, 0, 0, .05); color: #4a6b60; }

#kl2d-chat-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 0 4px;
  scroll-behavior: smooth;
  /* Firefox：细条 + 薄荷色 */
  scrollbar-width: thin;
  scrollbar-color: #CDEBDD transparent;
}
/* WebKit：透明轨道 + 圆角薄荷滑块，两侧留 2px 内缩，不贴边 */
#kl2d-chat-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
#kl2d-chat-list::-webkit-scrollbar-track {
  background: transparent;
  border: 0;
}
#kl2d-chat-list::-webkit-scrollbar-thumb {
  background-color: #D2EFE2;
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
  transition: background-color .18s ease;
}
#kl2d-chat-list:hover::-webkit-scrollbar-thumb {
  background-color: #A9DCC7;
}
#kl2d-chat-list::-webkit-scrollbar-thumb:hover {
  background-color: #7FCCB0;
}
#kl2d-chat-list::-webkit-scrollbar-corner {
  background: transparent;
}

.kl2d-msg { display: flex; margin: 6px 12px; }
.kl2d-msg--user { justify-content: flex-end; }
.kl2d-msg--assistant { justify-content: flex-start; }
.kl2d-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.kl2d-msg--user .kl2d-bubble {
  background: linear-gradient(135deg, #9BE3C9, #8FDCC8);
  color: #123f33;
  border-bottom-right-radius: 6px;
}
.kl2d-msg--assistant .kl2d-bubble {
  background: #F5FBF8;
  color: #263832;
  border: 1px solid #E9F5EF;
  border-bottom-left-radius: 6px;
}
.kl2d-msg--error .kl2d-bubble {
  background: #FFF3F1;
  border-color: #FBDDD6;
  color: #a2503f;
}

.kl2d-dots { display: inline-flex; gap: 3px; align-items: center; height: 18px; }
.kl2d-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: #9cc9b8;
  animation: kl2d-blink 1.1s infinite ease-in-out;
}
.kl2d-dots i:nth-child(2) { animation-delay: .16s; }
.kl2d-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes kl2d-blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

#kl2d-chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px 12px;
  border-top: 1px solid #EFF7F3;
  background: #FBFEFC;
}
#kl2d-chat-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 96px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: #263832;
  border: 1px solid #DCEFE6;
  border-radius: 12px;
  background: #fff;
  outline: none;
}
#kl2d-chat-input:focus { border-color: #9BE3C9; box-shadow: 0 0 0 3px rgba(155, 227, 201, .22); }
#kl2d-chat-send {
  flex: 0 0 auto;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  color: #fff;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, #63CDA9, #7DC9E8);
}
#kl2d-chat-send[disabled] { opacity: .55; cursor: default; }

/* 游客且后台关了游客额度：底部换成提示 + 登录入口 */
#kl2d-chat-panel[data-locked="1"] #kl2d-chat-list {
  flex: 0 0 auto;
  padding: 10px 0 0;
}
.kl2d-chat-lock {
  flex: 0 0 auto;
  padding: 14px 14px 16px;
  border-top: 1px solid #EFF7F3;
  background: #FBFEFC;
  text-align: center;
}
.kl2d-chat-lock p {
  margin: 0 0 10px;
  font-size: 13px;
  color: #6b8579;
}
.kl2d-chat-login {
  display: inline-block;
  padding: 7px 22px;
  font-size: 13px;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #63CDA9, #7DC9E8);
  box-shadow: 0 4px 12px rgba(99, 205, 169, .28);
  transition: transform .16s ease, box-shadow .16s ease;
}
.kl2d-chat-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 205, 169, .36);
  color: #fff;
}

@media (max-width: 767px) {
  #kl2d-chat-btn, #kl2d-chat-panel { display: none !important; }
}
