/* ==========================================================================
   claudechat.club · 在线咨询
   --------------------------------------------------------------------------
   前端不暴露 Telegram：用户看到的是「在线咨询」表单 + 官方邮箱。
   消息走后端 /api/consult 落库，同时转发到客服 Telegram，客服在 TG 里
   直接回复即可送回用户邮箱。
   ========================================================================== */

/* ---------- 悬浮入口 ---------- */
.consult-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 48px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--page);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    0 1px 2px #1018280d,
    0 12px 28px -10px #10182829,
    0 28px 60px -24px #10182833;
  transition: transform var(--dur-base) var(--ease-emphasized),
              box-shadow var(--dur-base) var(--ease-emphasized);
}

.consult-fab:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 16px color-mix(in srgb, var(--accent) 30%, transparent),
    0 12px 28px -10px #10182833,
    0 28px 60px -24px #10182840;
}

.consult-fab:active { transform: translateY(0) scale(.98); }

.consult-fab svg { flex: none; }

/* 小绿点表示在线 */
.consult-fab .live-dot {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px color-mix(in srgb, #10b981 26%, transparent);
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .55; transform: scale(.86); }
}

@media (max-width: 640px) {
  .consult-fab {
    right: 14px;
    bottom: 14px;
    width: 54px;
    height: 54px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .consult-fab .fab-label { display: none; }
  .consult-fab .live-dot { top: 12px; right: 12px; }
}

/* ---------- 弹窗 ---------- */
.cst-mask {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--ink) 46%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-emphasized);
}

.cst-mask[data-open="true"] { opacity: 1; }

.cst-panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: var(--radius-panel);
  background: var(--page);
  border: 1px solid var(--glass-line, var(--line));
  box-shadow:
    0 2px 4px #1018280a,
    0 8px 20px -4px #10182814,
    0 32px 64px -20px #10182833;
  padding: 26px;
  transform: translateY(12px) scale(.985);
  transition: transform var(--dur-base) var(--ease-emphasized);
}

.cst-mask[data-open="true"] .cst-panel { transform: none; }

.cst-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-emphasized),
              color var(--dur-fast) var(--ease-emphasized);
}

.cst-close:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- 头部 ---------- */
.cst-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.cst-ico {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-tint);
  color: var(--accent-text);
}

.cst-head h3 {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -.018em;
  margin: 0 0 3px;
}

.cst-head p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}

/* ---------- 官方邮箱行 ---------- */
.cst-mailrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--line);
}

.cst-mailrow .label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  flex: none;
}

.cst-mailrow a {
  font-family: var(--font-mono);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--accent-text);
  word-break: break-all;
}

.cst-mailrow a:hover { text-decoration: underline; }

.cst-copy {
  margin-left: auto;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-subtle);
  font: inherit;
  font-size: var(--fs-2xs);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.cst-copy:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- 表单 ---------- */
.cst-form { display: flex; flex-direction: column; gap: 14px; }

.cst-field { display: flex; flex-direction: column; gap: 6px; }

.cst-field > span {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text-muted);
}

.cst-field .input,
.cst-field .textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  padding: 10px 13px;
  transition: border-color var(--dur-base) var(--ease-emphasized),
              box-shadow var(--dur-base) var(--ease-emphasized);
}

.cst-field .textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

.cst-field .input:focus,
.cst-field .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* ---------- 提示 ---------- */
.cst-msg {
  font-size: var(--fs-xs);
  line-height: 1.55;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  transition: max-height var(--dur-base) var(--ease-emphasized),
              padding var(--dur-base) var(--ease-emphasized);
}

.cst-msg[data-show="true"] {
  max-height: 160px;
  padding: 10px 12px;
}

.cst-msg[data-kind="error"] {
  background: var(--danger-tint);
  color: var(--danger);
}

.cst-msg[data-kind="ok"] {
  background: var(--success-tint);
  color: var(--success);
}

.cst-msg[data-kind="info"] {
  background: var(--surface);
  color: var(--text-muted);
}

/* ---------- 底部说明 ---------- */
.cst-note {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-2xs);
  line-height: 1.62;
  color: var(--text-subtle);
}

/* 成功后展示 */
.cst-done {
  text-align: center;
  padding: 12px 0 4px;
}

.cst-done .ok-ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--success-tint);
  color: var(--success);
  font-size: 24px;
}

.cst-done h4 {
  font-size: 1rem;
  font-weight: 650;
  margin: 0 0 8px;
  color: var(--ink);
}

.cst-done p {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
}

/* 认证页底部有主按钮，悬浮入口上移避免遮挡 */
.auth-body .consult-fab { bottom: 84px; }

@media (max-width: 640px) {
  .auth-body .consult-fab { bottom: 76px; }
  .cst-panel { padding: 22px; border-radius: var(--radius-panel); }
}

/* ==========================================================================
   3D 机器人客服入口
   --------------------------------------------------------------------------
   两个实体形象的机器人坐在页面右下角：
     · bot-help  挥手 = 售前咨询（问价格、问配置、问开通）
     · bot-tech  敲键盘 = 技术支持（连不上、要重装、账单问题）
   要点：
     · 用真实 3D 渲染图的透明 PNG，带投影和呼吸浮动，像"坐"在页面上
     · 悬停抬身 + 影子收缩，产生离地感
     · 点击气泡说话，再进原有咨询弹窗（复用同一套后端）
   ========================================================================== */

.bot-dock {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 900;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  pointer-events: none;
}

.bot-item {
  position: relative;
  width: 104px;
  padding: 0 0 14px;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  transition: transform var(--dur-base) var(--ease-emphasized);
  will-change: transform;
}

/* 地面投影：机器人浮起来时影子缩小变淡 */
.bot-item::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 62px;
  height: 11px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--ink) 34%, transparent) 0%,
    transparent 72%);
  filter: blur(2.5px);
  transition: width var(--dur-base) var(--ease-emphasized),
              opacity var(--dur-base) var(--ease-emphasized);
  pointer-events: none;
}

.bot-item img {
  display: block;
  width: auto;
  height: 96px;
  max-width: 118px;
  margin: 0 auto;
  object-fit: contain;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--ink) 14%, transparent));
  animation: bot-breathe 4.2s ease-in-out infinite;
  transform-origin: 50% 92%;
}

/* 两只错开节奏，避免整齐划一的机械感 */
.bot-item:nth-child(2) img { animation-delay: -2.1s; }

@keyframes bot-breathe {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-5px) rotate(-.7deg); }
}

.bot-item:hover { transform: translateY(-6px); }
.bot-item:hover::after { width: 48px; opacity: .6; }
.bot-item:hover img { animation-play-state: paused; }
.bot-item:active { transform: translateY(-2px) scale(.98); }

/* 名牌标签 */
.bot-tag {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--page);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  box-shadow: 0 4px 12px -3px color-mix(in srgb, var(--ink) 40%, transparent);
  z-index: 2;
  transition: background var(--dur-fast) ease;
}

.bot-tag i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2.5px color-mix(in srgb, #10b981 28%, transparent);
  animation: live-pulse 2.4s ease-in-out infinite;
}

.bot-item:hover .bot-tag { background: var(--accent-text); }

/* 说话气泡 */
.bot-say {
  position: absolute;
  right: 92%;
  bottom: 62%;
  width: max-content;
  max-width: 210px;
  padding: 9px 13px;
  border-radius: 14px 14px 4px 14px;
  background: var(--page);
  color: var(--ink);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
  box-shadow:
    0 1px 2px #1018280f,
    0 10px 24px -8px #10182833;
  border: 1px solid var(--line-strong);
  opacity: 0;
  transform: translate(6px, 4px) scale(.94);
  transform-origin: 100% 100%;
  transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-emphasized);
  pointer-events: none;
}

.bot-item:hover .bot-say,
.bot-item:focus-visible .bot-say {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

/* 入场：从下方滑入，错开时间 */
.bot-dock {
  animation: dock-in .7s var(--ease-emphasized) .3s both;
}

@keyframes dock-in {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}

/* 移动端：缩到 74px，只留形象和标签，隐藏气泡 */
@media (max-width: 860px) {
  .bot-dock { right: 8px; bottom: 8px; gap: 0; }
  .bot-item { width: 78px; padding-bottom: 12px; }
  .bot-item img { height: 74px; max-width: 92px; }
  .bot-tag { height: 21px; padding: 0 8px; font-size: 10.5px; }
  .bot-say { display: none; }
}

@media (max-width: 480px) {
  .bot-dock { right: 4px; bottom: 6px; }
  .bot-item { width: 66px; }
  .bot-item img { height: 62px; max-width: 78px; }
  .bot-tag { height: 19px; padding: 0 7px; font-size: 10px; }
}

/* 有机器人时，原来的文字 FAB 让位（只有 .bot-dock 存在时才隐藏） */
body:has(.bot-dock) .consult-fab { display: none; }

@media (prefers-reduced-motion: reduce) {
  .bot-item img { animation: none; }
  .bot-dock { animation: none; }
}

/* ==========================================================================
   弹窗内的机器人人格
   ========================================================================== */

/* 头部图标换成机器人头像：圆形、带底色、显小但认得出 */
.cst-ico.cst-ico-bot {
  background: color-mix(in srgb, var(--accent) 12%, var(--page));
  overflow: hidden;
  padding: 0;
}

.cst-ico-bot img {
  width: 130%;
  height: 130%;
  object-fit: contain;
  object-position: 50% 42%;
  transform: translateY(4%);
}

/* 问候语气泡 */
.cst-greeting {
  position: relative;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: 4px 14px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.65;
}

.cst-greeting::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -7px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: 3px 0 0 0;
  transform: rotate(45deg) translateY(3px);
}

/* ==========================================================================
   实时聊天窗（consult.js 实时对话版）
   ========================================================================== */
.cst-panel.cst-chat { display: flex; flex-direction: column; max-height: min(640px, 86vh); padding: 0; }
/* 统一深色滚动条（消除刺眼白色条） */
.cst-msgs::-webkit-scrollbar { width: 6px; }
.cst-msgs::-webkit-scrollbar-track { background: transparent; }
.cst-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 999px; }
.cst-msgs::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }
.cst-panel.cst-chat::-webkit-scrollbar { width: 6px; }
.cst-panel.cst-chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 999px; }
.cst-chat .cst-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.cst-chat .cst-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line, rgba(255,255,255,.08));
}
.cst-live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #34d399; margin-right: 4px;
  box-shadow: 0 0 0 3px rgba(52,211,153,.18);
  animation: cstPulse 2s infinite;
}
@keyframes cstPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52,211,153,.18); }
  50% { box-shadow: 0 0 0 6px rgba(52,211,153,.06); }
}
.cst-msgs {
  flex: 1; overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 220px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
.cst-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px; line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.cst-bubble.cst-them {
  align-self: flex-start;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-bottom-left-radius: 4px;
}
.cst-bubble.cst-me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent, #f97316), color-mix(in oklab, var(--accent, #f97316) 78%, #000));
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cst-bubble.cst-sys {
  align-self: center;
  background: rgba(251,191,36,.12);
  color: #fbbf24;
  font-size: 12.5px;
  border-radius: 999px;
  padding: 6px 14px;
}
.cst-mailrow { display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--line, rgba(255,255,255,.08)); }
.cst-mailrow .label { font-size: 12px; color: var(--text-muted, #8b93b0); flex: none; }
.cst-mail-input { flex: 1; min-height: 34px; font-size: 13px; }
.cst-chatbar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 14px 6px;
}
.cst-input {
  flex: 1; resize: none;
  min-height: 42px; max-height: 120px;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px; line-height: 1.5;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  color: inherit;
}
.cst-input:focus { outline: none; border-color: var(--accent, #f97316); }
.cst-send {
  width: 42px; height: 42px; flex: none;
  border-radius: 14px; border: none;
  background: linear-gradient(135deg, var(--accent, #f97316), color-mix(in oklab, var(--accent, #f97316) 80%, #000));
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.cst-send:hover { transform: scale(1.05); }
.cst-send:disabled { opacity: .5; cursor: not-allowed; }
.cst-note-slim { padding: 0 18px 14px; font-size: 11.5px; margin: 0; }

/* 机器人 dock 浮动动画（更活泼） */
.bot-item img {
  animation: botFloat 3.2s ease-in-out infinite;
}
.bot-item:nth-child(2) img { animation-delay: 1.6s; }
.bot-item img:hover { animation-play-state: paused; }
@keyframes botFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
