/* ============================================================
   XIAOQ 导航站 · 动态接管 + 在线客服组件
   纯手写 CSS，无外部依赖
   ============================================================ */

:root {
  --xq-accent: var(--gold, #ffcf7a);
  --xq-accent-2: var(--warm, #ff8f5e);
  --xq-on-accent: #2b1720;
  --xq-glow: rgba(255, 143, 94, .42);
}

/* ---------- 动态 Logo ---------- */
.xq-logo-img {
  display: block;
  width: 82px;
  height: 82px;
  margin: 0 auto 12px;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, .38);
  background: rgba(255, 255, 255, .12);
  box-shadow: 0 10px 30px rgba(30, 8, 18, .34), inset 0 1px 0 rgba(255, 255, 255, .35);
  animation: xqFadeUp .7s .1s both;
}

/* ---------- 公告 ---------- */
.xq-notice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 20px;
  padding: 11px 36px 11px 13px;
  border-radius: 14px;
  color: rgba(255, 248, 236, .92);
  font-size: 12.5px;
  line-height: 1.75;
  letter-spacing: .3px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .07));
  border: 1px solid rgba(255, 255, 255, .24);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  box-shadow: 0 8px 24px rgba(35, 10, 20, .18), inset 0 1px 0 rgba(255, 255, 255, .18);
  animation: xqFadeUp .7s .4s both;
}
.xq-notice::before {
  content: "";
  flex: 0 0 3px;
  align-self: stretch;
  min-height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--xq-accent), var(--xq-accent-2));
  box-shadow: 0 0 10px var(--xq-glow);
}
.xq-notice-body { flex: 1; min-width: 0; }
.xq-notice strong {
  font-weight: 600;
  color: var(--xq-accent);
  margin-right: 6px;
  letter-spacing: 1px;
}
.xq-notice-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .55);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.xq-notice-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- 首页推荐 ---------- */
.xq-recommend {
  margin-top: 24px;
  animation: xqFadeUp .7s .55s both;
}
.xq-recommend-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 2px 11px;
  font-size: 12.5px;
  letter-spacing: 2px;
  color: rgba(255, 244, 227, .78);
}
.xq-recommend-head::before {
  content: "";
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--xq-accent), transparent);
  box-shadow: 0 0 8px var(--xq-glow);
}
.xq-recommend-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.xq-rec-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 15px;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .06));
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform .2s ease, background .2s ease;
}
.xq-rec-card:active { transform: scale(.98); }
.xq-rec-card:hover { background: linear-gradient(135deg, rgba(255, 255, 255, .23), rgba(255, 255, 255, .1)); }
.xq-rec-tag {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 10.5px;
  letter-spacing: .5px;
  color: var(--xq-on-accent);
  background: linear-gradient(135deg, var(--xq-accent), var(--xq-accent-2));
  box-shadow: 0 3px 12px var(--xq-glow);
}
.xq-rec-main { flex: 1; min-width: 0; }
.xq-rec-main b {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .5px;
}
.xq-rec-main small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xq-rec-arrow { color: rgba(255, 255, 255, .46); font-size: 19px; }

/* ---------- 主题接管微调 ---------- */
body.xq-themed .btn .ico {
  background: linear-gradient(140deg, var(--xq-accent-2), var(--xq-accent));
  box-shadow: 0 4px 14px var(--xq-glow), inset 0 1px 0 rgba(255, 255, 255, .35);
}
body.xq-themed .title {
  background: linear-gradient(180deg, #fff 30%, var(--xq-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================================================
   在线客服
   ============================================================ */

.xq-kefu-fab {
  position: fixed;
  right: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 9000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 18px 0 16px;
  border: 1px solid rgba(255, 255, 255, .52);
  border-radius: 999px;
  color: var(--xq-on-accent);
  background: linear-gradient(135deg, var(--xq-accent), var(--xq-accent-2));
  box-shadow: 0 12px 34px rgba(47, 12, 25, .42), 0 0 0 1px rgba(255, 255, 255, .08), inset 0 1px 0 rgba(255, 255, 255, .6);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease, opacity .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.xq-kefu-fab::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid var(--xq-accent);
  opacity: 0;
  animation: xqPulse 2.8s ease-out infinite;
  pointer-events: none;
}
.xq-kefu-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 42px rgba(47, 12, 25, .48), 0 0 26px var(--xq-glow), inset 0 1px 0 rgba(255, 255, 255, .7);
}
.xq-kefu-fab:active { transform: scale(.96); }
.xq-kefu-fab svg { width: 22px; height: 22px; flex: 0 0 auto; }
.xq-kefu-fab .xq-fab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38e09b;
  box-shadow: 0 0 0 2px rgba(20, 60, 40, .28), 0 0 9px rgba(56, 224, 155, .9);
}
.xq-kefu-fab.is-hidden { opacity: 0; pointer-events: none; transform: translateY(12px) scale(.94); }

.xq-chat {
  position: fixed;
  right: 22px;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  z-index: 9001;
  width: 370px;
  max-width: calc(100vw - 28px);
  height: min(570px, calc(100vh - 122px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  color: #fff;
  background: rgba(40, 21, 29, .9);
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 30px 80px rgba(18, 5, 12, .55), inset 0 1px 0 rgba(255, 255, 255, .16);
  backdrop-filter: blur(26px) saturate(145%);
  -webkit-backdrop-filter: blur(26px) saturate(145%);
  transform: translateY(18px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: transform .28s cubic-bezier(.2, .8, .25, 1), opacity .2s ease;
}
.xq-chat.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}
.xq-chat[aria-hidden="true"] { visibility: hidden; }
.xq-chat.is-open[aria-hidden="false"] { visibility: visible; }

.xq-chat-head {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 13px;
  background:
    radial-gradient(90% 160% at 15% 0%, rgba(255, 255, 255, .22), transparent 58%),
    linear-gradient(125deg, rgba(255, 207, 122, .2), rgba(255, 143, 94, .12));
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.xq-chat-avatar {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--xq-on-accent);
  background: linear-gradient(140deg, var(--xq-accent), var(--xq-accent-2));
  box-shadow: 0 6px 18px var(--xq-glow), inset 0 1px 0 rgba(255, 255, 255, .5);
  font-size: 18px;
  font-weight: 800;
}
.xq-chat-avatar::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38e09b;
  border: 2px solid #3b1d28;
  box-shadow: 0 0 8px rgba(56, 224, 155, .8);
}
.xq-chat-id { flex: 1; min-width: 0; }
.xq-chat-id b {
  display: block;
  font-size: 14.5px;
  letter-spacing: .8px;
  font-weight: 600;
}
.xq-chat-id span {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 11px;
  color: rgba(255, 255, 255, .62);
}
.xq-chat-id span::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #38e09b;
  box-shadow: 0 0 7px rgba(56, 224, 155, .9);
}
.xq-chat-close {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  color: rgba(255, 255, 255, .72);
  background: rgba(255, 255, 255, .07);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.xq-chat-close:hover { background: rgba(255, 255, 255, .15); color: #fff; }

.xq-chat-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(70% 40% at 100% 0%, rgba(255, 207, 122, .06), transparent 60%),
    linear-gradient(180deg, rgba(20, 9, 15, .22), rgba(20, 9, 15, .44));
}
.xq-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.xq-chat-messages::-webkit-scrollbar { width: 5px; }
.xq-chat-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 5px; }

.xq-msg {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-bottom: 12px;
  animation: xqMsgIn .25s ease both;
}
.xq-msg-visitor { flex-direction: row-reverse; }
.xq-msg-avatar {
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--xq-on-accent);
  background: linear-gradient(140deg, var(--xq-accent), var(--xq-accent-2));
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
}
.xq-msg-visitor .xq-msg-avatar {
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: none;
}
.xq-msg-main { max-width: 82%; min-width: 0; }
.xq-msg-bubble {
  padding: 9px 12px;
  border-radius: 14px 14px 14px 5px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: rgba(255, 255, 255, .95);
  background: rgba(255, 255, 255, .11);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 5px 16px rgba(10, 3, 7, .14);
}
.xq-msg-visitor .xq-msg-bubble {
  border-radius: 14px 14px 5px 14px;
  color: var(--xq-on-accent);
  background: linear-gradient(135deg, var(--xq-accent), var(--xq-accent-2));
  border-color: rgba(255, 255, 255, .26);
  box-shadow: 0 6px 18px var(--xq-glow);
}
.xq-msg-time {
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: .3px;
  color: rgba(255, 255, 255, .35);
}
.xq-msg-visitor .xq-msg-time { text-align: right; }
.xq-msg-bubble.xq-emoji-only {
  font-size: 26px;
  line-height: 1.25;
  padding: 7px 11px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.xq-msg.is-optimistic { opacity: .62; }

.xq-chat-welcome {
  margin: 0 0 13px;
  text-align: center;
}
.xq-chat-welcome span {
  display: inline-block;
  max-width: 90%;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .06);
}

.xq-chat-state {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 8px;
  min-height: 23px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, .38);
}
.xq-chat-state:empty { display: none; }
.xq-chat-state .xq-dot-load {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--xq-accent);
  box-shadow: 0 0 6px var(--xq-glow);
  animation: xqBlink 1.2s ease infinite;
}
.xq-chat-state.is-error { color: #ffb7ae; }

.xq-emoji-panel {
  flex: 0 0 auto;
  display: none;
  max-height: 218px;
  overflow-y: auto;
  padding: 9px 11px 11px;
  background: rgba(24, 11, 17, .97);
  border-top: 1px solid rgba(255, 255, 255, .09);
}
.xq-emoji-panel.is-open { display: block; }
.xq-emoji-cat {
  padding: 5px 3px 6px;
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, .36);
}
.xq-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}
.xq-emoji-btn {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}
.xq-emoji-btn:hover { background: rgba(255, 255, 255, .1); transform: scale(1.12); }
.xq-emoji-btn:active { transform: scale(.94); }

.xq-chat-compose {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 10px 11px calc(11px + env(safe-area-inset-bottom, 0px));
  background: rgba(28, 13, 20, .94);
  border-top: 1px solid rgba(255, 255, 255, .09);
}
.xq-compose-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 11px;
  color: rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.xq-compose-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.xq-compose-btn svg { width: 19px; height: 19px; }
.xq-compose-btn.xq-emoji-toggle.is-active {
  color: var(--xq-on-accent);
  background: linear-gradient(135deg, var(--xq-accent), var(--xq-accent-2));
  border-color: transparent;
}
.xq-compose-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 104px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 11px;
  outline: none;
  resize: none;
  color: #fff;
  background: rgba(255, 255, 255, .06);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.xq-compose-input::placeholder { color: rgba(255, 255, 255, .3); }
.xq-compose-input:focus {
  border-color: rgba(255, 207, 122, .55);
  box-shadow: 0 0 0 3px rgba(255, 207, 122, .08);
}
.xq-compose-send {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 11px;
  color: var(--xq-on-accent);
  background: linear-gradient(135deg, var(--xq-accent), var(--xq-accent-2));
  box-shadow: 0 4px 14px var(--xq-glow);
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease;
}
.xq-compose-send:hover { filter: brightness(1.06); }
.xq-compose-send:active { transform: scale(.94); }
.xq-compose-send:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.xq-compose-send svg { width: 17px; height: 17px; }

.xq-chat-foot {
  flex: 0 0 auto;
  padding: 0 0 6px;
  text-align: center;
  font-size: 9px;
  letter-spacing: .5px;
  color: rgba(255, 255, 255, .2);
  background: rgba(28, 13, 20, .94);
}

.xq-chat-toast {
  position: absolute;
  left: 50%;
  bottom: 92px;
  z-index: 4;
  transform: translate(-50%, 8px);
  max-width: calc(100% - 28px);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 11px;
  color: #fff;
  background: rgba(160, 50, 50, .9);
  border: 1px solid rgba(255, 255, 255, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.xq-chat-toast.is-show { opacity: 1; transform: translate(-50%, 0); }

@keyframes xqFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes xqPulse {
  0%   { opacity: .5; transform: scale(.96); }
  70%  { opacity: 0; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1.12); }
}
@keyframes xqMsgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes xqBlink {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

/* ---------- 移动端客服全屏 ---------- */
@media (max-width: 640px) {
  .wrap { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .xq-kefu-fab {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    height: 48px;
    padding: 0 15px 0 13px;
    font-size: 12.5px;
  }
  .xq-chat {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    transform: translateY(24px);
    transform-origin: center bottom;
  }
  .xq-chat.is-open { transform: translateY(0); }
  .xq-chat-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .xq-chat-messages { padding-left: 15px; padding-right: 15px; }
  .xq-chat-foot { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  body.xq-chat-open { overflow: hidden; }
}

@media (max-width: 360px) {
  .xq-chat-id b { font-size: 13px; }
  .xq-emoji-grid { grid-template-columns: repeat(7, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .xq-kefu-fab::before,
  .xq-logo-img,
  .xq-notice,
  .xq-recommend,
  .xq-msg {
    animation: none !important;
  }
  .xq-chat { transition: none; }
  .xq-chat-messages { scroll-behavior: auto; }
}

@media print {
  .xq-kefu-fab,
  .xq-chat,
  .xq-notice-close { display: none !important; }
}
