/*! 歌沐娜智能客服浮层 · cs-widget.css  v1.0.0
 * 独立组件：全部类名统一 sgcs- 前缀，CSS 变量只定义在 .sgcs-root 作用域内，
 * 不写 :root、不写裸标签选择器，因此不会污染或覆盖宿主页面的任何样式。
 * 配色沿用官网品牌色 #2b7cf0 / #6fa5f5。
 */

.sgcs-root,
.sgcs-root * { box-sizing: border-box; margin: 0; padding: 0; }

.sgcs-root {
  --sgcs-brand: #2b7cf0;
  --sgcs-brand2: #6fa5f5;
  --sgcs-text: #2f3540;
  --sgcs-sub: #6b7688;
  --sgcs-sub2: #8792a3;
  --sgcs-line: #dce7f5;
  --sgcs-line2: #e8f0fa;
  --sgcs-bg: #ffffff;
  --sgcs-bg2: #f6f9fe;
  --sgcs-shadow: 0 18px 46px rgba(24, 60, 120, .18);

  position: relative;
  z-index: 9990;
  color: var(--sgcs-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-align: left;
}
.sgcs-root :focus-visible { outline: 2px solid var(--sgcs-brand); outline-offset: 2px; }

/* ---------- 右下角悬浮入口 ---------- */
.sgcs-launcher {
  position: fixed; right: 22px; bottom: 22px; z-index: 9991;
  width: 58px; height: 58px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; line-height: 0; cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #2b7cf0, #6fa5f5);
  box-shadow: 0 10px 26px rgba(43, 124, 240, .42);
  transition: transform .22s cubic-bezier(.2, .8, .3, 1), box-shadow .22s;
}
.sgcs-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 32px rgba(43, 124, 240, .5); }
.sgcs-launcher:active { transform: scale(.96); }
.sgcs-launcher svg { display: block; max-width: none; width: 27px; height: 27px; }
.sgcs-launcher .sgcs-ic-x { display: none; width: 22px; height: 22px; }
.sgcs-root.is-open .sgcs-launcher .sgcs-ic-chat { display: none; }
.sgcs-root.is-open .sgcs-launcher .sgcs-ic-x { display: block; }

/* 呼吸光环：提示可点，鼠标悬停即消失 */
.sgcs-launcher::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(43, 124, 240, .45);
  pointer-events: none;
  animation: sgcsPulse 2.8s ease-out infinite;
}
.sgcs-root.is-open .sgcs-launcher::after,
.sgcs-launcher:hover::after { animation: none; opacity: 0; }
@keyframes sgcsPulse {
  0%   { transform: scale(.92); opacity: .85; }
  70%  { transform: scale(1.24); opacity: 0; }
  100% { transform: scale(1.24); opacity: 0; }
}

/* ---------- 浮层面板 ---------- */
.sgcs-panel {
  position: fixed; right: 22px; bottom: 94px; z-index: 9992;
  width: 392px;
  height: min(620px, calc(100vh - 132px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sgcs-bg);
  border: 1px solid var(--sgcs-line);
  border-radius: 18px;
  box-shadow: var(--sgcs-shadow);
  transform-origin: 100% 100%;
  opacity: 0; transform: translateY(14px) scale(.96); pointer-events: none;
  transition: opacity .24s ease, transform .28s cubic-bezier(.18, .9, .28, 1.06);
}
.sgcs-root.is-open .sgcs-panel { opacity: 1; transform: none; pointer-events: auto; }
.sgcs-panel[hidden] { display: none !important; }

/* 头部 */
.sgcs-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 11px;
  padding: 13px 15px; color: #fff;
  background: linear-gradient(135deg, #2b7cf0, #5f9df3);
}
.sgcs-av {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center; font-size: 15px; font-weight: 700; color: #fff;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .35);
}
.sgcs-tt { flex: 1 1 auto; min-width: 0; }
.sgcs-tt b { display: block; font-size: 15px; font-weight: 700; letter-spacing: .2px; color: #fff; }
.sgcs-tt i { display: flex; align-items: center; gap: 5px; font-style: normal; font-size: 11.5px; color: #fff; opacity: .93; }
.sgcs-tt i em { width: 6px; height: 6px; border-radius: 50%; background: #7ef2b0; box-shadow: 0 0 0 3px rgba(126, 242, 176, .28); }
.sgcs-x {
  flex: 0 0 30px; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 9px;
  display: grid; place-items: center; cursor: pointer;
  font-size: 19px; line-height: 1; color: #fff;
  background: rgba(255, 255, 255, .16);
  transition: background .16s;
}
.sgcs-x:hover { background: rgba(255, 255, 255, .3); }

/* 消息区 */
.sgcs-body {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 15px 15px 6px;
  background: linear-gradient(180deg, #fbfdff, #ffffff);
}
.sgcs-body::-webkit-scrollbar { width: 8px; }
.sgcs-body::-webkit-scrollbar-thumb { background: #d6e3f3; border-radius: 8px; }
.sgcs-body::-webkit-scrollbar-thumb:hover { background: #bcd2ec; }

.sgcs-msg { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 13px; }
.sgcs-msg .sgcs-who {
  flex: 0 0 29px; width: 29px; height: 29px; border-radius: 9px;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
}
.sgcs-msg .sgcs-bub {
  max-width: calc(100% - 42px);
  padding: 10px 13px; border-radius: 12px;
  font-size: 14.2px; line-height: 1.72;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.sgcs-msg.sgcs-bot .sgcs-who { color: #fff; background: linear-gradient(135deg, #2b7cf0, #6fa5f5); }
.sgcs-msg.sgcs-bot .sgcs-bub {
  color: var(--sgcs-text); background: #fff;
  border: 1px solid var(--sgcs-line); border-top-left-radius: 4px;
}
.sgcs-msg.sgcs-me { flex-direction: row-reverse; }
.sgcs-msg.sgcs-me .sgcs-who { color: var(--sgcs-sub); background: var(--sgcs-bg2); border: 1px solid var(--sgcs-line); }
.sgcs-msg.sgcs-me .sgcs-bub {
  color: #fff; background: linear-gradient(135deg, #2b7cf0, #5f9df3); border-top-right-radius: 4px;
}
.sgcs-msg.sgcs-err .sgcs-bub { color: #c0394b; background: #fff5f6; border-color: #f6ccd2; }
.sgcs-bub b { font-weight: 700; }
.sgcs-bub code {
  padding: 1px 6px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.6px;
  color: #1b5fc4; background: var(--sgcs-bg2); border: 1px solid var(--sgcs-line);
}
.sgcs-msg.sgcs-me .sgcs-bub code { color: #fff; background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .3); }

/* 输入中动画 */
.sgcs-typing { display: inline-flex; align-items: center; gap: 4px; height: 18px; }
.sgcs-typing i { width: 6px; height: 6px; border-radius: 50%; background: #9fb6d4; animation: sgcsTyp 1.2s ease-in-out infinite; }
.sgcs-typing i:nth-child(2) { animation-delay: .16s; }
.sgcs-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes sgcsTyp {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* 快捷问题 */
.sgcs-chips { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 7px; padding: 4px 15px 10px; background: #fff; }
.sgcs-chips button {
  padding: 6px 12px; border: 1px solid var(--sgcs-line); border-radius: 999px;
  font-family: inherit; font-size: 12.6px; line-height: 1.5; color: var(--sgcs-sub);
  background: #fff; cursor: pointer; transition: .16s;
}
.sgcs-chips button:hover { color: var(--sgcs-brand); border-color: var(--sgcs-brand); background: var(--sgcs-bg2); }

/* 输入区 */
.sgcs-foot { flex: 0 0 auto; padding: 11px 13px 12px; background: #fff; border-top: 1px solid var(--sgcs-line2); }
.sgcs-box {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 7px 7px 7px 12px;
  background: #fff; border: 1px solid var(--sgcs-line); border-radius: 13px;
  transition: .18s;
}
.sgcs-box:focus-within { border-color: var(--sgcs-brand); box-shadow: 0 0 0 3px rgba(43, 124, 240, .1); }
.sgcs-box textarea {
  flex: 1 1 auto; display: block; width: 100%;
  max-height: 96px; padding: 3px 0; border: 0; outline: none; resize: none;
  font-family: inherit; font-size: 14.2px; line-height: 1.6; color: var(--sgcs-text);
  background: transparent;
}
.sgcs-box textarea::placeholder { color: #a8b3c2; }
.sgcs-send {
  flex: 0 0 34px; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #2b7cf0, #6fa5f5);
  transition: .18s;
}
.sgcs-send svg { display: block; max-width: none; width: 17px; height: 17px; }
.sgcs-send:disabled { opacity: .42; cursor: not-allowed; }
.sgcs-send:not(:disabled):hover { transform: translateY(-1px); }

.sgcs-tip {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  margin-top: 8px; font-size: 11.8px; color: var(--sgcs-sub2);
}
.sgcs-tip b { color: var(--sgcs-brand); }
.sgcs-tip a { color: var(--sgcs-brand); text-decoration: none; }
.sgcs-tip a:hover { text-decoration: underline; }

.sgcs-warn {
  display: none; margin-top: 8px; padding: 8px 10px;
  font-size: 11.8px; line-height: 1.6; color: #8a6410;
  background: #fffaf0; border: 1px solid #f0e0bd; border-radius: 9px;
}
.sgcs-warn.is-show { display: block; }

/* ---------- 手机端：自适应全屏 ---------- */
@media (max-width: 680px) {
  .sgcs-panel {
    left: 0; right: 0; top: 0; bottom: 0;
    width: auto; height: auto;
    border: 0; border-radius: 0;
    z-index: 9999;
  }
  .sgcs-root.is-open .sgcs-panel { transform: none; }
  .sgcs-launcher { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .sgcs-msg .sgcs-bub { font-size: 14.6px; }
  .sgcs-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 12px; }
  .sgcs-chips button { flex: 0 0 auto; white-space: nowrap; }
  .sgcs-chips::-webkit-scrollbar { height: 0; }
}

/* ---------- 无障碍：尊重系统「减弱动态效果」 ---------- */
@media (prefers-reduced-motion: reduce) {
  .sgcs-launcher, .sgcs-panel, .sgcs-send { transition: none; }
  .sgcs-launcher::after { animation: none; opacity: 0; }
  .sgcs-typing i { animation-duration: 1.8s; }
}
