/* lo 上新 前端样式：移动优先、零外部依赖、零 CDN */

:root {
  --bg: #f6f0ec;
  --card: #fffdfb;
  --ink: #33292b;
  --muted: #8d7f7d;
  --line: #eadfd9;
  --accent: #b8667a;
  --accent-soft: #f3e2e6;
  --warn: #b07a24;
  --warn-soft: #fbf1dd;
  --ok: #4c7a5c;
  --ok-soft: #eaf3ec;
  --radius: 14px;
  --pad: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;   /* iOS 横屏/大字号时别自作主张放大正文 */
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ---------------------------------------------------------------- 顶栏 */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
  letter-spacing: .02em;
  /* 展示名变长时截断标题，别把状态点顶出屏幕 */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.bad { background: #c0554d; }

/* ---------------------------------------------------------------- 主体 */
#view {
  padding: var(--pad) var(--pad) calc(78px + env(safe-area-inset-bottom));
  max-width: 1040px;
  margin: 0 auto;
}
.loading, .empty { color: var(--muted); text-align: center; padding: 34px 12px; font-size: 14px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 8px 0 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }

/* 概览数字 */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.summary .num { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .lbl { font-size: 11px; color: var(--muted); }

/* 筛选 */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chip.on, .chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 知识页的工具入口 */
.entries { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.entry span { font-size: 20px; }
.entry:active { background: var(--accent-soft); }

/* ---------------------------------------------------------------- 上新卡片 */
.arrivals { display: flex; flex-direction: column; gap: 10px; }
.arrival {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.arrival .thumb {
  flex: 0 0 84px;
  width: 84px;
  height: 112px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  overflow: hidden;
}
.arrival .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 没图时的占位：品牌首字 + 「暂无图」。只放一个字母会被当成"加载失败"。 */
.arrival .thumb .ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
}
.arrival .thumb .ph b { font-size: 30px; font-weight: 700; line-height: 1; }
.arrival .thumb .ph small { font-size: 10.5px; font-weight: 500; opacity: .75; }
.arrival .body { flex: 1; min-width: 0; }
.arrival .line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.arrival .brand { font-size: 12.5px; color: var(--muted); }
.arrival .series { font-size: 15.5px; font-weight: 600; margin: 3px 0 2px; }
.arrival .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* 价格：单独一行、字号比正文大。混在灰色 meta 里会被当成"又一串数字"跳过。 */
.arrival .price-line { margin: 5px 0 3px; }
.arrival .price {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}
.arrival .price.none { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
/* 币种标签：比价格小一号、灰色、贴着数字，不抢价格的视觉重量 */
.arrival .cur {
  margin-left: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  vertical-align: 1px;
}
.arrival .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.arrival .note { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.55; }
.arrival .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.arrival .src { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.arrival .src.warn { color: var(--warn); }

.badge {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.badge.on { background: var(--accent); color: #fff; }
.badge.pref { background: var(--ok-soft); color: var(--ok); }
.badge.gray { background: #eee; color: var(--muted); }
/* 尺码：可选码 / 你的码 / 最大码都不够——三种状态三种颜色，不能长得一样 */
.badge.size { background: #f1f2f4; color: #4a4d52; font-variant-numeric: tabular-nums; }
.badge.size.on { background: var(--ok); color: #fff; }
.badge.size.warn { background: #fdecea; color: var(--warn); }
.arrival .sizes { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.style { border-color: var(--accent-soft); color: var(--accent); background: #fdf6f7; }

/* 排序原因：让"为什么排在前面"一直可见 */
.reasons { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.reason {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
}
/* 「命中」不是加分理由，是筛选条件——换个颜色，别和其它筛选状态混在一起 */
.reason.hit { background: #eef1f6; color: #4a5568; }

/* 搜索框 */
.searchbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.searchbar input {
  flex: 1;
  min-width: 0;
  padding: 10px 13px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.searchbar input:focus { outline: none; border-color: var(--accent); }
.chip.small { padding: 4px 11px; font-size: 12px; }
.empty .hint { font-size: 12px; color: var(--muted); }

.arrival .kn { margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.arrival .kn a { color: var(--accent); text-decoration: none; }
.arrival .kn a:hover { text-decoration: underline; }

/* 取图：就地展开的地址输入行 */
.fetch-form { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.fetch-form input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.fetch-form input:focus { outline: none; border-color: var(--accent); }
.fetch-form button { flex: 0 0 auto; }

/* 两个按钮并排（登录 / 注册） */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 button { width: 100%; }

/* 提示条里的链接要能看出来是链接 */
.notice a { color: inherit; text-decoration: underline; }

/* 品牌行 */
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.brand-row:last-child { border-bottom: none; }
.brand-row .grow { flex: 1; min-width: 0; }
.brand-row .name { font-size: 14.5px; font-weight: 600; }
.brand-row .meta { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- 表单 */
label.field { display: block; margin-bottom: 12px; }
label.field > span, .field > .label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field { margin-bottom: 12px; }
input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
textarea { resize: vertical; min-height: 68px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

button.primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.primary:disabled { opacity: .55; }
button.ghost, a.ghost {
  display: inline-block;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
button.ghost.sm, a.ghost.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
button.ghost:disabled { opacity: .5; }
button.ghost.danger { color: #b3413a; border-color: #eccac7; }

/* 多选按钮组 */
.pick { display: flex; flex-wrap: wrap; gap: 7px; }

/* ---------------------------------------------------------------- 结论块 */
.verdict {
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 10px;
}
.verdict .big { font-size: 26px; font-weight: 700; letter-spacing: .02em; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: #fbeceb; color: #b3413a; }
.kv { font-size: 12.5px; color: var(--muted); line-height: 1.8; margin-bottom: 10px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 10px; }
table.tbl th, table.tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.tbl td:first-child { font-weight: 600; }

ul.plain { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.85; }
ul.plain li { margin-bottom: 2px; }

/* ---------------------------------------------------------------- 知识问答 */
.answer { white-space: pre-wrap; line-height: 1.75; font-size: 15px; }
.cite {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 0 3px;
  margin: 0 1px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}
.notice { font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: #eef1f6; color: #4a5c74; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

.src-block { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 10px; font-size: 13.5px; }
.src-block:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.src-block .head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.src-block .body { white-space: pre-wrap; }
.src-block.flash { background: var(--accent-soft); border-radius: 8px; padding: 8px; }

/* 状态表 */
.status { font-size: 13.5px; line-height: 1.95; }

/* ---------------------------------------------------------------- 底栏 */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
#tabbar button {
  background: none;
  border: none;
  padding: 9px 2px 8px;
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
#tabbar button span { font-size: 19px; line-height: 1; }
#tabbar button.on { color: var(--accent); font-weight: 600; }

/* 提示条 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: 82vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(48, 38, 40, .93);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- 助手（聊天） */
/* 聊天页在 chat.js 里，样式单独一段，避免和别的区块互相影响 */

.chat-card { display: flex; flex-direction: column; gap: 10px; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-actions { display: flex; align-items: center; gap: 8px; }
.chat-model { min-width: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* 桌面：左侧固定对话栏 + 右侧聊天区 */
.chat-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.chat-main { min-width: 0; }
.thread-side {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 64px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 12px;
  max-height: calc(100dvh - 96px);
}
.thread-new { width: 100%; padding: 9px 14px; }
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}
.thread-item {
  display: flex;
  align-items: center;
  min-width: 0;
  border-radius: 10px;
}
.thread-item:hover { background: var(--accent-soft); }
.thread-item.on { background: var(--accent-soft); }
.thread-open {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 8px 4px 8px 10px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.thread-item.on .thread-open { color: var(--accent); font-weight: 600; }
.thread-del {
  align-self: stretch;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 0 8px 1px 4px;
  cursor: pointer;
}
.thread-del:hover { color: var(--accent); }

/* 窄屏抽屉：默认收起，用「对话」按钮唤出 */
.thread-toggle { display: none; }
.thread-backdrop { display: none; }

/* 登录 / 注册：跟聊天卡片同一套外观，不另起一页 */
.auth-card { max-width: 420px; margin: 8vh auto 0; gap: 12px; }
.auth-title { margin: 2px 0 0; font-size: 18px; }
.auth-card .hint { line-height: 1.6; }
.auth-tabs { display: flex; gap: 8px; }
.auth-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.auth-field input {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.auth-submit { width: 100%; padding: 11px 16px; }
.auth-msg { min-height: 18px; color: var(--accent); }
.auth-actions { display: flex; justify-content: flex-end; }

/* 问答是主页面的主区域：给足首屏高度，输入框始终在卡片底部可见 */
.chat-list {
  min-height: min(42vh, 380px);
  max-height: 62vh;
  min-height: min(42dvh, 380px);   /* 支持 dvh 时跟着可视高度走，软键盘弹出不会把输入框挤下去 */
  max-height: 62dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }

.bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;   /* 长英文串/链接别把气泡顶出屏幕 */
}
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--accent-soft); color: var(--ink); border-bottom-left-radius: 4px; }
.thinking { color: var(--muted); font-size: 13px; }

/* 首字前的逐通道召回状态：谁先返回谁先亮，别让用户对着空白气泡等 */
.recall-live {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 4px 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.recall-head { font-size: 11px; letter-spacing: .04em; margin-bottom: 2px; }
.recall-row { display: flex; align-items: center; gap: 6px; }
.recall-row .dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: recall-pulse 1.2s ease-in-out infinite;
}
.recall-row.done .dot { background: var(--ok); animation: none; }
@keyframes recall-pulse {
  0%, 100% { opacity: .3; }
  50% { opacity: 1; }
}

.steps { font-size: 11.5px; color: var(--muted); }
.steps summary { cursor: pointer; }
.step { padding: 2px 0 2px 8px; overflow-wrap: anywhere; }
.step-sum { display: block; color: var(--muted); opacity: .85; }

.evidence { display: flex; flex-direction: column; gap: 6px; }
.evidence summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}
.ev { font-size: 11.5px; color: var(--muted); line-height: 1.55; scroll-margin-top: 24px; overflow-wrap: anywhere; }
.ev-n { color: var(--accent); font-weight: 600; margin-right: 4px; }
.ev-title { font-weight: 600; }
.ev-link { margin-top: 2px; font-size: 11px; color: var(--accent); word-break: break-all; }
.ev-link a { color: inherit; text-decoration: none; }
.ev-link a:hover { text-decoration: underline; }
.ev-text { opacity: .9; }
.ev.flash { background: var(--accent-soft); border-radius: 8px; padding: 6px 8px; }

/* 引用对不上来源：就地标出，而不是把整段回答换掉 */
.cite.invalid {
  color: #b3261e;
  background: rgba(179, 38, 30, .12);
  text-decoration: line-through;
  cursor: help;
}
.cite-warn { margin-top: 8px; font-size: 12px; line-height: 1.6; }

.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 120px; }
.chat-input .primary { width: auto; flex: 0 0 auto; padding: 12px 18px; }
/* 首页推荐问题：窄屏换行，不横向滚动、不溢出容器。 */
.chat-chips { padding-bottom: 0; flex-wrap: wrap; overflow: visible; }

/* 裙子档案：结构化字段卡片（发售价与社媒线索必须能一眼区分） */
.dress-card {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.dress-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dress-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.dress-tag {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.dress-tag.jp { color: #8a5a2b; border-color: #e2c9a8; background: #fbf3e8; }
.dress-tag.cn { color: #2f6b4f; border-color: #b9dcc8; background: #eef8f2; }
.dress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  margin-top: 8px;
}
.dress-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.dress-row span { flex: 0 0 auto; color: var(--muted); }
.dress-row b { min-width: 0; font-weight: 500; color: var(--ink); text-align: right; overflow-wrap: anywhere; }
.dress-note { margin-top: 6px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.dress-src { margin-top: 4px; font-size: 11px; color: var(--muted); word-break: break-all; }
.dress-src a { color: inherit; text-decoration: none; }
.dress-src a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 身材参数 */
/* 这部分由 profile.js 挂到「我的」页，样式单独一段 */

.body-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin: 4px 0 8px;
}
.body-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.body-field input {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}
.body-field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.body-field em { font-style: normal; font-size: 10.5px; opacity: .7; }

/* ---------------------------------------------------------------- 关注面板 */
/* 折叠卡片：摘要行始终可见，展开才载入内容，避免首屏被面板占满 */
.fold { padding: 0; overflow: hidden; }
.fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  transition: transform .15s;
}
.fold[open] > summary::after { transform: rotate(180deg); }
.fold-hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.fold-body { padding: 0 14px 14px; }

/* 关注项 */
.follow-events { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.follow-event {
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.55;
}
.follow-event.unread { border-left-color: var(--accent); background: #fdf6f7; }
.follow-event .head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
  font-size: 11.5px;
  color: var(--muted);
}
.follow-event .head b { color: var(--ink); font-size: 12.5px; }

.follow-list { border-top: 1px solid var(--line); }
.follow-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.follow-row .grow { flex: 1; min-width: 0; }
.follow-row .name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.follow-row .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.follow-del {
  flex: 0 0 auto;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 17px;
  line-height: 1.2;
  cursor: pointer;
}
.follow-empty { padding: 8px 0; font-size: 12.5px; color: var(--muted); }

.follow-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.follow-actions .hint { margin: 0; }

/* 回答下方的「持续关注」提议：只在未发售 / 预约类问题后出现 */
.follow-suggest {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.5;
}
.follow-suggest span { flex: 1 1 160px; min-width: 0; }
.follow-suggest .ghost.sm { padding: 5px 10px; font-size: 12.5px; }

/* ---------------------------------------------------------------- 窄屏（手机） */
/* 同一套 DOM，只收紧外边距、放开正文，不做第二套移动端页面。
   断点取 600px：375/390 都是整屏铺满，桌面仍是 720px 居中卡片。 */
@media (max-width: 600px) {
  :root { --pad: 10px; }

  /* 顶栏不再把标题和状态点分别拉到屏幕两端：手机上一行内容收紧，
     状态点跟着标题走，左右留白也抬到 14px，避免贴边。 */
  #topbar {
    justify-content: flex-start;
    gap: 8px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  /* 卡片去掉左右外框贴边，把 14px 的左右留白还给正文 */
  #view { padding: 8px 0 calc(20px + env(safe-area-inset-bottom)); }
  #view > .card {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    margin-bottom: 8px;
  }
  /* 贴边卡片的正文留 14px，和顶栏、折叠面板对齐，不再顶着屏幕边框 */
  #view > .card:not(.fold) { padding: 14px; }

  /* 长回答：正文 15px，行高略松，读起来不挤 */
  .bubble { font-size: 15px; line-height: 1.75; padding: 10px 12px; }
  .msg { max-width: 94%; }
  .chat-head { flex-wrap: wrap; row-gap: 6px; }

  /* 对话区高度跟着可视视口走，给下方输入区留出空间 */
  .chat-list {
    min-height: min(34vh, 300px);
    max-height: min(56vh, 520px);
    min-height: min(34dvh, 300px);
    max-height: min(56dvh, 520px);
  }

  /* iOS 焦点落到 <16px 的输入框会自动放大页面：这里固定 16px 避免跳动 */
  .chat-input textarea { font-size: 16px; }
  .chat-input textarea { scroll-margin-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .chat-input { gap: 8px; }
  .chat-input .primary { padding: 12px 20px; }

  /* 指纹/触屏上引用编号的点击热区比视觉框大 */
  .cite { position: relative; }

  /* 引用来源：长标题与长 URL 一律在块内折行 */
  .evidence summary { padding: 4px 0; }
  .ev-link { font-size: 11.5px; }

  /* 折叠摘要保持一行：提示文字超长时省略，箭头始终贴右 */
  .fold > summary { flex-wrap: nowrap; padding: 12px 14px; }
  .fold > summary .badge { flex: 0 0 auto; }
  .fold-hint {
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .fold-body { padding: 0 14px 14px; }

  .follow-event .head { font-size: 11.5px; }
  .follow-actions { gap: 8px; }

  /* 推荐问题：单条太长时在胶囊内折行，不撑破容器 */
  .chat-chips .chip {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
  }

  /* 逐通道进度：长通道名/长错误串折行，圆点对齐首行 */
  .recall-live { overflow-wrap: anywhere; }
  .recall-row { min-width: 0; align-items: flex-start; }
  .recall-row .dot { margin-top: 4px; }

  /* 登录页不居中留白，整屏可用；输入框 16px 避免 iOS 自动放大 */
  .auth-card { max-width: none; margin: 0; }
  .auth-card .auth-field input { font-size: 16px; }
  /* 窄屏：对话栏变成左侧抽屉，浮在聊天区上方，不挤压正文 */
  .chat-shell { display: block; }
  .thread-side {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(80vw, 300px);
    max-height: none;
    padding: calc(env(safe-area-inset-top) + 12px) 12px
             calc(12px + env(safe-area-inset-bottom));
    border-radius: 0 14px 14px 0;
    border-left: 0;
    box-shadow: 0 10px 30px rgba(48, 38, 40, .18);
    overflow-y: auto;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .2s ease, visibility .2s ease;
  }
  .thread-side.open { transform: none; visibility: visible; }
  .thread-toggle { display: inline-flex; }
  .thread-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(48, 38, 40, .32);
  }

  .toast { max-width: 88vw; }
}

/* 触屏（手机/平板）：把可点元素抬到手指能点中的高度。
   只在粗指针设备生效，桌面鼠标的点击密度保持原样。 */
@media (pointer: coarse) {
  .chip { min-height: 38px; padding: 8px 14px; font-size: 13.5px; }
  .chip.small { min-height: 32px; }
  button.ghost, a.ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
  }
  button.ghost.sm, a.ghost.sm { min-height: 40px; }
  .chat-input .primary { min-height: 46px; }
  .thread-open { min-height: 40px; padding-top: 0; padding-bottom: 0; }
  .thread-del { min-width: 40px; }

  /* 引用编号视觉不变，热区向四周扩 9px */
  .cite::after {
    content: '';
    position: absolute;
    inset: -9px -6px;
  }

  .steps summary, .evidence summary {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  /* 记忆/关注项的删除键：视觉仍是小 ×，热区抬到 40×40 */
  .follow-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    margin: -8px -6px -8px 0;
  }
}
