/* ============================================================
   問小妃（/ask）
   疊在 ufans-tokens.css + ufans-ai.css（nav／footer／按鈕）之上
   ============================================================ */

.xf-page{
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --nav-h: 75px;
}
.xf-page .nav-links a[aria-current="page"]{ color: var(--rose); font-weight: 600; }
.admin-bar.xf-page .nav{ top: 32px; }
@media (max-width: 782px){ .admin-bar.xf-page .nav{ top: 46px; } }
@media (max-width: 600px){ .admin-bar.xf-page .nav{ top: 0; } }
html.xf-locked{ overflow: hidden; }

/* 聊天頁像 App 一樣固定在一個畫面：整頁不捲動，只有對話區自己捲；不顯示頁尾與回到頂端 */
body.xf-page{ height: 100dvh; overflow: hidden; }
.admin-bar.xf-page{ height: calc(100dvh - 32px); }
.xf-page footer, .xf-page .to-top{ display: none !important; }

.xf-sr{
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}

/* ───────── 版面 ───────── */
.xf-page .xf-app{
  display: grid; grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100dvh - var(--nav-h));
  min-height: 320px;
  border-bottom: 1px solid var(--line);
}
.admin-bar.xf-page .xf-app{ height: calc(100dvh - var(--nav-h) - 32px); }

/* ───────── 側欄 ───────── */
.xf-page .xf-side{
  display: flex; flex-direction: column; min-height: 0;
  padding: 1.1rem .9rem;
  background: #FFFBF8;
  border-right: 1px solid var(--line);
}
.xf-page .xf-new{
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  width: 100%; padding: .75rem 1rem; border-radius: 12px;
  font: 600 .9375rem/1 var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .18s ease, color .18s ease;
}
.xf-page .xf-new span{ color: var(--rose); font-size: 1.1rem; }
.xf-page .xf-new:hover{ border-color: var(--line-2); color: var(--rose); }
.xf-page .xf-side-label{
  margin: 1.4rem .4rem .5rem;
  font-family: var(--mono); font-size: .6875rem; letter-spacing: .16em; color: var(--muted);
}
.xf-page .xf-list{ list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.xf-page .xf-list li{ position: relative; margin: 0 0 2px; }
.xf-page .xf-item{
  display: flex; flex-direction: column; gap: .15rem; width: 100%;
  padding: .6rem 2rem .6rem .7rem; border-radius: 10px;
  text-align: left; background: none; border: 0; cursor: pointer; color: var(--ink-2);
  transition: background .15s ease;
}
.xf-page .xf-item:hover{ background: rgba(255,122,77,.06); }
.xf-page .xf-list li.is-on .xf-item{ background: rgba(255,107,157,.10); color: var(--ink); }
.xf-page .xf-item-t{
  font-size: .875rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.xf-page .xf-item-d{ font-family: var(--mono); font-size: .6875rem; color: var(--muted); }
.xf-page .xf-del{
  position: absolute; right: .35rem; top: .5rem;
  width: 1.6rem; height: 1.6rem; border-radius: 6px;
  border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0;
  transition: opacity .15s ease, color .15s ease;
}
.xf-page .xf-list li:hover .xf-del, .xf-page .xf-del:focus-visible{ opacity: 1; }
.xf-page .xf-del:hover{ color: var(--rose); }
.xf-page .xf-list:empty{ display: none; }
.xf-page .xf-list-empty{ margin: .2rem .4rem; font-size: .8125rem; color: var(--muted); }

.xf-page .xf-side-foot{ padding-top: .9rem; border-top: 1px solid var(--line); margin-top: auto; }
.xf-page .xf-human{
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; padding: .75rem 1rem; border-radius: 12px; border: 0; cursor: pointer;
  font: 600 .9375rem/1 var(--sans); color: #fff;
  background: linear-gradient(135deg, var(--dark-a), var(--dark-b));
  transition: transform .2s ease, box-shadow .2s ease;
}
.xf-page .xf-human:hover{ transform: translateY(-1px); box-shadow: 0 10px 24px rgba(36,24,32,.18); }
.xf-page .xf-human-dot{
  width: 8px; height: 8px; border-radius: 50%; background: #22B573;
  box-shadow: 0 0 0 3px rgba(34,181,115,.25);
}
.xf-page .xf-account{
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-top: .8rem; padding: 0 .3rem; font-size: .8125rem; color: var(--ink-3);
}
.xf-page .xf-acc-mail{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xf-page .xf-link{
  background: none; border: 0; padding: 0; cursor: pointer;
  font: 600 .8125rem/1.4 var(--sans); color: var(--rose);
}
.xf-page .xf-link:hover{ text-decoration: underline; text-underline-offset: 3px; }

/* ───────── 對話區 ───────── */
.xf-page .xf-main{
  position: relative;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  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: 40px 40px;
}
.xf-page .xf-bar{
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem clamp(1rem, 3vw, 1.75rem);
  background: rgba(253,248,245,.9);
  border-bottom: 1px solid var(--line);
}
.xf-page .xf-menu{
  display: none; width: 2.4rem; height: 2.4rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  align-items: center; justify-content: center;
}
.xf-page .xf-menu svg{ width: 20px; height: 20px; }
.xf-page .xf-ava{
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-2);
  display: grid; place-items: center; overflow: hidden;
}
.xf-page .xf-ava svg{ width: 40px; height: 40px; margin-top: 4px; }
.xf-page .xf-bar-who{ display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.xf-page .xf-bar-who b{ font-size: 1rem; color: var(--ink); }
.xf-page .xf-bar-who span{
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--mono); font-size: .6875rem; letter-spacing: .08em; color: var(--muted);
}
.xf-page .xf-live{
  width: 6px; height: 6px; border-radius: 50%; background: #22B573;
  animation: xf-pulse 2.2s ease-out infinite;
}
@keyframes xf-pulse{
  0%{ box-shadow: 0 0 0 0 rgba(34,181,115,.45); }
  70%{ box-shadow: 0 0 0 7px rgba(34,181,115,0); }
  100%{ box-shadow: 0 0 0 0 rgba(34,181,115,0); }
}
.xf-page .xf-bar-human{
  margin-left: auto; display: none;
  padding: .5rem .9rem; border-radius: 999px; cursor: pointer;
  font: 600 .8125rem/1 var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
}

.xf-page .xf-scroll{
  flex: 1; min-height: 0; overflow-y: auto;
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 3vw, 1.75rem) 1rem;
  scroll-behavior: smooth;
}

/* 歡迎畫面 */
.xf-page .xf-welcome{
  max-width: 640px; margin: clamp(.5rem, 4vh, 3rem) auto 0; text-align: center;
}
.xf-page .xf-welcome-ava{
  width: 112px; height: 112px; margin: 0 auto .5rem;
  animation: xf-float 4s ease-in-out infinite;
}
.xf-page .xf-welcome-ava svg{ width: 100%; height: 100%; }
@keyframes xf-float{ 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-6px); } }
.xf-page .xf-eyebrow{
  margin: 0; font-family: var(--mono); font-size: .6875rem; letter-spacing: .18em; color: var(--rose);
}
.xf-page .xf-welcome h2{ margin: .6rem 0 0; font-size: clamp(1.6rem, 3.4vw, 2.1rem); color: var(--ink); }
.xf-page .xf-welcome > p:not(.xf-eyebrow){ margin: .7rem auto 0; max-width: 30rem; color: var(--ink-3); }
.xf-page .xf-chips{
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem;
  margin-top: 1.75rem; text-align: left;
}
.xf-page .xf-chips button{
  padding: .85rem 1rem; border-radius: 14px; cursor: pointer;
  font: 500 .875rem/1.55 var(--sans); color: var(--ink-2); text-align: left;
  background: rgba(255,255,255,.85); border: 1px solid var(--line);
  transition: border-color .18s ease, transform .18s ease, color .18s ease;
}
.xf-page .xf-chips button:hover{ border-color: var(--line-2); color: var(--ink); transform: translateY(-2px); }

/* 訊息 */
.xf-page .xf-msgs{ max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.1rem; }
.xf-page .xf-msg{ display: flex; gap: .7rem; align-items: flex-start; }
.xf-page .xf-user{ justify-content: flex-end; }
.xf-page .xf-bubble{
  max-width: min(100%, 620px);
  padding: .8rem 1.05rem; border-radius: 16px;
  font-size: .975rem; line-height: 1.8; overflow-wrap: anywhere;
}
.xf-page .xf-user .xf-bubble{
  color: #fff; background: var(--ink); border-top-right-radius: 6px;
  white-space: pre-wrap; max-width: 80%;
}
.xf-page .xf-assistant .xf-bubble{
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-top-left-radius: 6px;
  box-shadow: 0 8px 22px rgba(36,24,32,.05);
}
.xf-page .xf-assistant .xf-bubble p{ margin: 0 0 .7em; }
.xf-page .xf-assistant .xf-bubble p:last-child{ margin-bottom: 0; }
.xf-page .xf-assistant .xf-bubble .xf-h{ font-weight: 700; margin-top: .4em; }
.xf-page .xf-assistant .xf-bubble ul, .xf-page .xf-assistant .xf-bubble ol{ margin: 0 0 .7em; padding-left: 1.3em; }
.xf-page .xf-assistant .xf-bubble li{ margin-bottom: .3em; }
.xf-page .xf-assistant .xf-bubble li::marker{ color: var(--orange); }
.xf-page .xf-assistant .xf-bubble strong{ color: var(--ink); }
.xf-page .xf-assistant .xf-bubble code{
  font-family: var(--mono); font-size: .85em; padding: .1em .35em; border-radius: 5px; background: var(--surface-2);
}
.xf-page .xf-assistant .xf-bubble a{
  color: var(--rose); text-decoration: underline; text-decoration-color: rgba(224,79,130,.35); text-underline-offset: 3px;
}
.xf-page .xf-caret{
  display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--grad); border-radius: 2px; animation: xf-blink 1s steps(2) infinite;
}
@keyframes xf-blink{ 50%{ opacity: 0; } }
.xf-page .xf-typing{ display: inline-flex; gap: 5px; padding: .35rem 0; }
.xf-page .xf-typing i{
  width: 7px; height: 7px; border-radius: 50%; background: var(--orange); opacity: .35;
  animation: xf-dot 1.2s ease-in-out infinite;
}
.xf-page .xf-typing i:nth-child(2){ animation-delay: .15s; }
.xf-page .xf-typing i:nth-child(3){ animation-delay: .3s; }
@keyframes xf-dot{ 0%,100%{ opacity: .3; transform: none; } 40%{ opacity: 1; transform: translateY(-3px); } }

.xf-page .xf-note{
  align-self: center; max-width: 560px; text-align: center;
  padding: .55rem 1rem; border-radius: 999px;
  font-size: .8125rem; color: var(--ink-3); background: var(--surface-2);
}
.xf-page .xf-note.is-err{ color: #B42318; background: #FEF3F2; }
.xf-page .xf-note.is-warn{ color: #93370D; background: #FFFAEB; }
.xf-page .xf-note.is-ok{ color: #1E7E50; background: #ECFDF3; }
.xf-page .xf-note.is-cta{ background: var(--surface); border: 1px solid var(--line-2); }

/* 輸入區 */
.xf-page .xf-compose{
  padding: .75rem clamp(1rem, 3vw, 1.75rem) 1rem;
  background: linear-gradient(180deg, rgba(253,248,245,0), var(--bg) 30%);
}
.xf-page .xf-input{
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: .5rem;
  padding: .5rem .5rem .5rem 1rem; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: 0 12px 34px rgba(255,122,77,.10);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.xf-page .xf-input:focus-within{ border-color: rgba(255,107,157,.6); box-shadow: 0 12px 34px rgba(255,107,157,.16), 0 0 0 3px rgba(255,107,157,.12); }
.xf-page .xf-input textarea{
  flex: 1; resize: none; border: 0; outline: 0; background: none;
  font: 400 1rem/1.6 var(--sans); color: var(--ink);
  padding: .45rem 0; max-height: 180px;
}
.xf-page .xf-input textarea::placeholder{ color: var(--muted); }
.xf-page .xf-send{
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: var(--grad);
  box-shadow: 0 6px 16px rgba(255,122,77,.3);
  transition: transform .18s ease, opacity .18s ease;
}
.xf-page .xf-send svg{ width: 20px; height: 20px; }
.xf-page .xf-send:hover{ transform: translateY(-1px); }
.xf-page .xf-send:disabled{ opacity: .45; cursor: default; transform: none; }
.xf-page .xf-hint{
  max-width: 760px; margin: .55rem auto 0; text-align: center;
  font-size: .72rem; line-height: 1.6; color: var(--muted);
}
.xf-page .xf-hint span{ color: var(--ink-3); font-weight: 500; margin-right: .35em; }

/* ───────── 對話框 ───────── */
.xf-page .xf-modal{
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 1rem;
  background: rgba(36,24,32,.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.xf-page .xf-modal[hidden]{ display: none; }
.xf-page .xf-dialog{
  position: relative; width: min(100%, 420px);
  max-height: calc(100dvh - 2rem); overflow-y: auto;
  padding: 2rem 1.75rem 1.5rem; border-radius: 20px;
  background: var(--surface); box-shadow: 0 30px 80px rgba(36,24,32,.3);
}
.xf-page .xf-dialog h2{ margin: .5rem 0 0; font-size: 1.35rem; color: var(--ink); }
.xf-page .xf-dialog-sub{ margin: .5rem 0 1.2rem; font-size: .9rem; color: var(--ink-3); line-height: 1.7; }
.xf-page .xf-dialog label{ display: block; margin: .9rem 0 .35rem; font-size: .8125rem; font-weight: 600; color: var(--ink-2); }
.xf-page .xf-dialog input, .xf-page .xf-dialog textarea{
  width: 100%; padding: .75rem .9rem; border-radius: 12px;
  font: 400 1rem/1.5 var(--sans); color: var(--ink);
  border: 1px solid var(--line); background: #FFFCFA; outline: 0;
}
.xf-page .xf-dialog input:focus, .xf-page .xf-dialog textarea:focus{ border-color: rgba(255,107,157,.6); box-shadow: 0 0 0 3px rgba(255,107,157,.12); }
.xf-page .xf-dialog #xf-code{ font-family: var(--mono); font-size: 1.4rem; letter-spacing: .4em; text-align: center; }
.xf-page .xf-wide{ display: block; width: 100%; margin-top: 1.1rem; border: 0; cursor: pointer; }
.xf-page .xf-wide:disabled{ opacity: .6; cursor: default; transform: none; }
.xf-page .xf-dialog .xf-link{ display: block; margin: .9rem auto 0; }
.xf-page .xf-x{
  position: absolute; right: .8rem; top: .7rem;
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer;
}
.xf-page .xf-x:hover{ color: var(--ink); background: var(--surface-2); }
.xf-page .xf-err{ margin: .8rem 0 0; min-height: 1.2em; font-size: .8125rem; color: #B42318; }
.xf-page .xf-fine{ margin: .6rem 0 0; font-size: .75rem; color: var(--muted); line-height: 1.6; }
.xf-page .xf-fine a{ color: var(--rose); }

/* ───────── 手機 ───────── */
@media (max-width: 860px){
  .xf-page{ --nav-h: 69px; }
  .xf-page .xf-app{ grid-template-columns: 1fr; }
  .xf-page .xf-side{
    position: fixed; z-index: 90; top: 0; bottom: 0; left: 0;
    width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .25s ease;
    box-shadow: 20px 0 50px rgba(36,24,32,.15);
  }
  .xf-page .xf-side.is-open{ transform: none; }
  .xf-page .xf-scrim{ position: fixed; inset: 0; z-index: 85; background: rgba(36,24,32,.35); }
  .xf-page .xf-menu{ display: inline-flex; }
  .xf-page .xf-bar-human{ display: inline-block; }
  .xf-page .xf-chips{ grid-template-columns: 1fr; }
  .xf-page .xf-del{ opacity: 1; }
}
@media (max-width: 600px){
  .xf-page .xf-welcome-ava{ width: 88px; height: 88px; }
  .xf-page .xf-user .xf-bubble{ max-width: 88%; }
  .xf-page .xf-bubble{ font-size: .95rem; }
  .xf-page .xf-hint{ font-size: .68rem; }
}
@media (prefers-reduced-motion: reduce){
  .xf-page .xf-live, .xf-page .xf-welcome-ava, .xf-page .xf-caret, .xf-page .xf-typing i{ animation: none; }
  .xf-page .xf-scroll{ scroll-behavior: auto; }
}

/* ───────── LINE／Google 登入 ───────── */
.xf-page .xf-social{ display: flex; flex-direction: column; gap: .6rem; }
.xf-page .xf-social[hidden], .xf-page .xf-sso[hidden]{ display: none; }
.xf-page .xf-sso{
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  width: 100%; padding: .85rem 1rem; border-radius: 12px;
  font: 600 .9375rem/1 var(--sans);
  transition: transform .18s ease, box-shadow .18s ease;
}
.xf-page .xf-sso:hover{ transform: translateY(-1px); }
.xf-page .xf-sso svg{ width: 20px; height: 20px; }
.xf-page .xf-sso-line{ color: #fff; background: #06C755; box-shadow: 0 10px 24px rgba(6,199,85,.22); }
.xf-page .xf-sso-google{ color: #1F1F1F; background: #fff; border: 1px solid #DADCE0; }
.xf-page .xf-sso-google:hover{ box-shadow: 0 6px 16px rgba(36,24,32,.08); }
.xf-page .xf-or{
  display: flex; align-items: center; gap: .8rem;
  margin: .6rem 0 .1rem; font-size: .75rem; color: var(--muted);
}
.xf-page .xf-or::before, .xf-page .xf-or::after{ content: ""; flex: 1; height: 1px; background: var(--line); }
