/* 纯静态样式，零依赖、零构建。
   T-125：两版差异由 :root[data-layout="desktop|mobile"] 分支给出，切换只改 dataset，不刷新。
   T-142：高度链 .shell → .chat → .workspace → .chat-pane → .chat-body → .messages
          每层都是可收缩 flex 项，只有最内层 .messages 滚动，页面本身不滚。 */
:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --ink: #2f2a24;
  --ink-soft: #7a7062;
  --line: #e7dfd0;
  --accent: #c2703c;
  --accent-ink: #ffffff;
  --pet-bubble: #fffdf8;
  --me-bubble: #f0d9bd;
  --danger: #a33b2a;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* T-142：页面本身永不滚动，内容一律在各容器内部消化。 */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.shell {
  /* T-142 根因 1：min-height 只给下限，内容会把容器撑高，于是整页跟着滚。
     改成定量高度 + 上限；vh 是 dvh 不支持时的兜底，dvh 跟随 iOS 地址栏伸缩。 */
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
}

h1 { margin: 0; font-weight: 650; letter-spacing: .02em; }
.subtitle { margin: 2px 0 0; color: var(--ink-soft); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.link-btn {
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 2px;
}

/* §5 告知：两版共用，不属于任何一版的专属容器 */
.notice {
  flex: 0 0 auto;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-soft);
  line-height: 1.6;
}

.toast {
  flex: 0 0 auto;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fbe9e4;
  border: 1px solid #eec8bd;
  color: var(--danger);
  font-size: 13px;
}

/* ---- 版本选择器（两版共用组件，分支只改尺寸/排布）---- */
.layout-picker { border-bottom: 1px solid var(--line); }
.layout-picker-title { margin: 0 0 10px; font-weight: 600; }
.layout-options { display: grid; grid-template-columns: 1fr 1fr; }
.layout-quick { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.layout-option {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-align: center;
}

.layout-option:hover { border-color: var(--accent); }
.layout-option[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.option-name { display: block; }
.option-desc { display: block; font-size: 11px; opacity: .78; margin-top: 2px; }
.layout-auto { margin: 10px 0 0; color: var(--ink-soft); }

/* ---- 兑换入口 ---- */
/* T-142：兑换页也要内部滚动。justify-content:flex-start + margin:auto：
   空间够时卡片居中，空间不够时 margin 退成 0，从顶部开始滚，不会裁掉头部。 */
.gate {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.gate-card {
  width: 100%;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(70, 55, 35, .06);
}

.gate-card h2 { margin: 0 0 8px; }
.gate-hint { margin: 0 0 20px; color: var(--ink-soft); }
.gate-card form { display: flex; flex-direction: column; gap: 10px; }

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194, 112, 60, .12); }

/* T-146 账号等同密码：默认 type=password，只有主动点「显示」才短暂露出。
   brain-viz/style.css 里有一份同结构规则，两处视觉与交互保持一致。 */
.secret-field { display: flex; align-items: stretch; gap: 8px; }
.secret-field input { flex: 1 1 auto; width: auto; min-width: 0; }
.secret-toggle {
  flex: 0 0 auto;
  min-width: 64px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.secret-toggle:hover { border-color: var(--accent); color: var(--accent); }
.secret-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.primary {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
}

.primary:disabled { opacity: .55; cursor: default; }
.field-error { margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.gate-side, .aside { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.gate-side h3, .aside h2 { margin: 0 0 10px; font-size: 15px; }
.gate-side ul { margin: 0; padding-left: 18px; color: var(--ink-soft); line-height: 1.9; }
.aside p { color: var(--ink-soft); }
.aside dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.aside dt { color: var(--ink-soft); }
.aside dd { margin: 0; overflow-wrap: anywhere; }
.aside-tip { border-top: 1px solid var(--line); padding-top: 10px; }

/* ---- T-148 顶部输入中提示：细、次要色、不抢注意力 ---- */
.typing-hint {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  padding: 6px 4px 8px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}
.typing-dots { display: inline-flex; align-items: center; gap: 3px; }
.typing-dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: .4;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-3px); opacity: .9; }
}
.typing-hint[data-state="failed"] { color: var(--danger); }
.typing-hint[data-state="failed"] .typing-dots { display: none; }
.typing-retry {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 1px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .typing-dots i { animation: none; opacity: .6; }
}

/* ---- 聊天共用骨架 ---- */
/* T-142 高度链：每一层都写成 flex:1 1 0 + min-height:0，保证高度能一层层传下去。 */
.chat { flex: 1 1 0; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
/* T-142 根因 2：原来这里没有 flex:1，.messages 的 flex:1 拿不到可分配空间；
   且两版把它改成 grid / block 后，子项的 flex:1 直接失效，grid 自动行被内容撑开。 */
.chat-body {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row { flex: 0 0 auto; min-width: 0; display: flex; }
.row.me { justify-content: flex-end; }
.row.pet { justify-content: flex-start; }

.bubble {
  min-width: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row.me .bubble { background: var(--me-bubble); border-bottom-right-radius: 6px; }
.row.pet .bubble { background: var(--pet-bubble); border: 1px solid var(--line); border-bottom-left-radius: 6px; }

.bubble.pending { opacity: .62; }
.bubble.failed { border: 1px solid #eec8bd; background: #fbe9e4; }
.bubble-meta { margin-top: 6px; font-size: 12px; color: var(--ink-soft); }

.retry-btn {
  margin-top: 8px;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  border-radius: 10px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.empty {
  flex: 0 0 auto;
  margin: auto;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.composer textarea {
  flex: 1;
  max-height: 160px;
  resize: none;
  line-height: 1.5;
}

.send { flex: none; }
.composer-hint { flex: 0 0 auto; color: var(--ink-soft); }

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

.noscript {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px; text-align: center; color: var(--danger); background: var(--bg);
}

/* =========================================================
   T-125 分支 A：手机版 —— 全屏、底部固定输入栏、单行、紧凑
   ========================================================= */
:root[data-layout="mobile"] .shell { max-width: none; padding: 0 12px env(safe-area-inset-bottom); }
/* T-203 验收 4：375px 下旧布局 .topbar 横排 + actions flex:none（四按钮约 280px）
   把 .brand 挤到 ~50px，标题逐字竖排。改两行：品牌独占一行横排，工具栏第二行可换行。 */
:root[data-layout="mobile"] .topbar {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 10px;
  padding: 12px 0 8px;
}
:root[data-layout="mobile"] .brand { flex: 1 1 100%; min-width: 0; }
:root[data-layout="mobile"] .brand > div { flex: 1; min-width: 0; }
:root[data-layout="mobile"] .topbar-actions {
  flex: 1 1 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px 10px;
}
:root[data-layout="mobile"] .avatar { width: 38px; height: 38px; font-size: 20px; }
:root[data-layout="mobile"] h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-layout="mobile"] .subtitle { font-size: 11px; }
:root[data-layout="mobile"] .notice { font-size: 12px; }
:root[data-layout="mobile"] .layout-quick { font-size: 11px; }
:root[data-layout="mobile"] .layout-quick .layout-option { padding: 5px 8px; border: 0; border-radius: 0; font-size: 11px; }
:root[data-layout="mobile"] .layout-picker { padding: 0 0 16px; margin-bottom: 16px; }
:root[data-layout="mobile"] .layout-picker-title { font-size: 14px; }
:root[data-layout="mobile"] .layout-options { gap: 8px; }
:root[data-layout="mobile"] .layout-options .layout-option { padding: 12px 8px; border-radius: 12px; font-size: 15px; }
:root[data-layout="mobile"] .layout-auto { font-size: 11px; }

:root[data-layout="mobile"] .gate { padding: 16px 0 40px; }
:root[data-layout="mobile"] .gate-card { max-width: 420px; padding: 20px 16px; }
:root[data-layout="mobile"] .gate-card h2 { font-size: 18px; }
:root[data-layout="mobile"] .gate-hint { font-size: 13px; }
:root[data-layout="mobile"] .gate-body { display: block; }
:root[data-layout="mobile"] .gate-side { display: none; }

:root[data-layout="mobile"] .chat-body { display: flex; flex-direction: column; }
:root[data-layout="mobile"] .aside { display: none; }
:root[data-layout="mobile"] .messages { padding: 12px 2px 100px; }
/* T-203 验收 4③：气泡区占满宽度且可读（82% → 94%，长文不再压成窄条）。
   历史气泡有更高优先级的 .row.history-row .bubble(84%)，手机版一并抬到 94%。 */
:root[data-layout="mobile"] .bubble { max-width: 94%; font-size: 15px; }
:root[data-layout="mobile"] .row.history-row .bubble { max-width: 94%; }

:root[data-layout="mobile"] .composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 18px rgba(70, 55, 35, .07);
}
:root[data-layout="mobile"] .composer textarea { min-height: 46px; }
:root[data-layout="mobile"] .send { min-width: 76px; height: 46px; padding: 0 16px; }
:root[data-layout="mobile"] .composer-hint { display: none; }

/* =========================================================
   T-125 分支 B：电脑版 —— 900-1100px 居中、双栏 aside、多行输入
   ========================================================= */
:root[data-layout="desktop"] .shell { max-width: 1040px; padding: 0 32px 24px; }
:root[data-layout="desktop"] .topbar { padding: 24px 0 14px; }
:root[data-layout="desktop"] .avatar { width: 48px; height: 48px; font-size: 26px; }
:root[data-layout="desktop"] h1 { font-size: 22px; }
:root[data-layout="desktop"] .subtitle { font-size: 13px; }
:root[data-layout="desktop"] .notice { font-size: 13px; padding: 12px 16px; }
:root[data-layout="desktop"] .layout-quick .layout-option { padding: 7px 14px; border: 0; border-radius: 0; font-size: 13px; }
:root[data-layout="desktop"] .layout-picker { padding: 0 0 22px; margin-bottom: 22px; }
:root[data-layout="desktop"] .layout-picker-title { font-size: 16px; }
:root[data-layout="desktop"] .layout-options { gap: 12px; max-width: 520px; }
:root[data-layout="desktop"] .layout-options .layout-option { padding: 14px; border-radius: 12px; font-size: 16px; }
:root[data-layout="desktop"] .layout-auto { font-size: 12px; }

:root[data-layout="desktop"] .gate { padding: 32px 0 64px; }
:root[data-layout="desktop"] .gate-card { max-width: 900px; padding: 32px; }
:root[data-layout="desktop"] .gate-card h2 { font-size: 21px; }
:root[data-layout="desktop"] .gate-hint { font-size: 14px; }
:root[data-layout="desktop"] .gate-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 32px;
  align-items: start;
}
:root[data-layout="desktop"] .gate-side { display: block; padding: 16px; font-size: 13px; }

/* T-142：原来是 grid，.messages 的 flex:1 对 grid item 无效，自动行高被内容撑开，
   高度链在这里断开。改为 flex 行，消息列可收缩、侧栏自己滚。 */
:root[data-layout="desktop"] .chat-body {
  flex-direction: row;
  align-items: stretch;
  gap: 24px;
}
:root[data-layout="desktop"] .messages { flex: 1 1 0; min-width: 0; padding: 12px 4px 18px; }
:root[data-layout="desktop"] .aside {
  flex: 0 0 280px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: block;
  padding: 18px;
  font-size: 13px;
}
:root[data-layout="desktop"] .bubble { max-width: 70%; font-size: 15px; }

:root[data-layout="desktop"] .composer { position: static; padding: 14px 0 0; box-shadow: none; }
:root[data-layout="desktop"] .composer textarea { min-height: 88px; }
:root[data-layout="desktop"] .send { min-width: 96px; height: 88px; padding: 0 20px; }
:root[data-layout="desktop"] .composer-hint { display: block; margin: 8px 0 0; font-size: 12px; }

/* =========================================================
   T-139 电脑版同屏：左聊天 / 可拖拽分隔条 / 右 3D 图谱
   手机版沿用同一套 DOM，但只做单列 + 全屏浮层，绝不挤成两半。
   ========================================================= */

.workspace { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.chat-pane { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.viz-open[aria-pressed="true"] { color: var(--accent); font-weight: 600; }

.viz-resizer {
  flex: none;
  width: 8px;
  cursor: col-resize;
  border-radius: 4px;
  background: var(--line);
  touch-action: none;
}
.viz-resizer:hover, .viz-resizer:focus-visible { background: var(--accent); outline: none; }

.viz-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #070d1c;
  border: 1px solid #1b2c4a;
  border-radius: 14px;
}
.viz-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  color: #e8f1ff;
  border-bottom: 1px solid rgba(125, 211, 252, .18);
}
.viz-head strong { font-size: 14px; }
.viz-state { margin-left: 8px; font-size: 11px; color: #7dd3fc; }
.viz-head-actions { display: flex; gap: 12px; flex: none; }
.viz-head .link-btn { color: #7dd3fc; font-size: 12px; }

.viz-stage { position: relative; flex: 1 1 0; min-height: 0; }
#viz-canvas { display: block; width: 100%; height: 100%; }
.viz-tooltip {
  position: absolute;
  min-width: 180px;
  max-width: 260px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(8, 16, 32, .94);
  border: 1px solid rgba(125, 211, 252, .35);
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
  pointer-events: none;
  z-index: 2;
}
.tip-title { font-weight: 600; color: #7dd3fc; margin-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 10px; }
.tip-row span:first-child { color: #8195b5; flex: none; }
.tip-row span:last-child { text-align: right; overflow-wrap: anywhere; }
.viz-notice {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(7, 13, 28, .9);
  border: 1px solid rgba(125, 211, 252, .3);
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.7;
  z-index: 2;
}
/* T-150：右下角轨迹提示走 .viz-notice，右上角这个只放截断计数 / 图谱不可用。 */
.viz-graph-notice {
  position: absolute;
  right: 14px;
  top: 14px;
  margin: 0;
  max-width: 220px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(7, 13, 28, .88);
  border: 1px solid rgba(125, 211, 252, .28);
  color: #9fb6d4;
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
  z-index: 3;
}
.viz-graph-notice[hidden] { display: none; }

.viz-stats {
  flex: none;
  margin: 0;
  padding: 7px 14px;
  color: #93a4c0;
  font-size: 11px;
  border-top: 1px solid rgba(125, 211, 252, .14);
}

/* ---- 分支 A：手机版 —— 单列不变，图谱是一个可点开的全屏浮层 ---- */
:root[data-layout="mobile"] .workspace { display: block; }
:root[data-layout="mobile"] .chat-pane { height: 100%; }
:root[data-layout="mobile"] .viz-resizer { display: none !important; }
:root[data-layout="mobile"] .viz-pane {
  position: fixed;
  inset: 0;
  z-index: 30;
  border-radius: 0;
  border: 0;
}
:root[data-layout="mobile"] .viz-head { padding-top: calc(10px + env(safe-area-inset-top)); }
:root[data-layout="mobile"] .viz-stats { padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
:root[data-layout="mobile"] .chat-body { flex-direction: column; }

/* ---- 分支 B：电脑版 —— 只在展开时三栏（聊天 / 分隔条 / 图谱）---- */
:root[data-layout="desktop"] .workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* T-142：唯一行必须可收缩，否则右栏 3D 面板会把整行、整页撑高。 */
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}
:root[data-layout="desktop"] .workspace[data-viz="open"] {
  grid-template-columns: minmax(0, calc(var(--viz-split, 55%) - 4px)) 8px minmax(0, 1fr);
}
/* 展开后左侧不再塞 aside，55% 全给聊天，避免被挤成窄条。
   T-142：chat-body 已改成 flex，隐藏 aside 即让消息列占满；不再用 grid 列覆盖。 */
:root[data-layout="desktop"] .workspace[data-viz="open"] .aside { display: none; }
:root[data-layout="desktop"] .viz-pane { min-height: 0; }

/* ---- T-170 页面内全屏 ----
   刻意不用 Fullscreen API：iframe / 企业策略下 requestFullscreen 会直接失败。
   只把 viz-pane 改 fixed 铺满 + 抬高层级；chat-pane 用 visibility:hidden
   （不是 display:none、更不 remove），DOM、输入草稿、滚动位置全部原样保留。
   面板自带的清空 / 全屏 / 收起按钮与底部统计都在 viz-pane 内，铺满后仍可访问。 */
.viz-account { margin-left: 10px; font-size: 11px; color: #9fb6d4; }
.viz-account[hidden] { display: none; }
:root .workspace[data-full="open"] .viz-pane {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border-radius: 0;
  border: 0;
}
:root .workspace[data-full="open"] .chat-pane,
:root .workspace[data-full="open"] .viz-resizer { visibility: hidden; }
/* 手机版本来就是铺满的全屏浮层，没有「非全屏」态可切换，隐藏按钮避免语义重复，
   同时保证 mobile 单列布局完全不受影响。 */
:root[data-layout="mobile"] #viz-fullscreen { display: none; }

.beta-tag {
  font-size: .62em;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: .02em;
  margin-left: 2px;
  vertical-align: 2px;
}

/* ---- T-152 刷新恢复历史：状态条 + 历史气泡（文档流内，不遮挡输入区） ---- */
.history-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 4px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}
.history-status[data-state="failed"] { color: var(--danger); }
.history-status.loading #history-status-text::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: #7dd3fc;
  animation: history-pulse 1s ease-in-out infinite;
}
@keyframes history-pulse { 0%, 100% { opacity: .2; } 50% { opacity: .95; } }
@media (prefers-reduced-motion: reduce) {
  .history-status.loading #history-status-text::before { animation: none; opacity: .6; }
}
.history-retry {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 1px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
/* 一轮历史 = 一行 = 两个气泡（用户 + 宠物），老的在上；悬停只高亮星点，不改样式闪烁。 */
.row.history-row {
  flex-direction: column;
  gap: 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}
.row.history-row .bubble { max-width: 84%; opacity: .82; }
.row.history-row .history-me {
  align-self: flex-end;
  background: var(--me-bubble);
  border-bottom-right-radius: 6px;
}
.row.history-row .history-pet {
  align-self: flex-start;
  background: var(--pet-bubble);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
