/* ============================================================
   問小妃快速對話框（右下角，TOP 上方）
   色票沿用 ufans-tokens.css 的 :root 變數
   ============================================================ */

.xfq{
  --xfq-r: max(20px, env(safe-area-inset-right));
  --xfq-b: max(20px, env(safe-area-inset-bottom));
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
.xfq-sr{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── 啟動鈕：TOP 沒出現時貼底，TOP 出現後往上讓位 ── */
.xfq-launch{
  position: fixed; z-index: 61;
  right: var(--xfq-r); bottom: var(--xfq-b);
  width: 56px; height: 56px; padding: 0; border-radius: 18px;
  display: grid; place-items: center;
  background: #fff; border: 1px solid #FFD8C6; cursor: pointer;
  box-shadow: 0 12px 30px rgba(255,122,77,.25);
  transition: bottom .28s cubic-bezier(.2,.7,.3,1), transform .2s ease, box-shadow .2s ease;
}
.xfq.has-top .xfq-launch{ bottom: calc(var(--xfq-b) + 64px); }
.xfq-launch:hover{ transform: translateY(-2px); box-shadow: 0 16px 36px rgba(255,107,157,.32); }
.xfq-launch:focus-visible{ outline: 2px solid #E04F82; outline-offset: 3px; }
.xfq-face svg{ width: 38px; height: 46px; display: block; }
.xfq-launch::after{
  content: ""; position: absolute; top: -3px; right: -3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #22B573; border: 2px solid #fff;
}
.xfq-tip{
  position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; padding: .45rem .8rem; border-radius: 999px;
  font-size: .8125rem; font-weight: 600; color: #fff;
  background: linear-gradient(100deg, #FF7A4D, #FF6B9D);
  box-shadow: 0 8px 20px rgba(255,122,77,.3);
  pointer-events: none;
  animation: xfq-tip 6s ease 1.2s 1 both;
}
.xfq-launch:hover .xfq-tip{ animation: none; opacity: 1; }
@keyframes xfq-tip{ 0%{ opacity: 0; } 8%, 80%{ opacity: 1; } 100%{ opacity: 0; } }
.xfq.is-open .xfq-tip{ display: none; }

/* ── 對話框 ── */
.xfq-panel{
  position: fixed; z-index: 62;
  right: var(--xfq-r); bottom: calc(var(--xfq-b) + 70px);
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - var(--xfq-b) - 70px - 24px));
  display: flex; flex-direction: column;
  background: #FDF8F5; border: 1px solid #F0E2DA; border-radius: 20px;
  box-shadow: 0 28px 70px rgba(36,24,32,.22);
  overflow: hidden;
  animation: xfq-in .22s cubic-bezier(.2,.7,.3,1);
}
.xfq.has-top .xfq-panel{ bottom: calc(var(--xfq-b) + 134px); height: min(560px, calc(100dvh - var(--xfq-b) - 134px - 24px)); }
.admin-bar .xfq-panel{ max-height: calc(100dvh - var(--xfq-b) - 70px - 56px); }
.admin-bar .xfq.has-top .xfq-panel{ max-height: calc(100dvh - var(--xfq-b) - 134px - 56px); }
.xfq-panel[hidden]{ display: none; }
@keyframes xfq-in{ from{ opacity: 0; transform: translateY(10px) scale(.98); } to{ opacity: 1; transform: none; } }

.xfq-head{
  display: flex; align-items: center; gap: .65rem;
  padding: .75rem .9rem; background: #fff; border-bottom: 1px solid #F0E2DA;
}
.xfq-ava{ width: 34px; height: 34px; border-radius: 11px; background: #FFF4EF; display: grid; place-items: center; flex-shrink: 0; }
.xfq-ava svg{ width: 24px; height: 29px; }
.xfq-who{ display: flex; flex-direction: column; line-height: 1.3; }
.xfq-who b{ font-size: .95rem; color: #241820; }
.xfq-who span{ display: inline-flex; align-items: center; gap: .35rem; font-size: .7rem; color: #A08894; letter-spacing: .04em; }
.xfq-who i{ width: 6px; height: 6px; border-radius: 50%; background: #22B573; }
.xfq-x{
  margin-left: auto; width: 2rem; height: 2rem; border-radius: 50%;
  border: 0; background: none; font-size: 1.4rem; line-height: 1; color: #A08894; cursor: pointer;
}
.xfq-x:hover{ background: #FFF4EF; color: #241820; }

.xfq-body{
  flex: 1; min-height: 0; overflow-y: auto; padding: .9rem;
  background-image:
    linear-gradient(rgba(36,24,32,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36,24,32,.03) 1px, transparent 1px);
  background-size: 32px 32px;
}
.xfq-msgs{ display: flex; flex-direction: column; gap: .6rem; }
.xfq-m{
  max-width: 88%; padding: .6rem .85rem; border-radius: 14px;
  font-size: .9rem; line-height: 1.7; overflow-wrap: anywhere;
}
.xfq-m p{ margin: 0 0 .5em; } .xfq-m p:last-child{ margin-bottom: 0; }
.xfq-m ul, .xfq-m ol{ margin: 0 0 .5em; padding-left: 1.2em; }
.xfq-m li{ margin-bottom: .2em; }
.xfq-m a{ color: #E04F82; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(224,79,130,.35); }
.xfq-assistant{ align-self: flex-start; background: #fff; border: 1px solid #F0E2DA; border-top-left-radius: 5px; color: #241820; }
.xfq-user{ align-self: flex-end; background: #241820; color: #fff; border-top-right-radius: 5px; }
.xfq-note{ align-self: center; max-width: 100%; text-align: center; font-size: .8rem; color: #6B5560; background: #FFF4EF; }
.xfq-note a{ color: #E04F82; font-weight: 600; }

.xfq-chips{ display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; margin-top: .2rem; }
.xfq-chips button{
  padding: .45rem .8rem; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: .8125rem; font-weight: 500; line-height: 1.4; color: #5A4750;
  background: #fff; border: 1px solid #FFD8C6;
  transition: border-color .15s ease, color .15s ease;
}
.xfq-chips button:hover{ border-color: #FF6B9D; color: #E04F82; }

.xfq-typing{ display: inline-flex; gap: 4px; padding: .3rem 0; }
.xfq-typing i{ width: 6px; height: 6px; border-radius: 50%; background: #FF7A4D; opacity: .35; animation: xfq-dot 1.2s ease-in-out infinite; }
.xfq-typing i:nth-child(2){ animation-delay: .15s; } .xfq-typing i:nth-child(3){ animation-delay: .3s; }
@keyframes xfq-dot{ 0%,100%{ opacity: .3; } 40%{ opacity: 1; transform: translateY(-2px); } }

.xfq-form{
  display: flex; gap: .45rem; padding: .65rem .7rem; background: #fff; border-top: 1px solid #F0E2DA;
}
.xfq-form input{
  flex: 1; min-width: 0; padding: .6rem .8rem; border-radius: 12px;
  font-family: inherit; font-size: 16px; line-height: 1.4; color: #241820;
  border: 1px solid #F0E2DA; background: #FFFCFA; outline: 0;
}
.xfq-form input:focus{ border-color: rgba(255,107,157,.6); box-shadow: 0 0 0 3px rgba(255,107,157,.12); }
.xfq-form button{
  flex-shrink: 0; width: 40px; border-radius: 12px; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(100deg, #FF7A4D, #FF6B9D);
}
.xfq-form button svg{ width: 18px; height: 18px; }
.xfq-form button:disabled{ opacity: .45; cursor: default; }
.xfq-foot{
  margin: 0; padding: .45rem .9rem .6rem; background: #fff;
  font-size: .7rem; line-height: 1.5; color: #A08894; text-align: center;
}
.xfq-foot a{ color: #E04F82; font-weight: 600; white-space: nowrap; }

/* ── 手機：對話框改成底部抽屜，開啟時隱藏啟動鈕與 TOP ── */
@media (max-width: 600px){
  .xfq{ --xfq-r: max(14px, env(safe-area-inset-right)); --xfq-b: max(14px, env(safe-area-inset-bottom)); }
  .xfq-launch{ width: 50px; height: 50px; border-radius: 16px; }
  .xfq.has-top .xfq-launch{ bottom: calc(var(--xfq-b) + 58px); }
  .xfq-tip{ display: none; }
  .xfq-panel, .xfq.has-top .xfq-panel{
    left: 8px; right: 8px; bottom: 8px; width: auto;
    height: min(78dvh, 600px);
  }
  .xfq.is-open .xfq-launch{ display: none; }
  body:has(.xfq.is-open) .to-top{ display: none; }
}
@media (prefers-reduced-motion: reduce){
  .xfq-launch, .xfq-panel{ transition: none; animation: none; }
  .xfq-tip{ animation: none; opacity: 0; }
  .xfq-typing i{ animation: none; }
}
