/* ============================================================================
   在线客服 · 前台悬浮窗（首页 / 用户中心 / 素材页共用）
   ----------------------------------------------------------------------------
   配色跟 heima 玻璃皮肤一套：主色 #007aff 只做「填充」，凡是白字压在上面
   一律用 #0050c8（白字对 #007aff 只有 3.86:1，对 #0050c8 是 7.04:1）。
   层级：悬浮球 1290，聊天室抽屉 1300 压在上面，Bootstrap 弹层 1050 在下面。
   ========================================================================== */

.hm-kefu {
  --kf-blue: var(--hm-blue, #007aff);
  --kf-ink: var(--hm-ink, #1c2530);
  --kf-ink-2: var(--hm-ink-2, #55617a);
  --kf-ink-3: var(--hm-ink-3, #8a93a6);
  --kf-hair: var(--hm-hair, rgba(120, 140, 170, .18));
  --kf-ink-btn: #0050c8;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1290;
  font-family: inherit;
  color: var(--kf-ink);
}

/* ── 悬浮球 ─────────────────────────────────────────────────────────────── */
.hm-kefu-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #1b86ff 0%, #007aff 55%, #0069db 100%);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(0, 63, 140, .62), 0 2px 6px rgba(10, 40, 80, .16);
  transition: transform .18s ease, box-shadow .18s ease;
}

.hm-kefu-fab:hover,
.hm-kefu-fab:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px -12px rgba(0, 63, 140, .7), 0 3px 8px rgba(10, 40, 80, .18);
  outline: none;
}

.hm-kefu-fab:active {
  transform: translateY(0) scale(.97);
}

.hm-kefu-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .92);
}

/* ── 面板 ───────────────────────────────────────────────────────────────── */
.hm-kefu-panel {
  position: absolute;
  right: 0;
  bottom: 66px;
  display: flex;
  flex-direction: column;
  width: 348px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 110px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 24px 60px -28px rgba(23, 42, 73, .5), 0 2px 10px rgba(23, 42, 73, .08);
  transform-origin: 100% 100%;
  animation: hm-kefu-in .18s ease-out;
}

.hm-kefu-panel[hidden] {
  display: none !important;
}

@keyframes hm-kefu-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hm-kefu-panel {
    animation: none;
  }

  .hm-kefu-fab {
    transition: none;
  }
}

/* 头 */
.hm-kefu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #eef6ff 0%, #e6f1ff 100%);
  border-bottom: 1px solid var(--kf-hair);
}

.hm-kefu-ava {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--kf-ink-btn);
  color: #fff;
  font-size: 16px;
  flex: 0 0 auto;
}

.hm-kefu-tt {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.hm-kefu-tt b {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--kf-ink);
}

.hm-kefu-tt em {
  font-style: normal;
  font-size: 12px;
  color: var(--kf-ink-3);
  line-height: 1.4;
}

.hm-kefu-x {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .72);
  color: var(--kf-ink-2);
  font-size: 14px;
  cursor: pointer;
}

.hm-kefu-x:hover {
  background: #fff;
  color: var(--kf-ink);
}

/* 身体 */
.hm-kefu-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: linear-gradient(180deg, #f7fbff 0%, #f2f7fd 100%);
  -webkit-overflow-scrolling: touch;
}

.hm-kefu-hello p {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--kf-hair);
  color: var(--kf-ink);
  font-size: 13.5px;
  line-height: 1.65;
}

.hm-kefu-ctc {
  color: var(--kf-ink-2) !important;
  background: #f4f8fd !important;
  font-size: 12.5px !important;
}

.hm-kefu-msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hm-kefu-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
}

.hm-kefu-msg.is-mine {
  align-items: flex-end;
}

.hm-kefu-bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--kf-hair);
  color: var(--kf-ink);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.hm-kefu-msg.is-mine .hm-kefu-bubble {
  background: var(--kf-ink-btn);
  border-color: transparent;
  color: #fff;
}

.hm-kefu-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--kf-ink-3);
}

/* 访客资料 */
.hm-kefu-form {
  padding: 0 14px 6px;
  background: #fff;
  border-top: 1px solid var(--kf-hair);
}

.hm-kefu-row {
  display: flex;
  gap: 8px;
  padding-top: 10px;
}

.hm-kefu-row input {
  flex: 1 1 0;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--kf-hair);
  border-radius: 10px;
  background: #f8fbff;
  color: var(--kf-ink);
  font-size: 13px;
  outline: none;
}

.hm-kefu-row input:focus {
  border-color: #8fbcf7;
  background: #fff;
}

/* 输入区 */
.hm-kefu-foot {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px 12px;
  background: #fff;
  border-top: 1px solid var(--kf-hair);
}

.hm-kefu-foot textarea {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  max-height: 96px;
  padding: 9px 10px;
  border: 1px solid var(--kf-hair);
  border-radius: 10px;
  background: #f8fbff;
  color: var(--kf-ink);
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
}

.hm-kefu-foot textarea:focus {
  border-color: #8fbcf7;
  background: #fff;
}

.hm-kefu-send {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--kf-ink-btn);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.hm-kefu-send:disabled {
  opacity: .55;
  cursor: default;
}

.hm-kefu-tip {
  padding: 0 14px 10px;
  background: #fff;
  color: #c0262b;
  font-size: 12.5px;
}

/* 窄屏：整屏面板，悬浮球贴边 */
@media (max-width: 575px) {
  .hm-kefu {
    right: 14px;
    bottom: 14px;
  }

  .hm-kefu-fab {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .hm-kefu-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    top: 8px;
    bottom: 8px;
    width: auto;
    height: auto;
    max-height: none;
    max-width: none;
  }
}
