/* ===== 右下角在线客服（可拖动 + 新回复提醒） ===== */
.cs-btn {
  position: fixed; right: 22px; bottom: 24px; z-index: 900;
  width: 58px; height: 58px; border: 0; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; touch-action: none;
  background: linear-gradient(135deg, #123a5f, #1857a4);
  box-shadow: 0 12px 28px rgba(12, 40, 67, .28), 0 0 0 1px rgba(255, 255, 255, .12) inset;
  transition: transform .18s ease, box-shadow .18s ease;
}
.cs-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(12, 40, 67, .34); }
.cs-btn:active { transform: scale(.95); }
.cs-btn:focus-visible { outline: 3px solid rgba(195, 154, 78, .7); outline-offset: 3px; }
.cs-btn.is-moving { transition: none; cursor: grabbing; }

.cs-badge {
  position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #e04b3a; color: #fff;
  font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center;
  box-shadow: 0 2px 6px rgba(224, 75, 58, .55); font-family: -apple-system, "Segoe UI", sans-serif;
}

/* 面板 */
.cs-panel {
  position: fixed; right: 22px; bottom: 94px; z-index: 900;
  width: 352px; max-width: calc(100vw - 24px); height: 522px; max-height: calc(100vh - 120px);
  display: flex; flex-direction: column; overflow: hidden; background: #fff;
  border-radius: 18px; box-shadow: 0 26px 64px rgba(12, 40, 67, .24), 0 0 0 1px rgba(12, 40, 67, .06);
  animation: cs-in .22s cubic-bezier(.2, .8, .3, 1);
}
.cs-panel[hidden] { display: none; }
.cs-panel.is-moving { animation: none; }

.cs-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px;
  background: linear-gradient(135deg, #0c2843, #123a5f); color: #fff;
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
}
.cs-head:active { cursor: grabbing; }
.cs-head-ava {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #c39a4e, #e0bf80); color: #3a2a08;
  font-weight: 700; font-size: 15px;
}
.cs-head-txt { flex: 1; min-width: 0; line-height: 1.35; }
.cs-head-txt strong { display: block; font-size: 14.5px; font-weight: 700; letter-spacing: .2px; }
.cs-head-txt small { display: block; font-size: 11.5px; color: #b7cde2; }
.cs-new {
  display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 8px;
  background: #c39a4e; color: #241a05; font-size: 10.5px; font-weight: 700;
  vertical-align: 2px; animation: cs-blink 1s ease-in-out infinite;
}
.cs-new[hidden] { display: none; }
.cs-head-ops { display: flex; gap: 2px; flex: 0 0 auto; }
.cs-mini {
  width: 30px; height: 30px; border: 0; border-radius: 8px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .1); color: #e7eef5; cursor: pointer;
  transition: background .15s ease;
}
.cs-mini:hover { background: rgba(255, 255, 255, .22); }
.cs-mini .cs-slash { display: none; }
#csMute.is-muted .cs-slash { display: inline; }
#csMute.is-muted { color: #f2b8ad; }

/* 消息区 */
.cs-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; background: #f6f8fb; padding: 14px 14px 4px; }
.cs-body::-webkit-scrollbar { width: 6px; }
.cs-body::-webkit-scrollbar-thumb { background: #d3dde8; border-radius: 3px; }
.cs-day { text-align: center; font-size: 11px; color: #93a3b6; margin-bottom: 12px; letter-spacing: .5px; }
.cs-list { display: flex; flex-direction: column; }
.cs-msg { display: flex; margin-bottom: 12px; animation: cs-pop .26s cubic-bezier(.2, .8, .3, 1); }
.cs-msg--me { justify-content: flex-end; }
.cs-item { max-width: 82%; }
.cs-bubble {
  padding: 9px 12px; border-radius: 13px; font-size: 13.5px; line-height: 1.68;
  white-space: pre-wrap; word-break: break-word;
  background: #fff; border: 1px solid #e3e9f0; color: #2b3a4a;
  border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(12, 40, 67, .04);
}
.cs-msg--me .cs-bubble {
  background: #1857a4; border-color: #1857a4; color: #fff;
  border-bottom-left-radius: 13px; border-bottom-right-radius: 5px;
}
.cs-time { font-size: 10.5px; color: #9aabbd; margin-top: 5px; padding: 0 3px; }
.cs-msg--me .cs-time { text-align: right; }
.cs-bubble--new { animation: cs-glow 1.5s ease-in-out 3; }

/* 首次咨询需要手机号 */
.cs-profile { padding: 10px 12px 0; background: #fff; border-top: 1px solid #eef2f7; }
.cs-profile[hidden] { display: none; }
.cs-profile-row { display: flex; gap: 8px; }
.cs-profile-row input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px; font-size: 13px;
  border: 1px solid #e3e9f0; border-radius: 9px; background: #fbfcfe; outline: none;
}
.cs-profile-row input:focus { border-color: #1857a4; background: #fff; box-shadow: 0 0 0 3px rgba(24, 87, 164, .1); }

/* 输入区 */
.cs-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; background: #fff; }
.cs-form textarea {
  flex: 1; min-width: 0; min-height: 42px; max-height: 104px; resize: none;
  padding: 10px 11px; font-size: 13.5px; line-height: 1.5; color: #2b3a4a;
  border: 1px solid #e3e9f0; border-radius: 11px; background: #fbfcfe; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cs-form textarea:focus { border-color: #1857a4; background: #fff; box-shadow: 0 0 0 3px rgba(24, 87, 164, .1); }
.cs-send {
  width: 42px; height: 42px; flex: 0 0 42px; border: 0; border-radius: 11px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: #1857a4; color: #fff; cursor: pointer; transition: background .15s ease, transform .15s ease;
}
.cs-send:hover { background: #123a5f; }
.cs-send:active { transform: scale(.96); }
.cs-send:disabled { opacity: .55; cursor: not-allowed; }
.cs-tip { padding: 0 14px 9px; font-size: 12px; color: #c0392b; background: #fff; }
.cs-tip:empty { display: none; }

/* 提醒动画 */
.cs-btn.is-alert { animation: cs-shake .62s ease-in-out 3; }
.cs-btn.is-alert::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  animation: cs-ring 1.5s ease-out infinite;
}
.cs-panel.is-alert .cs-head { animation: cs-flash 1.1s ease-in-out infinite; }

@keyframes cs-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes cs-pop { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes cs-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes cs-shake {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0); }
  15% { transform: translate3d(-4px, 0, 0) rotate(-7deg); }
  30% { transform: translate3d(4px, 0, 0) rotate(7deg); }
  45% { transform: translate3d(-3px, 0, 0) rotate(-5deg); }
  60% { transform: translate3d(3px, 0, 0) rotate(5deg); }
  75% { transform: translate3d(-1px, 0, 0) rotate(-2deg); }
}
@keyframes cs-ring {
  0% { box-shadow: 0 0 0 0 rgba(195, 154, 78, .65); }
  70% { box-shadow: 0 0 0 18px rgba(195, 154, 78, 0); }
  100% { box-shadow: 0 0 0 0 rgba(195, 154, 78, 0); }
}
@keyframes cs-flash {
  0%, 100% { background: linear-gradient(135deg, #0c2843, #123a5f); }
  50% { background: linear-gradient(135deg, #8a6a24, #c39a4e); }
}
@keyframes cs-glow {
  0%, 100% { box-shadow: 0 1px 2px rgba(12, 40, 67, .04); }
  50% { box-shadow: 0 0 0 4px rgba(195, 154, 78, .35); }
}

@media (max-width: 560px) {
  .cs-btn { right: 14px; bottom: 16px; width: 54px; height: 54px; }
  .cs-panel {
    right: 10px; left: auto; bottom: 84px;
    width: calc(100vw - 20px); height: auto; max-height: 72vh;
  }
  .cs-panel .cs-body { max-height: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-btn.is-alert, .cs-panel.is-alert .cs-head, .cs-new, .cs-msg, .cs-bubble--new, .cs-btn.is-alert::after {
    animation: none;
  }
}
