/* =========================================================
   AI 智能客服挂件
   与主题共用 --ink / --green / --paper 变量，换主题自动跟随
   ========================================================= */

.cs { position: fixed; right: 26px; bottom: 26px; z-index: 80; font-family: var(--sans); }

.cs-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  box-shadow: 0 18px 34px -16px rgba(11, 31, 23, .62), 0 2px 6px rgba(11, 31, 23, .18);
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
}
.cs-btn:hover { transform: translateY(-2px); box-shadow: 0 22px 40px -16px rgba(11, 31, 23, .7); }
.cs-btn svg { width: 24px; height: 24px; }
.cs-btn .cs-dot {
  position: absolute; right: 4px; top: 4px; width: 9px; height: 9px; border-radius: 50%;
  background: #35D07F; border: 2px solid #fff;
}
/* 未读人工回复 */
.cs-btn .cs-unread {
  position: absolute; right: -4px; top: -4px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 99px; background: #E0563F; color: #fff; font-size: 10.5px; font-style: normal;
  display: grid; place-items: center; border: 2px solid #fff; line-height: 1;
}
.cs-btn .cs-unread[hidden] { display: none; }
.cs-btn::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 1px solid rgba(1, 154, 69, .28); animation: cs-pulse 3.2s ease-out infinite;
}
@keyframes cs-pulse {
  0% { transform: scale(.92); opacity: .8; }
  70% { transform: scale(1.16); opacity: 0; }
  100% { opacity: 0; }
}

.cs-panel {
  position: absolute; right: 0; bottom: 72px; width: 372px; max-height: 560px;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 70px -30px rgba(11, 31, 23, .48), 0 4px 12px rgba(11, 31, 23, .06);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(10px) scale(.98);
  transform-origin: bottom right; transition: opacity .2s, transform .2s, visibility .2s;
}
.cs-panel.on { opacity: 1; visibility: visible; transform: none; }

.cs-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: var(--ink); color: #fff; flex: 0 0 auto;
}
.cs-ava {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); font-family: var(--serif); font-size: 15px;
}
.cs-head b { display: block; font-size: 14px; font-weight: 500; letter-spacing: .02em; }
.cs-head span { display: block; font-size: 11px; color: rgba(255, 255, 255, .55); margin-top: 1px; }
.cs-head .cs-x {
  margin-left: auto; width: 28px; height: 28px; border-radius: 8px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center;
}
.cs-head .cs-x:hover { background: rgba(255, 255, 255, .18); }

.cs-body {
  flex: 1; min-height: 240px; max-height: 380px; overflow-y: auto;
  padding: 16px; background: #FBFBF8; display: flex; flex-direction: column; gap: 10px;
}
.cs-body::-webkit-scrollbar { width: 6px; }
.cs-body::-webkit-scrollbar-thumb { background: #DDE3DB; border-radius: 99px; }

.cs-msg {
  max-width: 84%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}
.cs-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); color: var(--ink-2); border-bottom-left-radius: 4px; }
.cs-msg.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.cs-msg.tip {
  align-self: stretch; max-width: 100%; background: var(--mint-2); border: 1px solid var(--mint);
  color: var(--green-ink); font-size: 12.5px;
}
.cs-msg.tip a { color: var(--green-ink); text-decoration: underline; }

/* 招生老师（人工）回复 */
.cs-msg.teacher {
  align-self: flex-start; background: #fff; border: 1px solid var(--line);
  border-left: 2px solid var(--green); color: var(--ink-2); border-bottom-left-radius: 4px;
}
/* 系统提示（转人工、发送失败等） */
.cs-msg.sys {
  align-self: stretch; max-width: 100%; background: #F3F5F2; color: #6C7A70;
  font-size: 12px; text-align: center; line-height: 1.7;
}
/* 受理通知（已转人工，等老师回复） */
.cs-msg.notice {
  align-self: flex-start; background: var(--mint-2); border: 1px solid var(--mint);
  color: var(--green-ink); border-bottom-left-radius: 4px;
}

/* 等待人工回复 */
.cs-wait {
  align-self: flex-start; display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #7A8880; padding: 2px 0;
}
.cs-wait i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: cs-blink 1.2s infinite; }

/* 转人工入口 */
.cs-acts { display: flex; padding: 8px 14px 0; background: #fff; flex: 0 0 auto; }
.cs-acts[hidden] { display: none; }
.cs-human {
  border: 0; background: none; padding: 0; cursor: pointer; font-size: 12px; color: var(--green-ink);
  text-decoration: underline; text-underline-offset: 3px;
}
.cs-human:hover { color: var(--green); }
.cs-human:disabled { opacity: .5; cursor: default; }

.cs-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.cs-typing i { width: 5px; height: 5px; border-radius: 50%; background: #B6C2B7; animation: cs-blink 1.2s infinite; }
.cs-typing i:nth-child(2) { animation-delay: .18s; }
.cs-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes cs-blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.cs-chips {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; background: #fff; flex: 0 0 auto;
}
.cs-chips[hidden] { display: none; }
.cs-chips button {
  border: 1px solid var(--line); background: #fff; color: var(--body); cursor: pointer;
  font-size: 12px; padding: 6px 10px; border-radius: 99px; transition: all .16s;
}
.cs-chips button:hover { border-color: var(--green); color: var(--green-ink); background: var(--mint-2); }

.cs-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); background: #fff; flex: 0 0 auto; }
.cs-form input {
  flex: 1; min-width: 0; height: 38px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 12px; font-size: 13.5px; outline: none; background: #FBFBF8; color: var(--ink);
}
.cs-form input:focus { border-color: var(--green); background: #fff; }
.cs-form button {
  height: 38px; padding: 0 16px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--green); color: #fff; font-size: 13.5px;
}
.cs-form button:disabled { opacity: .5; cursor: default; }

@media (max-width: 760px) {
  .cs { right: 16px; bottom: 16px; }
  .cs-panel { width: calc(100vw - 32px); max-height: 72vh; right: -6px; }
  .cs-btn { width: 50px; height: 50px; }
}
