#cs-root, #cs-root * { box-sizing: border-box; }
#cs-root {
  --cs-main: #0f766e; --cs-deep: #102a2a; --cs-soft: #e8f5f2; --cs-line: #dce8e5;
  --cs-muted: #6b7d79; --cs-danger: #c2413b;
  position: fixed; right: 22px; bottom: 22px; z-index: 2147483000;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18312d; font-size: 14px;
}
.cs-launcher {
  height: 54px; min-width: 132px; padding: 0 19px; border: 0; border-radius: 28px;
  color: #fff; background: linear-gradient(135deg, #159485, var(--cs-main)); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 700;
  box-shadow: 0 14px 38px rgba(15,118,110,.32); transition: transform .2s, box-shadow .2s;
}
.cs-launcher:hover { transform: translateY(-2px); box-shadow: 0 17px 42px rgba(15,118,110,.38); }
.cs-launcher-icon { font-size: 20px; line-height: 1; }
.cs-badge {
  position: absolute; right: -3px; top: -5px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 12px; background: #ef4444; color: #fff; border: 2px solid #fff;
  font-size: 11px; display: none; align-items: center; justify-content: center; font-weight: 800;
}
.cs-badge.show { display: flex; }
.cs-window {
  position: absolute; right: 0; bottom: 66px; width: min(380px, calc(100vw - 28px)); height: min(590px, calc(100vh - 115px));
  border-radius: 20px; overflow: hidden; background: #fff; border: 1px solid rgba(15,118,110,.13);
  box-shadow: 0 24px 72px rgba(13,42,38,.24); display: none; flex-direction: column;
  transform-origin: right bottom;
}
.cs-window.show { display: flex; animation: cs-pop .2s ease-out; }
@keyframes cs-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.cs-head {
  min-height: 72px; padding: 15px 16px; color: #fff; background: linear-gradient(125deg, #103b38, #0f766e);
  display: flex; align-items: center; gap: 11px;
}
.cs-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.16); font-size: 20px; }
.cs-head-copy { flex: 1; min-width: 0; }
.cs-title { font-weight: 800; font-size: 16px; }
.cs-presence { margin-top: 3px; font-size: 12px; color: rgba(255,255,255,.8); }
.cs-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #61e6b6; box-shadow: 0 0 0 3px rgba(97,230,182,.14); }
.cs-icon-btn { border: 0; background: transparent; color: inherit; width: 32px; height: 32px; border-radius: 9px; cursor: pointer; font-size: 21px; }
.cs-icon-btn:hover { background: rgba(255,255,255,.12); }
.cs-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 17px 14px; background: #f7faf9; scroll-behavior: smooth; }
.cs-welcome { margin: 4px auto 18px; max-width: 290px; text-align: center; color: var(--cs-muted); font-size: 12px; line-height: 1.65; }
.cs-message { display: flex; margin: 10px 0; }
.cs-message.mine { justify-content: flex-end; }
.cs-bubble { max-width: 82%; padding: 10px 12px; border-radius: 14px 14px 14px 4px; background: #fff; border: 1px solid var(--cs-line); line-height: 1.55; white-space: pre-wrap; word-break: break-word; box-shadow: 0 2px 7px rgba(21,54,48,.04); }
.cs-message.mine .cs-bubble { color: #fff; background: var(--cs-main); border-color: var(--cs-main); border-radius: 14px 14px 4px 14px; }
.cs-message-meta { margin-top: 5px; display: flex; align-items: center; justify-content: flex-end; gap: 7px; font-size: 11px; white-space: nowrap; }
.cs-time { opacity: .78; text-align: right; }
.cs-message:not(.mine) .cs-time { color: #71817e; opacity: 1; }
.cs-read-state { opacity: .66; font-size: 10px; }
.cs-read-state.read { opacity: 1; font-weight: 750; }
.cs-ai-tag { margin-bottom: 4px; font-size: 10px; font-weight: 800; opacity: .72; letter-spacing: .04em; }
.cs-admin .cs-message.ai .cs-bubble { background: #e7f4f1; color: #16443e; border-color: #c3e2dc; }
.cs-compose { flex: 0 0 auto; border-top: 1px solid var(--cs-line); background: #fff; padding: 11px; display: flex; gap: 8px; align-items: flex-end; }
.cs-input { flex: 1; min-height: 42px; max-height: 112px; resize: none; border: 1px solid var(--cs-line); border-radius: 13px; padding: 10px 11px; outline: 0; font: inherit; line-height: 1.45; }
.cs-input:focus { border-color: var(--cs-main); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.cs-send { height: 42px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--cs-main); color: #fff; font-weight: 700; cursor: pointer; }
.cs-send:disabled { opacity: .5; cursor: wait; }
.cs-error { min-height: 0; padding: 0 13px; color: var(--cs-danger); font-size: 11px; background: #fff; }

/* 管理员工作台 */
#cs-root.cs-admin { display: none; }
#cs-root.cs-admin.ready { display: block; }
.cs-admin .cs-launcher { min-width: 148px; }
.cs-admin .cs-window { width: min(820px, calc(100vw - 35px)); height: min(650px, calc(100vh - 105px)); }
.cs-admin .cs-head { color: #142d29; background: #eef5f3; border-bottom: 1px solid var(--cs-line); }
.cs-admin .cs-head .cs-presence { color: #526b66; }
.cs-admin .cs-head .cs-avatar { color: #142d29; background: #dcece8; }
.cs-admin .cs-head .cs-icon-btn { color: #142d29; }
.cs-admin .cs-head .cs-icon-btn:hover { background: rgba(15,118,110,.09); }
.cs-admin .cs-head .cs-remind-btn { color: #142d29; border-color: #bdd5d0; background: #fff; }
.cs-admin-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px 1fr; background: #fff; }
.cs-conversations { min-width: 0; border-right: 1px solid var(--cs-line); overflow-y: auto; background: #f8faf9; }
.cs-conv-empty, .cs-chat-empty { padding: 35px 18px; text-align: center; color: var(--cs-muted); line-height: 1.7; }
.cs-conv { width: 100%; border: 0; border-bottom: 1px solid var(--cs-line); padding: 13px 14px; text-align: left; background: transparent; cursor: pointer; color: inherit; }
.cs-conv:hover, .cs-conv.active { background: #eaf5f2; }
.cs-conv-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.cs-conv-name { font-weight: 750; }
.cs-conv-time { color: var(--cs-muted); font-size: 10px; white-space: nowrap; }
.cs-conv-preview { margin-top: 5px; color: var(--cs-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-conv-unread { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: #ef4444; font-size: 10px; }
.cs-admin-chat { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.cs-admin-subhead { flex: 0 0 auto; min-height: 48px; padding: 8px 13px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--cs-line); }
.cs-admin-meta { color: var(--cs-muted); font-size: 11px; max-width: 330px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-admin-actions { display: flex; align-items: center; gap: 6px; }
.cs-ai-toggle { border: 1px solid var(--cs-line); border-radius: 9px; padding: 6px 9px; color: var(--cs-muted); background: #fff; cursor: pointer; font-size: 11px; }
.cs-ai-toggle.active { color: #fff; border-color: var(--cs-main); background: var(--cs-main); }
.cs-ai-toggle:disabled { cursor: not-allowed; opacity: .6; }
.cs-remind-btn, .cs-close-conv { border: 1px solid rgba(255,255,255,.25); border-radius: 9px; padding: 6px 9px; color: #fff; background: rgba(255,255,255,.1); cursor: pointer; font-size: 11px; }
.cs-close-conv { color: var(--cs-muted); border-color: var(--cs-line); background: #fff; }
@media (max-width: 650px) {
  #cs-root { right: 14px; bottom: 14px; }
  .cs-launcher { min-width: 54px; width: 54px; padding: 0; }
  .cs-launcher-label { display: none; }
  .cs-window { bottom: 64px; }
  .cs-admin .cs-window { width: calc(100vw - 20px); right: -4px; }
  .cs-admin-body { grid-template-columns: 120px 1fr; }
  .cs-conv { padding: 11px 8px; }
  .cs-conv-time, .cs-conv-preview { display: none; }
}
