:root {
  --bg0: linear-gradient(180deg, #A7B8FF 0%, #D1DDF8 37%, #EAEDF4 100%);
  --bg1: #E6E7FD;
  --text: #1D1F1F;
  --muted: rgba(234, 240, 255, .65);
  --good: #31F2AF;
  --warn: #FFD36A;
  --bad: #FF5B7A;
  --shadow: 0 24px 80px rgba(0, 0, 0, .55);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-h: 100vh;
  --pillBtn-border: rgba(255, 255, 255, 0.20);
  --pillBtn-bg: #418AF7;
  --pillBtn-bg-hover: #15C1F6;
  --pillBtn-color: #FFFFFF;
  --rectangle-border: #418AF7;
  --send-bg: #FFFFFF;
  --placeholder-color: rgba(29, 31, 31, .5);
}

@supports (height: 100dvh) {
  :root {
    --app-h: 100dvh;
  }
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "PingFang SC", "Microsoft YaHei";
  background: var(--bg0);
  overflow: hidden;
}

/* FAB */
.chatFabIcon {
  width: 28px;
  height: 28px;
  background-image: url("/pic/ai_sci.png");
  background-size: cover;
  background-position: center;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(56, 242, 179, .16);
}

/* Modal */
.chatModal {
  position: fixed;
  inset: 0;
  display: block;
  z-index: 9998;
  /* background-image: url("/pic/bg.png");
  background-position: top;
  background-size: 100% auto;
  background-repeat: no-repeat; */
}

.chatOverlay {
  position: absolute;
  inset: 0;
}

.chatPanel {
  position: absolute;
  right: 16px;
  bottom: calc(84px + var(--safe-bottom));
  width: min(420px, calc(100vw - 32px));
  height: min(720px, calc(var(--app-h) - 120px));
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .04);
}

@media (max-width: 520px) {
  .chatPanel {
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: var(--app-h);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

.shell {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Top */
.top {
  padding: 12px 14px;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  gap: 0px;
  align-items: center;
  justify-content: center;
}

.statusDot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--good);
  margin-left: 5px;
}

.topLeft {
  min-width: 0;
  /* margin-left: 10px; */
}

.topDesc {
  font-weight: 800;
}

.topSub {
  /* margin-left: auto; */
  display: flex;
  gap: 8px;
  align-items: center;
}

.closeBtn {
  width: 0px;
  height: 0px;
}

@media (max-width:520px) {
  .top {
    padding: 10px 12px;
  }

  #statusText {
    display: none;
  }
}

/* View */
.viewPort {
  flex: 1;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.view.active {
  display: flex;
}

.msgs {
  flex: 1;
  padding: 12px;
  overflow: auto;
  scroll-behavior: smooth;
}

/* ✅ 微信上面那种居中时间条 */
.timeDivider {
  margin: 10px 0;
  display: flex;
  justify-content: center;
}

.timeDivider span {
  font-size: 12px;
  color: rgba(234, 240, 255, .55);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(0, 0, 0, .18);
  backdrop-filter: blur(10px);
}

/* Rows */
.row {
  display: flex;
  margin: 10px 0;
  gap: 8px;
  align-items: flex-start;
}

.row.bot {
  justify-content: flex-start;
}

.row.me {
  justify-content: flex-end;
}

.msgCol {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  width: 82%;
}

.row.me .bubble {
  margin-left: auto;
}

/* Bubble */
.bubble {
  width: fit-content;
  padding: 12px 12px;
  border-radius: 6px;
  background: var(--bg1);
  line-height: 1.45;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

/* ✅ AI 气泡背景：更协调（深色玻璃） */
.bot .bubble {}

/* 我：保持好看但更柔和 */
.me .bubble {
  font-size: 14px;
}

/* Quick bar */
.quickBar {
  padding: 10px 12px 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;

  /* 隐藏滚动条（Firefox） */
  &::-webkit-scrollbar {
    display: none;
    /* 隐藏滚动条（Chrome） */
  }
}

/* ✅ 优化后的按钮样式 */
.pillBtn {
  border-radius: 6px;
  border: 1px solid var(--pillBtn-border);
  background: var(--pillBtn-bg);

  color: var(--pillBtn-color);
  /* 保持白色字体 */
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  /* 增加柔和的阴影，提升立体感 */
}

.pillBtn:hover {
  /* 悬浮时边框颜色稍微加深 */
  background: var(--pillBtn-bg-hover);
  transform: translateY(-2px);
  /* 提升按钮的悬浮效果 */
}

.pillBtn--sm {
  padding: 7px 12px;
  font-size: 13px;
}

.pillBtn--ghost {
  border-radius: 6px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 提供渐变色样式（更现代） */
.pillBtn--gradient {
  border-radius: 6px;
  background: linear-gradient(135deg, #6A9DB8, #5C8DA2);
  border-color: #4E7C92;
}


/* 顶部状态小圆点 */
.pillDot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--good);
  box-shadow: 0 0 18px rgba(56, 242, 179, .55);
  display: inline-block;
}

/* 气泡里的按钮布局 */
.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btns .pillBtn {
  background: #4e89f5;
}

/* Bottom */
.bottom {
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  display: flex;
  gap: 10px;
  align-items: center;
}

.rectangle {
  border-radius: 6px;
  border: 2px solid var(--rectangle-border);
  background: transparent;
  padding: 4px 7px;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  align-items: center;
}

.input {
  flex: 1;
  border-radius: 6px;
  padding: 12px 14px 12px 10px;
  outline: none;
  font-size: 14px;
  color: var(--text);
  border: none;
  background: none;
}

.input::placeholder {
  color: var(--placeholder-color);
}

.send {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s ease, filter .15s ease;
  white-space: nowrap;
  margin-left: 4px;
  background: var(--send-bg);
}

.send:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.send:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* To bottom */
.toBottom {
  position: absolute;
  right: 12px;
  bottom: calc(94px + var(--safe-bottom));
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .30);
  color: rgba(234, 240, 255, .85);
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  display: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

/* Avatar（不依赖外网） */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  flex: 0 0 auto;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .20);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.avatar--user {
  background-image: url("/pic/user.png");
}

.avatar--ai {
  background-image: url("/pic/ai_sci.png");
}

.avatar--agent {
  background-image: url("/pic/agent_female.png");
}

/* Thinking */
.typingLine {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(234, 240, 255, .65);
  animation: bob 1s infinite ease-in-out;
}

.dot:nth-child(2) {
  animation-delay: .12s;
}

.dot:nth-child(3) {
  animation-delay: .24s;
}

@keyframes bob {

  0%,
  100% {
    transform: translateY(0);
    opacity: .55;
  }

  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

/* ================================
   聊天消息区滚动条美化
   作用于 #aiMsgs / #huMsgs
   ================================ */

/* Chrome / Edge / Safari */
#aiMsgs::-webkit-scrollbar,
#huMsgs::-webkit-scrollbar {
  width: 6px;
}

#aiMsgs::-webkit-scrollbar-track,
#huMsgs::-webkit-scrollbar-track {
  background: transparent;
}

#aiMsgs::-webkit-scrollbar-thumb,
#huMsgs::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}

#aiMsgs::-webkit-scrollbar-thumb:hover,
#huMsgs::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.45);
}

/* Firefox */
#aiMsgs,
#huMsgs {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;

}

#toggleBtn {
  display: none;
}

#toggleBtn.active {
  display: inline-flex;
  /* 或 inline-block / block，按你布局 */
}

html.rtl {
  direction: rtl;
}

html.rtl body {
  text-align: right;
}

html.rtl input,
html.rtl textarea {
  text-align: right;
}

html.rtl .aiMsgs {
  flex-direction: row-reverse;
}

/* 顶部联系方式 */
.contactBox {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 8px;
  font-size: 12px;
  line-height: 1.2;
}

.contactItem {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  margin-bottom: 2px;
  white-space: nowrap;
}

.contactItem:hover {
  color: #ffffff;
  text-decoration: underline;
}

.contactBtn {
  background: #f1e6ff;
  border: none;
  border-radius: 8px;
  color: #8f4dde;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Noto Sans SC";
  width: 0px;
}

.contactBtn:hover {
  transform: scale(1.05);
  /* 鼠标悬停时放大 */
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  /* 更强的阴影效果 */
}

.contactBtn:active {
  transform: scale(0.98);
  /* 点击时缩小 */
}

.view {
  transition: opacity 0.3s ease-in-out;
}

.timestamp {
  font-size: 12px;
  color: var(--text);
  text-align: center;
  margin: 0 auto 10px;
  /* 增加底部间距 */
  display: inline-block;
  /* 使时间戳和气泡紧密包裹 */
  padding: 5px 10px;
  /* 给时间戳添加一些内边距 */
  border-radius: 20px;
  /* 创建小气泡效果 */
  /* font-weight: bold; */
  /* 让时间戳更突出 */
  position: relative;
  max-width: 80%;
  /* 限制时间戳的最大宽度 */
  min-width: 30px;
}

/* 确保时间戳样式在聊天框中的位置 */
.chat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#fileInput {
  display: none;
}