/* 在线客服：右下角悬浮入口 + 轻量对话面板（演示态） */

.hd-fab {
  position: fixed;
  right: 22px;
  top: 50%;
  bottom: auto;
  z-index: 210;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 15px 0 12px;
  border: 1px solid var(--accent-line, #b8d1fb);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--accent, #0b57d0);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 28px -12px rgba(13, 21, 35, .28);
  transform: translateY(-50%);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
}
.hd-fab:hover { transform: translateY(calc(-50% - 1px)); box-shadow: 0 16px 32px -14px rgba(13, 21, 35, .34); background: var(--accent-weak, #eef4fe); }
.hd-fab svg { width: 18px; height: 18px; }
.hd-fab__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .16);
}
.hd-fab__dot.is-off { background: #b7791f; box-shadow: 0 0 0 3px rgba(183, 121, 31, .14); }
.hd-fab__badge {
  position: absolute; top: -6px; right: -4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: #dc2626; color: #fff;
  font-size: 10.5px; font-weight: 600; line-height: 1;
}
.hd-fab__badge[hidden] { display: none; }

.hd-mask { display: none; position: fixed; inset: 0; z-index: 230; background: rgba(9, 16, 28, .44); }
.hd-mask[hidden] { display: none !important; }

.hd-panel {
  position: fixed;
  right: 22px;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  z-index: 240;
  width: 354px;
  max-height: min(620px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e4e9f0);
  border-radius: 12px;
  box-shadow: 0 28px 70px -28px rgba(13, 21, 35, .4);
}
.hd-panel[hidden] { display: none; }

.hd-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 12px;
  border-bottom: 1px solid var(--line, #e4e9f0);
  background: var(--bg-softer, #fafbfc);
}
.hd-head b { display: block; font-size: 14px; line-height: 1.4; color: var(--ink, #0d1523); }
.hd-status { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11px; color: var(--muted-2, #7d8a9b); }
.hd-status i { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; }
.hd-status i.is-off { background: #b7791f; }
.hd-close {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted-2, #7d8a9b); cursor: pointer;
}
.hd-close:hover { background: var(--bg-soft, #f5f7fa); color: var(--ink, #0d1523); }
.hd-close svg { width: 16px; height: 16px; }

.hd-body { flex: 1; overflow-y: auto; padding: 13px 14px; }

.hd-tabs {
  display: flex; gap: 4px; padding: 8px 12px 0;
  border-bottom: 1px solid var(--line, #e4e9f0);
}
.hd-tabs button {
  flex: 1; height: 30px; border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted, #5c6a7c);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.hd-tabs button:hover { color: var(--accent, #0b57d0); }
.hd-tabs button.is-active { color: var(--accent, #0b57d0); border-bottom-color: var(--accent, #0b57d0); }

.hd-state {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  padding: 14px 12px; border: 1px dashed var(--line, #e4e9f0); border-radius: 8px;
  font-size: 12.5px; line-height: 1.65; color: var(--muted, #5c6a7c);
}
.hd-state b { color: var(--ink, #0d1523); font-size: 13px; }
.hd-state--err { border-color: #f0c4c4; background: #fff6f6; color: #9b2c2c; }
.hd-state--err b { color: #9b2c2c; }

.hd-tickets { display: flex; flex-direction: column; gap: 7px; }
.hd-ticket {
  display: block; padding: 9px 10px; border: 1px solid var(--line, #e4e9f0);
  border-radius: 8px; text-decoration: none; color: inherit;
  transition: border-color .16s, background .16s;
}
.hd-ticket:hover { border-color: var(--accent, #0b57d0); background: var(--accent-weak, #eef4fe); }
.hd-ticket__top { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink, #0d1523); }
.hd-ticket__top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hd-ticket__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #dc2626; }
.hd-ticket__meta {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  font-size: 11px; color: var(--muted-2, #7d8a9b);
}
.hd-ticket__st { padding: 1px 6px; border-radius: 999px; background: var(--bg-soft, #f5f7fa); color: var(--muted, #5c6a7c); }
.hd-ticket__st--waiting_user { background: #fff3e0; color: #b45309; }
.hd-ticket__st--open, .hd-ticket__st--reopened { background: var(--accent-weak, #eef4fe); color: var(--accent, #0b57d0); }
.hd-ticket__st--resolved { background: #e8f7ee; color: #15803d; }
.hd-ticket__st--closed { background: var(--bg-soft, #f5f7fa); color: var(--muted-2, #7d8a9b); }
.hd-more { margin: 8px 0 0; font-size: 11px; line-height: 1.6; color: var(--muted-2, #7d8a9b); }

.hd-note {
  margin-bottom: 10px; padding: 8px 10px; border-radius: 6px;
  font-size: 12px; line-height: 1.65;
}
.hd-note--ok { background: #eef8f1; color: #15803d; }
.hd-note--err { background: #fff4f4; color: #9b2c2c; }
.hd-note a { color: inherit; font-weight: 600; }

.hd-login { padding: 12px; border: 1px solid var(--line, #e4e9f0); border-radius: 8px; }
.hd-login b { display: block; font-size: 13px; color: var(--ink, #0d1523); }
.hd-login p { margin: 5px 0 10px; font-size: 12px; line-height: 1.65; color: var(--muted, #5c6a7c); }

.hd-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 13px; border: 1px solid var(--line-strong, #d3dae5); border-radius: 6px;
  background: var(--surface, #fff); color: var(--ink-2, #34445a);
  font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.hd-btn:hover { border-color: var(--accent, #0b57d0); color: var(--accent, #0b57d0); }
.hd-btn--primary { border-color: var(--accent, #0b57d0); background: var(--accent, #0b57d0); color: #fff; }
.hd-btn--primary:hover { background: var(--accent-hover, #0846ab); border-color: var(--accent-hover, #0846ab); color: #fff; }
.hd-btn:disabled { opacity: .6; cursor: default; }

.hd-newform { display: flex; flex-direction: column; gap: 10px; }
.hd-newform label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2, #34445a); }
.hd-newform input, .hd-newform textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line, #e4e9f0); border-radius: 6px;
  background: var(--surface, #fff); color: var(--ink, #0d1523);
  font: inherit; font-size: 12.5px; line-height: 1.6; resize: vertical;
}
.hd-newform input:focus, .hd-newform textarea:focus {
  outline: 0; border-color: var(--accent, #0b57d0); box-shadow: 0 0 0 3px var(--accent-weak, #eef4fe);
}
.hd-hint { margin: 0; font-size: 11px; line-height: 1.6; color: var(--muted-2, #7d8a9b); }
.hd-newform .hd-btn { align-self: flex-start; }

.hd-intro { font-size: 12.5px; line-height: 1.7; color: var(--muted, #5c6a7c); }
.hd-intro b { color: var(--ink, #0d1523); }

.hd-faq { margin-top: 12px; }
.hd-faq > b { display: block; font-size: 11.5px; color: var(--muted-2, #7d8a9b); font-weight: 600; margin-bottom: 6px; }
.hd-faq a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 9px; border-radius: 6px; color: var(--ink-2, #34445a);
  font-size: 12.5px; line-height: 1.5; text-decoration: none;
}
.hd-faq a:hover { background: var(--accent-weak, #eef4fe); color: var(--accent, #0b57d0); }
.hd-faq a::after { content: '→'; color: var(--muted-2, #7d8a9b); font-size: 11px; }

.hd-chat { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.hd-msg {
  max-width: 88%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  word-break: break-word;
}
.hd-msg--bot { align-self: flex-start; background: var(--bg-soft, #f5f7fa); color: var(--ink-2, #34445a); border-top-left-radius: 3px; }
.hd-msg--me { align-self: flex-end; background: var(--accent, #0b57d0); color: #fff; border-top-right-radius: 3px; }

.hd-form { display: flex; gap: 7px; padding: 10px 12px; border-top: 1px solid var(--line, #e4e9f0); }
.hd-form input {
  flex: 1; min-width: 0; height: 34px; padding: 0 10px;
  border: 1px solid var(--line, #e4e9f0); border-radius: 6px;
  background: var(--surface, #fff); color: var(--ink, #0d1523); font: inherit; font-size: 12.5px;
}
.hd-form input:focus { outline: 0; border-color: var(--accent, #0b57d0); box-shadow: 0 0 0 3px var(--accent-weak, #eef4fe); }
.hd-form button {
  flex: none; height: 34px; padding: 0 13px; border: 0; border-radius: 6px;
  background: var(--accent, #0b57d0); color: #fff; font: inherit; font-size: 12.5px; cursor: pointer;
}
.hd-form button:hover { background: var(--accent-hover, #0846ab); }

.hd-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 13px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line, #e4e9f0);
  background: var(--bg-softer, #fafbfc);
  font-size: 10.5px; color: var(--muted-2, #7d8a9b);
}
.hd-foot a {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border: 1px solid var(--line-strong, #d3dae5); border-radius: 5px;
  background: var(--surface, #fff); color: var(--ink-2, #34445a); font-size: 11px; text-decoration: none;
}
.hd-foot a:hover { border-color: var(--accent, #0b57d0); color: var(--accent, #0b57d0); }

html[data-theme="dark"] .hd-msg--bot { background: rgba(255, 255, 255, .06); }
html[data-theme="dark"] .hd-head,
html[data-theme="dark"] .hd-foot { background: rgba(255, 255, 255, .03); }
/* 深色下 --accent 是浅蓝，白字压不住；实底按钮与自己的气泡改用实色蓝 */
html[data-theme="dark"] .hd-form button,
html[data-theme="dark"] .hd-msg--me { background: var(--accent-solid, #2f6fe8); }
html[data-theme="dark"] .hd-form button:hover { background: var(--accent-hover, #0846ab); }
html[data-theme="dark"] .hd-state--err,
html[data-theme="dark"] .hd-note--err { background: rgba(220, 38, 38, .12); border-color: rgba(220, 38, 38, .35); color: #fca5a5; }
html[data-theme="dark"] .hd-state--err b { color: #fca5a5; }
html[data-theme="dark"] .hd-note--ok { background: rgba(22, 163, 74, .14); color: #86efac; }
html[data-theme="dark"] .hd-ticket__st--waiting_user { background: rgba(180, 83, 9, .22); color: #fbbf24; }
html[data-theme="dark"] .hd-ticket__st--resolved { background: rgba(22, 163, 74, .18); color: #86efac; }
html[data-theme="dark"] .hd-btn--primary { background: var(--accent-solid, #2f6fe8); border-color: var(--accent-solid, #2f6fe8); }


@media (max-width: 48em) {
  body { padding-bottom: 72px; }
  .hd-fab {
    right: 14px;
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
    height: 40px;
    padding: 0 13px 0 10px;
    font-size: 12.5px;
    transform: none;
  }
  .hd-fab:hover { transform: translateY(-1px); }
  .hd-mask { display: block; }
  .hd-panel {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(78vh, 640px);
    border-radius: 12px;
    transform: none;
  }
  .hd-body { padding: 12px; }
  .hd-faq a { padding: 8px 6px; }
}
