/* MagicTrip Lite — 极简手机端。空白背景 + 左上 logo + 居中椭圆输入框。
   风格纪律：完整句、句号断句换行、不用破折号连接、不用 emoji。 */
:root {
  --ink: #191c20;
  --ink-2: #5f6671;
  --ink-3: #9aa1ab;
  --line: #e6e9ee;
  --bubble: #f1f3f6;
  --send-on: #111418;
  --send-off: #e8eaee;
  --send-off-ink: #aab0b8;
  --accent: #8A5DE1; /* 品牌紫，与主站一致 */
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overscroll-behavior-y: none;
}

/* ── 背景：主站 #how-it-works 同款"变幻色彩"虹彩特效（同色板、同 8s 周期、同 keyframes），
      挪到固定底层做柔和光晕。prefers-reduced-motion 时停用动画。 ── */
.glow { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.glow i {
  position: absolute; display: block;
  background: linear-gradient(270deg, #ec4899, #8A5DE1, #667eea, #ec4899);
  background-size: 400% 400%;
  filter: blur(90px);
  will-change: transform;
}
/* 光晕不能只靠色相流动 —— 低透明度下几乎看不出在动。每条光晕都带自己的
   慢速漂移/呼吸（22–28s，各自相位错开），颜色流动（8s，与主站同款）叠在上面。 */
.glow i:nth-child(1) {
  left: 50%; top: 58%; transform: translate(-50%, -50%);
  width: 130vw; height: 40vh; opacity: 0.16;
  animation: gradientFlow 8s ease-in-out infinite, driftA 22s ease-in-out infinite;
}
.glow i:nth-child(2) {
  left: -34vw; top: -16vh;
  width: 92vw; height: 34vh; opacity: 0.11;
  animation: gradientFlow 8s ease-in-out infinite -5s, driftB 28s ease-in-out infinite;
}
.glow i:nth-child(3) {
  right: -30vw; bottom: -18vh;
  width: 80vw; height: 30vh; opacity: 0.10;
  animation: gradientFlow 8s ease-in-out infinite -2.5s, driftC 24s ease-in-out infinite;
}
@keyframes gradientFlow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes driftA {
  0%, 100% { transform: translate(-50%, -50%) translate(0, 0) scale(1); }
  50%      { transform: translate(-50%, -50%) translate(-7vw, 4vh) scale(1.12); }
}
@keyframes driftB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(9vw, 7vh) scale(1.18); }
}
@keyframes driftC {
  0%, 100% { transform: translate(0, 0) scale(1.05); }
  50%      { transform: translate(-6vw, -6vh) scale(0.95); }
}
@media (prefers-reduced-motion: reduce) {
  .glow i { animation: none; }
}

/* ── 顶栏：左 logo，右「新对话」（仅对话中出现） ── */
.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.logo { height: 26px; width: auto; display: block; }
.newchat {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
/* display:grid 会覆盖 [hidden] 的 UA display:none —— 必须显式补上，否则空状态也显示 */
.newchat[hidden] { display: none; }
.newchat:active { background: #f4f5f7; }

/* ── 舞台：空状态整体居中；对话态消息滚动、输入框沉底 ── */
.stage {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: 0 18px calc(14px + env(safe-area-inset-bottom));
}
.stage > * { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }

body.empty .stage { justify-content: center; padding-bottom: calc(9vh + env(safe-area-inset-bottom)); }
body.empty .welcome { display: block; }
body:not(.empty) .welcome { display: none; }
body.empty .thread { display: none; }
body:not(.empty) .hints { display: none; }

/* ── 空状态：招呼语 + 输入框 + 三行提示 ── */
.welcome { margin-bottom: 30px; text-align: center; }
.welcome h1 {
  margin: 0; font-size: 26px; line-height: 1.3; font-weight: 700;
  letter-spacing: -0.01em; color: var(--accent); /* 一贯的品牌紫粗体 */
}
.welcome .sub { margin: 9px 0 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.5; }

.hints {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 24px; max-width: 460px;
}
.hint {
  position: relative; background: none; border: 0; margin: 0;
  padding: 0 0 0 16px; color: #7c838d;
  font: inherit; font-size: 15px; line-height: 1.5;
  text-align: left; cursor: pointer;
}
.hint::before {
  content: ""; position: absolute; left: 2px; top: 0.62em;
  width: 5px; height: 5px; border-radius: 50%; background: #cebdf0; /* 品牌紫淡色 */
}
.hint:active { color: #14171b; }

/* ── 输入框：椭圆胶囊 ── */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 26px;
  padding: 7px 7px 7px 18px;
  box-shadow: 0 4px 24px rgba(23, 32, 64, 0.07), 0 1px 2px rgba(23, 32, 64, 0.04);
}
body.empty .composer { border-radius: 28px; box-shadow: 0 10px 34px rgba(23, 32, 64, 0.10), 0 1px 2px rgba(23, 32, 64, 0.05); }
.composer:focus-within { border-color: #d9c8f7; box-shadow: 0 4px 26px rgba(138, 93, 225, 0.14); }
.composer textarea {
  flex: 1; border: 0; outline: 0; background: transparent; resize: none;
  font: inherit; font-size: 16px; line-height: 23px; max-height: 115px;
  padding: 6px 0; color: var(--ink);
}
.composer textarea::placeholder { color: var(--ink-3); }
.send {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--send-on); color: #fff;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: background 0.15s;
}
.send:disabled { background: var(--send-off); color: var(--send-off-ink); cursor: default; }

/* ── 消息流 ── */
.thread {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 14px 2px 8px;
  -webkit-overflow-scrolling: touch;
}
.msg { margin: 0 0 16px; font-size: 15.5px; line-height: 1.68; overflow-wrap: break-word; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--bubble); border-radius: 18px;
  padding: 9px 14px; max-width: 84%; white-space: pre-wrap;
}
.msg.bot { white-space: pre-wrap; color: #20242a; }
.msg.bot a { color: var(--accent); }

/* markdown（marked 渲染）产出块级元素时关掉 pre-wrap，避免标签间换行变成大片空白 */
.msg.bot.md { white-space: normal; }
.msg.bot.md p { margin: 0 0 10px; }
.msg.bot.md p:last-child { margin-bottom: 0; }
.msg.bot.md h1, .msg.bot.md h2, .msg.bot.md h3, .msg.bot.md h4 {
  margin: 16px 0 6px; line-height: 1.35; font-weight: 600;
}
.msg.bot.md h1 { font-size: 19px; }
.msg.bot.md h2 { font-size: 17px; }
.msg.bot.md h3 { font-size: 15.5px; }
.msg.bot.md h1:first-child, .msg.bot.md h2:first-child, .msg.bot.md h3:first-child { margin-top: 0; }
.msg.bot.md ul, .msg.bot.md ol { margin: 0 0 10px; padding-left: 22px; }
.msg.bot.md li { margin: 3px 0; }
.msg.bot.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.msg.bot.md table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 14px; }
.msg.bot.md th, .msg.bot.md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.msg.bot.md code { background: #f3f4f6; border-radius: 6px; padding: 1px 5px; font-size: 13.5px; }
.msg.bot.md pre { background: #f7f8fa; border-radius: 10px; padding: 10px 12px; overflow-x: auto; }
.msg.bot.md strong { font-weight: 600; }

.sys {
  text-align: center; color: var(--ink-3); font-size: 13px;
  line-height: 1.5; margin: 2px 0 16px;
  white-space: pre-wrap;
}

/* 打字三点 + 状态行（"正在搜本地知识库"等） */
.typing { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.typing .dots { display: inline-flex; gap: 5px; align-items: center; flex: 0 0 auto; }
.typing .dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #c3c9d2;
  animation: tp 1.2s infinite ease-in-out;
}
.typing .dots i:nth-child(2) { animation-delay: 0.15s; }
.typing .dots i:nth-child(3) { animation-delay: 0.3s; }
.typing .tlabel { color: var(--ink-3); font-size: 13.5px; line-height: 1.4; }
@keyframes tp {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* 城市照片叠卡：前卡清晰 + 后两张同图虚化旋转，像一摞照片 */
.pstack {
  position: relative; width: min(78%, 300px); aspect-ratio: 16 / 10;
  margin: 10px 0 18px;
  animation: stackIn 0.45s ease both;
}
@keyframes stackIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.pstack img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.pstack .back2 { transform: rotate(-7deg) translate(-12px, -7px) scale(0.95); filter: blur(6px) saturate(1.05); opacity: 0.55; }
.pstack .back1 { transform: rotate(-3.5deg) translate(-6px, -3px) scale(0.975); filter: blur(3px) saturate(1.02); opacity: 0.8; }
.pstack .front { box-shadow: 0 10px 30px rgba(23, 32, 64, 0.18); }
.pstack .pcap {
  position: absolute; left: 13px; bottom: 12px; z-index: 4;
  color: #fff; font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
.pstack { cursor: zoom-in; -webkit-tap-highlight-color: transparent; }
.pstack:active .front { filter: brightness(0.95); }

/* 全屏相册（点叠卡打开：多图左右切换，点背景/Esc 关闭） */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12, 16, 24, 0.88);
  display: grid; place-items: center; padding: 22px;
  cursor: zoom-out; animation: lbIn 0.22s ease both;
}
.lightbox img.lbimg {
  max-width: 100%; max-height: 78vh; border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  animation: lbImg 0.26s ease both;
  user-select: none; -webkit-user-drag: none; touch-action: pan-y;
}
.lightbox img.lbimg.from-right { animation: lbFromR 0.22s ease both; }
.lightbox img.lbimg.from-left  { animation: lbFromL 0.22s ease both; }
.lightbox .lbcap {
  position: absolute; left: 0; right: 0; bottom: calc(26px + env(safe-area-inset-bottom));
  text-align: center; color: rgba(255, 255, 255, 0.85); font-size: 14px;
}
.lightbox .lbcount {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 18px;
  color: rgba(255, 255, 255, 0.75); font-size: 13px; font-variant-numeric: tabular-nums;
}
.lightbox .lbdots {
  position: absolute; left: 0; right: 0; bottom: calc(54px + env(safe-area-inset-bottom));
  display: flex; gap: 7px; justify-content: center;
}
.lightbox .lbdots i {
  width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); cursor: pointer;
}
.lightbox .lbdots i.on { background: #fff; }
.lightbox .lbnav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, 0.12); color: #fff;
  font-size: 22px; line-height: 1; display: grid; place-items: center;
  cursor: pointer; padding: 0 0 3px; -webkit-tap-highlight-color: transparent;
}
.lightbox .lbnav:active { background: rgba(255, 255, 255, 0.22); }
.lightbox .lbprev { left: 10px; }
.lightbox .lbnext { right: 10px; }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbImg { from { transform: scale(0.92); opacity: 0.6; } to { transform: scale(1); opacity: 1; } }
@keyframes lbFromR { from { transform: translateX(26px); opacity: 0.4; } to { transform: translateX(0); opacity: 1; } }
@keyframes lbFromL { from { transform: translateX(-26px); opacity: 0.4; } to { transform: translateX(0); opacity: 1; } }

/* 回复后的追问小条 */
.sugs { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 16px; }
.sug {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 13px; font: inherit; font-size: 13.5px; color: #454b54;
  cursor: pointer;
}
.sug:active { background: #f4f5f7; }

/* ── 行程单卡片 ── */
.plan {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 16px 14px; margin: 2px 0 6px;
}
.plan h3 { margin: 0; font-size: 16.5px; line-height: 1.35; font-weight: 600; }
.plan .meta { margin-top: 4px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.pcity { margin-top: 16px; font-size: 15px; font-weight: 600; color: #14171b; }
.pday { margin-top: 12px; }
.pday .h { font-weight: 600; font-size: 14.5px; }
.pday .theme { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; line-height: 1.5; }
.act { display: flex; gap: 10px; margin-top: 6px; font-size: 14.5px; line-height: 1.5; }
.act .t { flex: 0 0 44px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.act .n { flex: 1; }
.act .dur { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.notes { color: var(--ink-3); font-size: 13px; margin: 2px 0 0 54px; line-height: 1.5; }
.pbudget { margin-top: 14px; font-size: 14px; }
.dl { display: flex; gap: 10px; margin-top: 14px; }
.dl a {
  flex: 1; text-align: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 0; font-size: 14.5px; font-weight: 500; color: #14171b;
  background: #fff;
}
.dl a:active { background: #f4f5f7; }
.upd {
  display: block; margin: 10px auto 0; background: none; border: 0;
  padding: 4px 8px; color: var(--accent); font: inherit; font-size: 13.5px;
  cursor: pointer;
}
.upd:active { opacity: 0.7; }
.sys.tap { cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* 回底按钮（往上翻时出现，悬浮在输入框上方） */
.scrollbtn {
  position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 20; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 20px rgba(23, 32, 64, 0.14);
  animation: stackIn 0.25s ease both;
}
.scrollbtn[hidden] { display: none; }
.scrollbtn:active { background: #f4f5f7; }

/* 参考卡片（主站内容：城市指南 / 故事 / 文化 / 电台 / 生存包） */
.refs { display: flex; flex-direction: column; gap: 8px; margin: -6px 0 16px; }
.refcard {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 14px;
}
.refcard:active { background: #f8f9fb; }
.refcard .rt { flex: 1; color: var(--ink); font-size: 14.5px; font-weight: 500; line-height: 1.4; }
.refcard .rs { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.refcard .ra { color: var(--accent); font-size: 18px; line-height: 1; }
