/* ============================================================
   幸运家 · 前端样式
   ------------------------------------------------------------
   这个产品有件别处没有的事实：AI 跑在家里那台电脑上，它醒着才有人应答。
   所以"在家 / 不在家"用一个独立的语义色（绿/灰），而不是品牌色——
   在线是状态不是身份，占用主色会让状态变化看起来像品牌在闪。

   主色是靛蓝 #2b4570：够沉静，既压得住一条健康回答，也不跟小孩的画打架。
   底色走白 + 浅灰，克制留白，正文 15px；读者跨三代人，可读性靠对比度和
   节奏拿，而不是靠把字放大。

   一处刻意的不对称：**提问是淡底小气泡，回答不套卡片**，直接铺在画布上。
   把每条消息都塞进一样的圆角卡片是最省事也最没主张的做法，而且长回答
   （健康那种三段式）套进卡片会变得很难读。只有图片和歌曲这类"东西"才进容器。

   手机端（家里人主要从微信里打开）三条铁律：
   1. 所有输入框字号 ≥ 16px。iOS 对小于 16px 的输入框会在聚焦时把整页放大，
      放大后右边被裁掉——微信里截到的"发送键只剩半个、在家两个字缺一个"就是它。
   2. 输入框的工具行永远一行：技能 chip 是横向可滑的一条，不换行。换行会把
      加图按钮孤零零甩在左边、发送键悬在半空。
   3. 悬停不是触屏的语言：:hover 只写在 (hover: hover) 里，触屏用 :active 反馈；
      "悬停才出现"的东西（复制、删对话）在触屏上直接显示，否则家里人永远点不到。
   ============================================================ */

:root {
  color-scheme: light;

  /* 底与纸 */
  --ground: #f5f6f8;
  --paper: #ffffff;
  --raised: #ffffff;
  --hover: #eef0f4;
  --pressed: #e5e8ee;
  --sunken: #eceef2;

  /* 墨 */
  --ink: #1c2027;
  --ink-2: #5b6472;
  --ink-3: #7e8795;

  /* 主色：靛蓝 */
  --accent: #2b4570;
  --accent-2: #3a5c94;
  --accent-ink: #1e3255;
  --accent-tint: #eef2f8;
  --accent-line: rgba(43, 69, 112, 0.22);
  --accent-ring: rgba(43, 69, 112, 0.16);

  /* 状态（语义色，不进品牌）*/
  --on: #1f9d6b;
  --off: #a5adb9;
  --danger: #c0392f;
  --danger-tint: #fdf0ee;

  /* 毛边用 rgba：叠在纸、浅灰、深色上都不出硬边 */
  --line: rgba(28, 32, 39, 0.1);
  --line-strong: rgba(28, 32, 39, 0.17);
  --line-soft: rgba(28, 32, 39, 0.06);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow: 0 1px 2px rgba(19, 26, 40, 0.05), 0 4px 12px -6px rgba(19, 26, 40, 0.09);
  --shadow-pop: 0 2px 6px rgba(19, 26, 40, 0.07), 0 20px 44px -20px rgba(19, 26, 40, 0.22);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 264px;
  --read-w: 62ch; /* 正文行长上限：中文 62 字左右一行，比 80 更好读 */
  --card-pad: 18px;

  /* 安全区：刘海屏 / 底部手势条。桌面上都是 0 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --ground: #14171c;
    --paper: #1b1f26;
    --raised: #1f242c;
    --hover: #262c36;
    --pressed: #2e3540;
    --sunken: #171b21;

    --ink: #e8ebf0;
    --ink-2: #a4adba;
    --ink-3: #737d8b;

    --accent: #7fa2dd;
    --accent-2: #93b3e8;
    --accent-ink: #b9cef0;
    --accent-tint: #1e2735;
    --accent-line: rgba(127, 162, 221, 0.3);
    --accent-ring: rgba(127, 162, 221, 0.24);

    --on: #35c78d;
    --off: #6b7482;
    --danger: #ef6a5e;
    --danger-tint: #2a1c1b;

    --line: rgba(232, 235, 240, 0.12);
    --line-strong: rgba(232, 235, 240, 0.2);
    --line-soft: rgba(232, 235, 240, 0.07);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px -6px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 2px 8px rgba(0, 0, 0, 0.36), 0 20px 48px -20px rgba(0, 0, 0, 0.66);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 整页固定一屏高，各页面在自己内部滚。dvh 跟着手机浏览器的地址栏伸缩，
   不支持的老内核退回 100%。 */
html { height: 100%; -webkit-text-size-adjust: 100%; }
@supports (height: 100dvh) { html { height: 100dvh; } }
body, #root { height: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--ground);
  overflow-x: hidden; /* 任何一处算错宽度都不该让整页横着滚 */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  background: none;
  border: none;
  touch-action: manipulation; /* 关掉双击放大：家里人点两下按钮不该把页面放大 */
  -webkit-tap-highlight-color: transparent; /* 安卓/微信那层灰色闪一下太廉价，:active 自己给反馈 */
}
a { color: var(--accent); -webkit-tap-highlight-color: transparent; }

/* 键盘可达性：所有可聚焦元素都有看得见的焦点环 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-ring); }

.boot { height: 100%; display: grid; place-items: center; color: var(--ink-3); }

/* 数字不跳宽：时间戳、用量、张数都用等宽数字位 */
.tnum { font-variant-numeric: tabular-nums; }

/* ---------------- 应用外壳 ---------------- */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* 门牌：一个小房子，窗口亮着 = 家里那台电脑醒着。
   全站唯一一处用暖色的地方，别的地方一律不要。 */
.house { width: 22px; height: 22px; flex: none; color: var(--accent); }
.house .win { fill: var(--off); transition: fill 0.35s var(--ease); }
.house.lit .win { fill: #ffc75a; }

.home-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}
.home-state .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--off);
}
.home-state.on .dot { background: var(--on); }
.home-state.on { color: var(--ink-2); }

.side-new {
  margin: 0 12px 10px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  font-weight: 550;
  transition: background 0.15s, border-color 0.15s;
}
.side-new:active { background: var(--pressed); }
.side-new svg { width: 15px; height: 15px; flex: none; }

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.conv-empty { padding: 18px 12px; color: var(--ink-3); font-size: 13px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s;
}
.conv-item:active { background: var(--pressed); }
.conv-item.active { background: var(--accent-tint); color: var(--accent-ink); font-weight: 550; }

.conv-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.conv-time { font-size: 11.5px; color: var(--ink-3); flex: none; }
.conv-del {
  flex: none;
  width: 22px; height: 22px;
  display: none;
  align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
}
/* 键盘走到这一行时也要露出删除键，不只靠鼠标悬停 */
.conv-item:focus-within .conv-del { display: flex; }

.side-foot {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
}
.side-foot .who {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.side-foot .who:active { background: var(--pressed); }
.side-foot .who.active { background: var(--accent-tint); color: var(--accent-ink); }
.avatar {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
}
.who-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
}

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* 移动端顶栏：桌面不显示 */
.topbar { display: none; }

/* ---------------- 首页 ---------------- */

.home {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* 底边多留一截：视觉重心比几何中心略高才显得"稳"，正好居中反而像往下坠 */
  padding: 32px 24px calc(40px + 6vh);
}
.home-inner { width: 100%; max-width: 720px; margin: 0 auto; }

/* 问候是首页唯一的字体重音：大一档、字重 650、字距收紧。
   不加副标签、不加装饰线——它自己就够。 */
.greet {
  font-size: 27px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.greet-sub { color: var(--ink-3); margin-bottom: 22px; }

.suggests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.suggest {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raised);
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: left;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.suggest:active { background: var(--pressed); }

/* ---------------- 输入框（这是全站唯一花力气的地方）---------------- */

.composer {
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 8px 11px 6px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.composer:focus-within {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-pop), 0 0 0 3px var(--accent-ring);
}

/* 16px 不是审美，是 iOS 的门槛：小于它就会在聚焦时把整页放大（见文件头） */
.composer textarea {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: none;
  font-size: 16px;
  line-height: 1.6;
  max-height: 220px;
  padding: 4px 2px;
}
.composer textarea::placeholder { color: var(--ink-3); }

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-top: 6px;
}
.spacer { flex: 1; }

/* 技能 chip 是一条横向可滑的带子：窄屏放不下时滑，不换行。
   上下各留 2px 内边距再用负 margin 收回——不然焦点环会被 overflow 切掉。 */
.task-chips {
  display: flex;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 3px 0;
  margin: -3px 0;
}
.task-chips::-webkit-scrollbar { display: none; }
/* 右边还有没露出来的 chip 时，边上淡出一截当提示（tasks.jsx 里量出来的） */
.task-chips.more {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.task-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.task-chip:active:not(:disabled) { background: var(--pressed); }
.task-chip:disabled { opacity: 0.45; cursor: not-allowed; }
.task-icon { width: 15px; height: 15px; flex: none; }

/* 待发送的图：输入框壳内顶部一排缩略图 */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 0 8px; }
.thumb {
  position: relative;
  width: 62px; height: 62px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--sunken);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.bad { border-color: var(--danger); }
.thumb-mask {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  background: rgba(12, 15, 20, 0.55);
  color: #fff;
  font-size: 11.5px;
}
.thumb-x {
  position: absolute;
  top: 2px; right: 2px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(12, 15, 20, 0.6);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

.attach {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  transition: background 0.15s, color 0.15s;
}
.attach:active:not(:disabled) { background: var(--pressed); }
.attach:disabled { opacity: 0.4; cursor: not-allowed; }
.attach svg { width: 17px; height: 17px; }

/* 拖图进来时给整个输入框一圈提示 */
.composer.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.composer-tags { padding: 2px 0 6px; }
.task-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 9px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-ink);
  border: 1px solid var(--accent-line);
  font-size: 13px;
  font-weight: 550;
}
.task-count {
  border: none;
  background: none;
  color: inherit;
  font-size: 12.5px;
  padding: 0 2px;
  cursor: pointer;
}
.task-tag-x {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--accent-ink);
  opacity: 0.6;
  font-size: 14px;
  line-height: 1;
}
.task-tag-x:active { opacity: 1; background: rgba(0, 0, 0, 0.06); }

.send {
  flex: none;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  transition: transform 0.14s var(--ease), background 0.14s, opacity 0.14s;
}
.send:active:not(:disabled) { transform: scale(0.93); }
.send:disabled { opacity: 0.32; cursor: not-allowed; }
.send svg { width: 16px; height: 16px; }
.send.stop { background: var(--ink); }
.icon-stop { width: 10px; height: 10px; border-radius: 2px; background: currentColor; }

.composer-hint { font-size: 12px; color: var(--ink-3); }

/* ---------------- 对话 ---------------- */

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain; /* 微信里滚到顶再拉一下会整页刷新，把它拦在这层 */
  padding: 24px 24px 8px;
}
.chat-col { width: 100%; max-width: 760px; margin: 0 auto; }
.chat-input { padding: 10px 24px 22px; }
.chat-input .chat-col { max-width: 760px; }

.turn + .turn { margin-top: 26px; }

/* 提问：淡底小气泡，右对齐，宽度跟着内容走 */
.ask {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}
.ask > div {
  max-width: 82%;
  padding: 9px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--accent-tint);
  color: var(--accent-ink);
  word-break: break-word;
}
/* 文字保留换行，但图不能被 pre-wrap 影响，所以只给文字这一层 */
.ask-text { white-space: pre-wrap; }

/* 提问里带的图：贴着气泡上沿，最多一行四张 */
.ask-pics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 8px;
}
.ask-pics:last-child { margin-bottom: -2px; } /* 只发图不写字时不留下沿空隙 */
.ask-pics a {
  display: block;
  width: 96px; height: 96px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sunken);
}
.ask-pics img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 回答：不套卡片，直接铺画布 */
.answer {
  font-size: 16px;
  line-height: 1.8;
  max-width: var(--read-w);
  overflow-wrap: anywhere; /* 长链接、长英文串不能把手机页面撑宽 */
}
.answer > * + * { margin-top: 0.85em; }
.answer h1, .answer h2, .answer h3 { line-height: 1.4; font-weight: 650; }
.answer h1 { font-size: 1.32em; }
/* h2 带一道主色短竖线：健康回答的三段（解答/居家建议/何时就医）
   靠它形成节奏，一眼看得出走到哪一段了 */
.answer h2 {
  font-size: 1.14em;
  padding-left: 11px;
  border-left: 3px solid var(--accent);
  margin-top: 1.5em;
}
.answer h3 { font-size: 1.04em; margin-top: 1.2em; }
.answer ul, .answer ol { padding-left: 1.35em; }
.answer li + li { margin-top: 0.3em; }
.answer code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.12em 0.36em;
  border-radius: 5px;
  background: var(--sunken);
}
.answer pre {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--sunken);
  overflow-x: auto;
}
.answer pre code { background: none; padding: 0; }
.answer blockquote {
  padding: 8px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
  background: var(--sunken);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.answer table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.answer th, .answer td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.answer th { background: var(--sunken); font-weight: 600; }
.answer a { text-decoration: underline; text-underline-offset: 2px; }
.answer img { max-width: 100%; border-radius: var(--radius-sm); }

/* 打字光标：只在还在写的那段末尾 */
.answer.streaming > :last-child::after {
  content: "";
  display: inline-block;
  width: 2px; height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: blink 1.1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 健康回答底部的免责：小字，不抢戏，但每条都在。
   用 ink-2 而不是 ink-3——这是安全提示，读者又多半是长辈，
   看不清的警告等于没有警告。 */
.disclaimer {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-2);
  max-width: var(--read-w);
}

.answer-tools {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}
.answer-tools:focus-within { opacity: 1; }
.tool-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
}
.tool-btn:active { background: var(--pressed); }

/* ---------------- 执行过程时间线（默认折叠）---------------- */

.steps { margin-bottom: 12px; max-width: var(--read-w); }

.steps-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--ink-2);
  font-size: 13px;
  text-align: left;
}
/* 中间那段摘要按需截断，两头的圆点与「看看」始终留着 */
.steps-toggle > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.steps-toggle .steps-caret, .steps-toggle .steps-elapsed { flex: none; }
.steps-toggle:active { background: var(--pressed); }
.steps-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.steps-dot.running { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.28; } }
.steps-caret { color: var(--ink-3); font-size: 12px; }
.steps-elapsed { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

.steps-list {
  list-style: none;
  margin-top: 8px;
  padding-left: 4px;
  border-left: 1px solid var(--line);
}
.steps-list li {
  display: flex;
  gap: 8px;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.steps-list li.failed { color: var(--danger); }
.step-verb {
  flex: none;
  min-width: 2.6em;
  color: var(--ink-3);
  font-size: 12px;
  padding-top: 1px;
}
.step-text { min-width: 0; word-break: break-word; }

.step-say {
  padding: 4px 0 4px 12px;
  font-size: 13.5px;
  color: var(--ink-2);
}

/* ---------------- 产物：图片与歌曲 ---------------- */

.arts { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.art-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  max-width: 560px;
}
.art-images a {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--sunken);
  aspect-ratio: 1;
}
.art-images img { width: 100%; height: 100%; object-fit: cover; display: block; }

.art-audio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  max-width: 460px;
}
.art-audio .meta { min-width: 0; flex: 1; }
.art-audio .name {
  font-weight: 550;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.art-audio audio { width: 100%; margin-top: 6px; }

.art-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
}
.art-file:active { background: var(--pressed); }
.art-size { color: var(--ink-3); font-size: 12px; }

/* ---------------- 提示条 ---------------- */

.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 14px;
}
.notice.warn { background: var(--accent-tint); color: var(--accent-ink); }
.notice.error {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid var(--line-soft);
}
.notice .retry { margin-left: 8px; text-decoration: underline; color: inherit; }

/* ---------------- 「我的」 ---------------- */

.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 24px 48px;
}
.page-inner { max-width: 720px; margin: 0 auto; }
.page h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-bottom: 18px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--card-pad);
}
.card + .card { margin-top: 14px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
/* 名字与「改称呼」同一行：按钮贴在名字右边，而不是甩到卡片另一端——
   它改的就是左边那个名字，离得越近越不用想 */
.name-line { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.name-line h3 { margin-bottom: 0; font-size: 17px; }
.row-btns { display: flex; gap: 8px; }
.card .hint { color: var(--ink-3); font-size: 13px; margin-top: 8px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--ink-2); }
.field input, .field select {
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--raised);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--raised);
  font-weight: 550;
  transition: background 0.15s, border-color 0.15s;
}
.btn:active:not(:disabled) { background: var(--pressed); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:active:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-sm { padding: 5px 11px; font-size: 13px; font-weight: 500; }
.btn-danger { color: var(--danger); }
.btn-danger:active:not(:disabled) { background: var(--danger-tint); }

.msg { color: var(--on); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}
.row:first-child { border-top: none; }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--ink-3); font-size: 12.5px; }
.row code {
  font-family: var(--mono);
  font-size: 13px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--sunken);
}
.tag-off {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-tint);
  color: var(--danger);
}
.tag-admin {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.usage-total {
  display: flex;
  gap: 26px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.usage-total div { display: flex; flex-direction: column; }
.usage-total b {
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.usage-total span { font-size: 12.5px; color: var(--ink-3); }

/* ---------------- 全家用量（管理员） ---------------- */

/* 明细表七列，720 放不下；这页放宽一档，其余页面不动 */
.page-inner.wide { max-width: 880px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { flex: 1; margin-bottom: 0; }

/* 时间窗切换：一组贴在一起的小按钮，选中的那个填色 */
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--raised);
}
.seg-btn { padding: 5px 11px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
.seg-btn:focus-visible { outline-offset: -2px; border-radius: 0; }

.ustats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.ustat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ustat b { font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.ustat span { font-size: 12.5px; color: var(--ink-3); }
.ustat.warn b { color: var(--danger); }

/* 按人：整行可点当筛选；条形是占全家的比例，不是绝对量 */
.urow {
  width: calc(100% + 16px);
  margin: 0 -8px;
  padding: 10px 8px;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.urow.on { background: var(--accent-tint); }
.urow-name { display: block; }
.urow-n { font-weight: 600; }
.ubar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.5;
  margin-top: 6px;
  transition: width 0.3s var(--ease);
}
.urow.on .ubar { opacity: 0.85; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--raised);
  transition: background 0.15s, border-color 0.15s;
}
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chip i { font-style: normal; color: var(--ink-3); font-size: 12px; }
.chip.on { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-ink); }
.chip.on b, .chip.on i { color: inherit; }

/* 明细表：让它在卡片里横向滚，页面本身永远不横滚 */
.utable-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  margin: 0 calc(-1 * var(--card-pad));
  padding: 0 var(--card-pad);
}
.utable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.utable th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.utable td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.utable tbody tr:last-child td { border-bottom: none; }
.utable th:first-child, .utable td:first-child { padding-left: 0; }
.utable th:last-child, .utable td:last-child { padding-right: 0; }
.utable .num { text-align: right; font-variant-numeric: tabular-nums; }
.utable .dim { color: var(--ink-3); }
.utable .empty { text-align: center; color: var(--ink-3); padding: 22px 0; white-space: normal; }
.umore { display: flex; justify-content: center; padding-top: 12px; }

.tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag-ok { background: rgba(31, 157, 107, 0.12); color: var(--on); }
.tag-err { background: var(--danger-tint); color: var(--danger); }
.tag-muted { background: var(--sunken); color: var(--ink-3); }

/* ---------------- 登录 ---------------- */

.auth {
  height: 100%;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-box { width: 100%; max-width: 340px; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}
.auth-brand .house { width: 26px; height: 26px; }
.auth-sub { color: var(--ink-3); margin-bottom: 22px; font-size: 14px; }
.auth-switch {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
}
.auth-switch button { color: var(--accent); text-decoration: underline; }

/* ---------------- 悬停：只给真有鼠标的设备 ----------------
   触屏上 :hover 会在点过之后一直粘着（iOS 尤甚），看起来像按钮坏了。 */

@media (hover: hover) {
  .side-new:hover { background: var(--hover); border-color: var(--line-strong); }
  .conv-item:hover { background: var(--hover); }
  .conv-item:hover .conv-del { display: flex; }
  .conv-del:hover { background: var(--danger-tint); color: var(--danger); }
  .side-foot .who:hover { background: var(--hover); }
  .suggest:hover { border-color: var(--accent-line); color: var(--accent-ink); background: var(--accent-tint); }
  .task-chip:hover:not(:disabled) {
    border-color: var(--accent-line);
    color: var(--accent-ink);
    background: var(--accent-tint);
  }
  .thumb-x:hover { background: rgba(12, 15, 20, 0.85); }
  .attach:hover:not(:disabled) { background: var(--hover); color: var(--ink-2); }
  .task-tag-x:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
  .send:hover:not(:disabled) { background: var(--accent-2); }
  .turn:hover .answer-tools { opacity: 1; }
  .tool-btn:hover { background: var(--hover); color: var(--ink); }
  .steps-toggle:hover { background: var(--hover); }
  .art-file:hover { background: var(--hover); }
  .btn:hover:not(:disabled) { background: var(--hover); }
  .btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
  .btn-danger:hover:not(:disabled) { background: var(--danger-tint); }
  .seg-btn:hover:not(.on) { background: var(--hover); }
  .urow:hover { background: var(--hover); }
  .chip:hover:not(.on) { background: var(--hover); }
  .topbar .menu:hover { background: var(--hover); }
}

/* 触屏：悬停才出现的东西直接摆出来 */
@media (hover: none) {
  .answer-tools { opacity: 1; }
  .conv-del { display: flex; opacity: 0.55; }
  .conv-item.active .conv-del { opacity: 0.8; }
}

/* ---------------- 移动端 ---------------- */

.scrim { display: none; }

@media (max-width: 820px) {
  :root { --card-pad: 16px; }

  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, var(--sidebar-w));
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.24s var(--ease);
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: none; }
  .side-head { padding-top: max(16px, var(--safe-t)); padding-left: max(16px, var(--safe-l)); }
  .side-foot { padding-bottom: calc(10px + var(--safe-b)); }
  .conv-item { padding: 10px 10px; }
  .conv-del { width: 28px; height: 28px; }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(12, 15, 20, 0.4);
    animation: fade 0.2s;
  }
  @keyframes fade { from { opacity: 0; } }

  .topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    padding-top: max(8px, var(--safe-t));
    border-bottom: 1px solid var(--line);
    background: var(--paper);
  }
  .topbar .menu {
    flex: none;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
  }
  .topbar .menu:active { background: var(--pressed); }
  .topbar .t-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
  }
  .topbar .t-title .house { width: 20px; height: 20px; }
  .topbar .t-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .home-state { font-size: 12.5px; }

  /* 首页：问候靠上站稳，键盘弹起来时输入框还在视野里 */
  .home { justify-content: flex-start; padding: 6vh 16px calc(24px + var(--safe-b)); }
  .greet { font-size: 24px; }
  .greet-sub { margin-bottom: 16px; font-size: 14.5px; }
  .suggests { margin-top: 14px; gap: 8px; }
  /* 指头点的地方要够大：每条至少 40px 高 */
  .suggest { padding: 9px 14px; font-size: 14.5px; line-height: 1.5; }

  /* 手机上换成微信/短信那种排法：加图 | 输入 | 发送 一行，技能 chip 单独铺满一行。
     桌面那种"工具行挤在输入框底下"在 360px 上根本放不下三个带图标的 chip——
     chip 行不再跟两个按钮抢宽度，就放得下了；四个时横向滑。
     display: contents 让 .composer-row 的孩子直接落进网格，DOM 不用分两份。 */
  .composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "thumbs thumbs thumbs"
      "tags   tags   tags"
      "attach text   send"
      "chips  chips  chips";
    align-items: end;
    column-gap: 6px;
    padding: 6px 8px;
    border-radius: 20px;
  }
  .composer-row { display: contents; }
  .thumbs { grid-area: thumbs; padding: 4px 4px 8px; }
  .composer-tags { grid-area: tags; padding: 4px 4px 6px; }
  .attach { grid-area: attach; }
  .composer textarea { grid-area: text; min-height: 36px; padding: 6px 4px; }
  .send { grid-area: send; }
  .spacer { display: none; }
  .task-chips { grid-area: chips; margin: 4px 0 -1px; padding: 3px 2px; }
  .task-chip { padding: 7px 11px; font-size: 13.5px; }
  .task-icon { width: 16px; height: 16px; }
  .attach { width: 36px; height: 36px; }
  .attach svg { width: 19px; height: 19px; }
  .send { width: 36px; height: 36px; }
  .send svg { width: 17px; height: 17px; }
  .task-tag { padding: 5px 7px 5px 10px; font-size: 13.5px; }
  .task-tag-x { width: 24px; height: 24px; font-size: 16px; }
  .thumb { width: 68px; height: 68px; }

  .chat-scroll { padding: 14px 14px 4px; }
  .chat-input { padding: 6px 12px calc(10px + var(--safe-b)); }
  .turn + .turn { margin-top: 22px; }
  .ask > div { max-width: 88%; padding: 8px 13px; }
  .ask-pics a { width: 84px; height: 84px; }
  .answer { font-size: 16px; line-height: 1.75; }
  .steps-toggle { padding: 6px 11px 6px 9px; }
  .tool-btn { padding: 6px 12px; font-size: 13px; }
  .art-images { grid-template-columns: repeat(2, 1fr); max-width: none; }

  .page { padding: 18px 16px calc(28px + var(--safe-b)); }
  .page h2 { font-size: 20px; margin-bottom: 14px; }
  .page-head h2 { flex-basis: 100%; order: -1; }
  .card + .card { margin-top: 12px; }
  .ustat b { font-size: 19px; }
  /* 16px：同样是防 iOS 聚焦放大（见文件头第 1 条） */
  .field input, .field select { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 9px 16px; }
  .btn-sm { padding: 6px 12px; }
  .row { gap: 8px; }
  .row .btn-sm { white-space: nowrap; }

  .auth { padding: 20px 20px calc(20px + var(--safe-b)); }
}

/* 尊重「减少动态效果」：只留状态变化，去掉所有装饰性动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
