/* =============================================================================
   app.css — 米莉家居 · 手机端优先聊天站（零依赖、零外链字体）
   -----------------------------------------------------------------------------
   约定：
   1) 所有颜色只走 CSS 自定义属性，切换主题靠 :root[data-theme="dark"]。
      默认（没有 data-theme 属性时）跟随 prefers-color-scheme。
      JS 只在两处写 data-theme：显式选浅色 → "light"；显式选深色 → "dark"；
      "跟随系统" 时**不写属性**，这样系统切换主题能实时生效（无需 JS 监听）。
   2) 布局用 flex 列（顶栏 / 滚动区 / 输入区），不用 position:fixed 铺三个 fixed 层 ——
      iOS 键盘弹出时 fixed 层容易和可视区错位。
   3) 全部尺寸按手机优先写，>768px 只做"居中限宽"，不变成两栏。
   ========================================================================== */

/* ---------- 1. 主题变量 ---------- */
:root {
  /* 品牌与语义色（浅色模式） */
  --brand: #4D6BFE;            /* 品牌蓝 */
  --brand-strong: #3B57E8;     /* 按下 / hover */
  --brand-rgb: 77, 107, 254;   /* 用于 rgba() 半透明，避免 color-mix 兼容问题 */

  --bg: #FFFFFF;               /* 页面底色 */
  --bg-soft: #F9FAFB;          /* 浅灰分区（思考面板、代码块标题） */
  --fg: #1B1B1F;               /* 主文字 */
  --fg-2: #4A4A55;             /* 次级文字 */
  --muted: #8A8F9C;            /* 弱化文字（思考正文、占位符） */
  --bubble: #EFF3FF;           /* 用户气泡底色（浅蓝） */
  --bubble-fg: #1B2A5B;        /* 用户气泡文字（深蓝） */
  --input-bg: #F4F5F7;         /* 输入药丸底色 */
  --border: #ECECF1;           /* 描边 / 分隔线 */
  --drawer-bg: #FFFFFF;        /* 历史抽屉底色 */
  --mask: rgba(17, 20, 45, .38);
  --danger: #E5484D;
  --danger-bg: rgba(229, 72, 77, .09);

  /* 代码块：浅色模式下也保持深色底（对齐主流 AI 聊天 App） */
  --code-bg: #1E1E24;
  --code-head: rgba(255, 255, 255, .06);
  --code-fg: #E8E8F0;
  --code-dim: rgba(255, 255, 255, .55);

  --shadow: 0 6px 24px rgba(17, 20, 45, .10);

  /* ---------------------------------------------------------------
   * 别名变量：补齐落地案例模块一直在用、但从来没定义过的 4 个名字。
   *
   * 为什么要有这一段：cases.css / admin-cases.css 通篇使用
   *   --card（面板底色）、--text（主文字）、--line（描边）、--hover（悬停底色）
   * 而 app.css 实际定义的是 --bg / --fg / --border / --input-bg —— **四组名字完全对不上**。
   *
   * 后果不是"颜色不对"，而是**整条声明被浏览器丢弃**：
   * CSS 规范里 var() 引用了不存在的变量，该声明按 invalid 处理直接扔掉，
   * 不会取默认值、不会报错、控制台一个字都不提示。
   * 于是 67 处样式（边框 28、文字 18、背景 10、悬停 11）**一直是失效的**，
   * 表现只是"看着怪怪的"—— 标签右键菜单背景透明、文字压在照片上看不清，
   * 就是 --card 失效导致的。这类问题靠肉眼逐条核对几乎不可能发现。
   *
   * 定义成别名而不是去改那 67 处引用：改引用要动两个文件几十行，
   * 漏一处就再坏一处；在这里映射一次，深色模式也跟着自动生效。
   * --------------------------------------------------------------- */
  --card: var(--drawer-bg);    /* 面板/菜单底色：浅色下是白，深色下比页面底色略亮 */
  --text: var(--fg);           /* 主文字 */
  --line: var(--border);       /* 描边与分隔线 */
  --hover: var(--input-bg);    /* 悬停底色：比页面底色明显一档，鼠标移上去看得出来 */

  /* 字体：不引外链字体，走系统字体栈（中文优先 PingFang / 鸿蒙 / 微软雅黑） */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --math-font: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria,
               Georgia, "Times New Roman", serif;

  --topbar-h: 54px;
  --col-max: 720px;            /* 桌面端正文列最大宽度 */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius-pill: 24px;
}

/* 跟随系统深色：只有"没有显式选浅色"时才生效 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1B1F;
    --bg-soft: #202027;
    --fg: #ECECF1;
    --fg-2: #C7C9D3;
    --muted: #9A9AA5;
    --bubble: #2F3A5C;
    --bubble-fg: #E8ECFF;
    --input-bg: #2A2A30;
    --border: #33333B;
    --drawer-bg: #202024;
    --mask: rgba(0, 0, 0, .58);
    --danger: #FF6B6F;
    --danger-bg: rgba(255, 107, 111, .12);
    --code-bg: #151519;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  }
}

/* 显式选深色 */
:root[data-theme="dark"] {
  --bg: #1B1B1F;
  --bg-soft: #202027;
  --fg: #ECECF1;
  --fg-2: #C7C9D3;
  --muted: #9A9AA5;
  --bubble: #2F3A5C;
  --bubble-fg: #E8ECFF;
  --input-bg: #2A2A30;
  --border: #33333B;
  --drawer-bg: #202024;
  --mask: rgba(0, 0, 0, .58);
  --danger: #FF6B6F;
  --danger-bg: rgba(255, 107, 111, .12);
  --code-bg: #151519;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;                 /* 只让消息区滚动，避免整页被键盘顶动 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- 3. 页面骨架 ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;             /* 移动端动态视口，键盘弹出时不会被截断 */
  width: 100%;
  overflow: hidden;
}

/* ---------- 4. 顶部栏 ---------- */
.topbar {
  flex: none;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 6px;
  padding-right: 6px;
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:active { background: rgba(var(--brand-rgb), .10); }
@media (hover: hover) {
  .icon-btn:hover { background: rgba(var(--brand-rgb), .08); }
}

/* 顶部标题 = 模型选择器入口（按钮，不是纯文本）：模型名可截断，chevron 永不被挤掉 */
.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.topbar-title:active { background: rgba(var(--brand-rgb), .10); }
@media (hover: hover) {
  .topbar-title:hover { background: rgba(var(--brand-rgb), .08); }
}

.topbar-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-chev { flex: none; opacity: .7; }
/* 只有一个可用模型时 JS 会加上 hidden 属性（自己写规则，不依赖 UA 样式对 SVG 的处理） */
.topbar-chev[hidden] { display: none; }

/* ---------- 5. 消息滚动区 ---------- */
.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.msg-list {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: 14px 16px 28px;
}

/* ---------- 6. 空状态 ---------- */
.empty {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: clamp(40px, 13vh, 150px) 22px 24px;
  text-align: center;
}
.empty[hidden] { display: none; }

.empty-logo {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  display: block;
}

.empty-title {
  margin: 0 0 26px;
  font-size: 21px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: .2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 460px;
  margin: 0 auto;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-2);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chip:active {
  background: rgba(var(--brand-rgb), .10);
  border-color: rgba(var(--brand-rgb), .45);
  color: var(--brand);
}
@media (hover: hover) {
  .chip:hover {
    background: rgba(var(--brand-rgb), .07);
    border-color: rgba(var(--brand-rgb), .40);
    color: var(--brand);
  }
}

/* ---------- 7. 消息 ---------- */
.msg { margin-bottom: 22px; }
.msg:last-child { margin-bottom: 4px; }

/* 用户：右对齐浅蓝气泡 */
.msg-user { display: flex; justify-content: flex-end; }

.bubble {
  max-width: 85%;
  background: var(--bubble);
  color: var(--bubble-fg);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 助手：左对齐、无气泡无背景 */
.msg-ai { display: block; }

/* ---------- 8. 思考面板（关键还原点） ---------- */
.reason {
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  overflow: hidden;
}

.reason-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.reason-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.reason[data-live="true"] .reason-dot {
  background: var(--brand);
  animation: ds-pulse 1.1s ease-in-out infinite;
}

.reason-title { flex: none; }
.reason-time { flex: none; font-variant-numeric: tabular-nums; }

.reason-chev {
  flex: none;
  margin-left: auto;
  transition: transform .2s ease;
  opacity: .8;
}
.reason[data-open="true"] .reason-chev { transform: rotate(180deg); }

.reason-body { padding: 0 12px 11px; }
.reason[data-open="false"] .reason-body { display: none; }

.reason-text {
  margin: 0;
  padding-left: 10px;
  border-left: 2px solid var(--border);   /* 左侧 2px 竖线 */
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow-y: auto;
}

@keyframes ds-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.72); }
}

/* ---------- 9. 正文 Markdown ---------- */
.md {
  font-size: 16px;
  line-height: 1.75;          /* 助手正文行高 1.75 */
  color: var(--fg);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md-b > :first-child { margin-top: 0; }
.md-b > :last-child { margin-bottom: 0; }
.md-b + .md-b { margin-top: 14px; }

.md-h { margin: 0 0 8px; font-size: 1.12em; font-weight: 600; line-height: 1.4; }
.md-p { margin: 0; }
.md-hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

.md-list { margin: 0; padding-left: 1.35em; }
.md-list li { margin: 3px 0; }
.md-list li > .md-list { margin: 3px 0; }
.md-task { list-style: none; margin-left: -1.2em !important; }
.md-task input { margin-right: .4em; vertical-align: -1px; }

.md-quote {
  margin: 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--fg-2);
}

.md-link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.md-link:active { opacity: .7; }

.md-code-inline {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .5px 4px;
  overflow-wrap: anywhere;
}

.md-del { opacity: .7; }

/* 代码块：浅色模式下也是深色底 */
.md-code {
  margin: 12px 0;
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}
.md-code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--code-head);
  color: var(--code-dim);
  font-size: 12px;
  font-family: var(--mono);
}
.md-code-lang { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-copy {
  flex: none;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, .09);
  color: var(--code-dim);
  font-size: 12px;
  font-family: var(--font);
  padding: 3px 9px;
  cursor: pointer;
}
.md-copy:active { background: rgba(255, 255, 255, .18); }
.md-code pre {
  margin: 0;
  padding: 10px 13px 13px;
  overflow-x: auto;                /* 长代码横向滚动 */
  -webkit-overflow-scrolling: touch;
}
.md-code code {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--code-fg);
  white-space: pre;
  tab-size: 2;
}

/* 表格 */
.md-table-wrap { margin: 12px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md-table { border-collapse: collapse; font-size: 14.5px; min-width: 60%; }
.md-table th, .md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.md-table th { background: var(--bg-soft); font-weight: 600; }

/* ---------- 10. 数学公式（轻量渲染，见 markdown.js） ---------- */
.md-math {
  display: block;
  margin: 14px 0;
  padding: 2px 0;
  text-align: center;
  font-size: 1.08em;
  line-height: 2.1;
  font-family: var(--math-font);
  overflow-x: auto;
  overflow-y: hidden;
}
.md-math-i { font-family: var(--math-font); font-size: 1.02em; }

.md sup, .md sub { font-size: .72em; line-height: 0; }

.md-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  margin: 0 .16em;
  line-height: 1.18;
  font-size: .95em;
}
.md-frac-n { border-bottom: 1px solid currentColor; padding: 0 .3em; }
.md-frac-d { padding: 0 .3em; }

.md-sqrt-wrap { white-space: nowrap; }
.md-sqrt {
  border-top: 1px solid currentColor;
  padding: 0 .12em 0 .08em;
  margin-left: .04em;
}
.md-sqrt-idx { font-size: .6em; margin-right: -.1em; }

.md-moverline { text-decoration: overline; }

/* 不支持的 LaTeX 命令：原样显示，等宽包起来，绝不吞掉 */
.md-mraw {
  font-family: var(--mono);
  font-size: .9em;
  background: rgba(127, 127, 127, .16);
  border-radius: 4px;
  padding: 0 .22em;
  overflow-wrap: anywhere;
}

/* ---------- 11. 流式光标 / 错误条 / 操作条 ---------- */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--brand);
  animation: ds-blink .9s steps(1, end) infinite;
}

@keyframes ds-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: .05; }
}

.err {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.5;
}

.notice {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.acts {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.act:active { background: var(--bg-soft); color: var(--fg-2); }
@media (hover: hover) {
  .act:hover { background: var(--bg-soft); color: var(--fg-2); }
}

/* ---------- 12. 输入区 ---------- */
.composer {
  flex: none;
  background: var(--bg);
  padding: 4px 12px calc(8px + var(--safe-b));
}

.composer-inner {
  max-width: var(--col-max);
  margin: 0 auto;
}

/* ---------------------------------------------------------------- 图片附件条
 *
 * 来自画廊页每张卡片左上角的「问AI」按钮。
 * 业务方的需求："支持多张照片被一起加载到聊天窗口，并且按照先后迅速标记 1 2 3 4 5。"
 *
 * 编号是**画在缩略图右下角的角标**，不是靠顺序暗示 ——
 * 聊天里要能说"第 2 张是什么"，没有可见编号就无从指代。
 * 8 张以内横向排开，超出的横向滚动（一次最多 8 张，见服务端 MAX_CHAT_IMAGES）。 */
.attach-strip {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--drawer-bg);
}
.attach-strip[hidden] { display: none !important; }

.attach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.attach-clear {
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 4px;
}
.attach-clear:hover { text-decoration: underline; }

.attach-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.attach-item {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--input-bg);
}
.attach-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* 编号角标：右下角，深底白字 —— 56px 的缩略图上只有这个位置放得下 */
.attach-no {
  position: absolute;
  right: 2px;
  bottom: 2px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 0 3px;
}
.attach-del {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  line-height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.attach-del:hover { background: #c0392b; }

/* 用户气泡里的照片：发出去之后历史里还要看得到是哪几张 */
.msg-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.msg-photos .msg-photo {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--input-bg);
}
.msg-photos .msg-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 照片下面跟着的标签文字：`第1张图，图片标签：客厅、现代、…`
 *
 * 业务方的要求原文是"把文字标签也一起带过去…文字标签还是没有复制过去" ——
 * 他要的是**看得见**。之前只把标签塞进给模型的提示词、界面上不显示，
 * 在他看来就是完全没生效。
 *
 * 样式要点：
 *   · 字号比正文小一点（12px）、颜色淡一点 —— 它是**元信息**，
 *     不该和用户自己打的字抢注意力；
 *   · 左对齐并和照片对齐，一眼能看出"这几行分别对应哪张照片"；
 *   · 允许换行（标签多的时候会很长），不要省略号 —— 被截掉的标签
 *     等于没显示，那正是这次要修的问题。 */
.msg-tags {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.msg-tag-line {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  word-break: break-all;
  text-align: left;
  /* 用左侧竖线标出"这是标签行"，和正文区分开 */
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

.switches {
  display: flex;
  gap: 8px;
  padding: 0 4px 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.switch svg { flex: none; }
.switch[data-on="true"] {
  color: var(--brand);
  border-color: rgba(var(--brand-rgb), .45);
  background: rgba(var(--brand-rgb), .10);
}
.switch[data-disabled="true"] { opacity: .6; }

.pill {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 48px;
  padding: 5px 5px 5px 6px;
  border-radius: var(--radius-pill);
  background: var(--input-bg);
}

/* 顶部「线稿出效果图」入口。
   用文字而不是图标：这个功能名本身有信息量，图标表达不出来。
   紧凑药丸样式，宽度约 92px（390px 屏上仍留得下模型名）。 */
.topbar-action {
  flex: none;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: rgba(var(--brand-rgb), .10);
  color: var(--brand);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease;
}
.topbar-action:active { background: rgba(var(--brand-rgb), .20); }
@media (hover: hover) {
  .topbar-action:hover { background: rgba(var(--brand-rgb), .16); }
}
/* 「落地案例」是链接不是按钮：它是页面跳转，用 <a> 才能被"新标签页打开"和收录。
   去掉下划线并保持与按钮完全一致的外观，用户不该看出两者实现不同。 */
a.topbar-action {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

/* 顶栏现在有「线稿出图」「落地案例」两个入口（约 92px 各），
   加上菜单/加号两个 40px 图标按钮，390px 屏上留给模型名的空间很紧。
   逐级压缩内边距与字号，保证不换行也不挤压模型名 ——
   换行会让顶栏变高，把聊天内容整体下推。 */
@media (max-width: 430px) {
  .topbar-action { padding: 0 8px; font-size: 11.5px; letter-spacing: -.2px; }
}
@media (max-width: 380px) {
  .topbar-action { padding: 0 6px; font-size: 11px; letter-spacing: -.3px; }
  .topbar-model { max-width: 96px; }
}
@media (max-width: 340px) {
  .topbar-action { padding: 0 5px; font-size: 10.5px; }
  .topbar-model { max-width: 72px; }
}

#input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--fg);
  /* 16px 是硬性下限：小于 16px 时 iOS Safari 聚焦会自动放大页面 */
  font-size: 16px;
  font-family: inherit;
  line-height: 22px;
  padding: 8px 2px;
  margin: 0;
  max-height: 126px;         /* 5 行 × 22px + 上下 padding，超过则内部滚动（JS 会用 scrollHeight 精确同步） */
  overflow-y: hidden;
}
#input::placeholder { color: var(--muted); }

.send-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  cursor: default;
  transition: background .15s ease, color .15s ease;
}
.send-btn.is-ready {
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.send-btn.is-ready:active { background: var(--brand-strong); }
.send-btn.is-stop {
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.send-btn.is-stop:active { background: var(--brand-strong); }

.disclaimer {
  margin: 7px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- 13. 历史抽屉 ---------- */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(84vw, 320px);
  display: flex;
  flex-direction: column;
  background: var(--drawer-bg);
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  z-index: 60;
  will-change: transform;
  box-shadow: var(--shadow);
}
.drawer.is-open { transform: translateX(0); }

.drawer-head {
  flex: none;
  padding: calc(10px + var(--safe-t)) 12px 10px;
}

.new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
}
.new-chat:active { background: rgba(var(--brand-rgb), .10); }

.conv-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 2px 8px 10px;
  -webkit-overflow-scrolling: touch;
}

.conv-empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.conv {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 10px;
  margin-bottom: 2px;
}
.conv.is-active { background: rgba(var(--brand-rgb), .10); }

.conv-open {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: 14.5px;
  padding: 11px 34px 11px 11px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv.is-active .conv-open { color: var(--brand); font-weight: 500; }

.conv-del {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .15s ease;
}
.conv.reveal .conv-del,
.conv.is-active.reveal .conv-del { opacity: 1; pointer-events: auto; }
.conv-del:active { color: var(--danger); }

/* 桌面端：悬停直接出现删除按钮 */
@media (hover: hover) {
  .conv:hover { background: var(--bg-soft); }
  .conv:hover .conv-del { opacity: 1; pointer-events: auto; }
}

.drawer-foot {
  flex: none;
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(12px + var(--safe-b));
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 10px;
  color: var(--fg-2);
  font-size: 13.5px;
}
.who-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(var(--brand-rgb), .12);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}
.who-phone { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foot-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.foot-btn:active { background: var(--bg-soft); }
.foot-btn.danger { color: var(--danger); }

.mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 50;
}
.mask.is-open { opacity: 1; pointer-events: auto; }

/* ---------- 13.5 模型选择器（bottom sheet，契约 §7） ---------- */
/* 遮罩独立于抽屉的 #mask：两者层级不同，互不干扰 */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 70;
}
.sheet-mask.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 520px;               /* 桌面端居中限宽，不做两栏 */
  max-height: 70vh;               /* 契约 §7.1：高度不超过视口 70% */
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  background: var(--drawer-bg);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(101%);
  /* 收起时 visibility:hidden —— 否则弹层里的按钮还能被 Tab 聚焦到 */
  visibility: hidden;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .28s;
  will-change: transform;
  overscroll-behavior: contain;
  z-index: 72;
}
.sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility 0s;
}
.sheet.is-dragging { transition: none; }   /* 手指拖动跟手，不要过渡 */

.sheet-grab {
  flex: none;
  width: 36px;
  height: 4px;
  margin: 8px auto 2px;
  border-radius: 999px;
  background: var(--border);
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 6px 16px;
}

.sheet-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-close {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.sheet-close:active { background: var(--bg-soft); }
@media (hover: hover) {
  .sheet-close:hover { background: var(--bg-soft); color: var(--fg-2); }
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;                  /* 关键：让内容区真正可滚动，而不是把弹层撑高 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 8px 10px;
  scrollbar-width: thin;
}

.sheet-group + .sheet-group { margin-top: 4px; }

.sheet-group-head {
  padding: 10px 10px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
  transition: background .15s ease;
}
.model-row:active { background: var(--bg-soft); }
@media (hover: hover) {
  .model-row:hover { background: var(--bg-soft); }
}
.model-row.is-active { background: rgba(var(--brand-rgb), .10); }
.model-row.is-active .model-name { color: var(--brand); font-weight: 600; }

.model-check {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--brand);
}

.model-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.model-name {
  color: var(--fg);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-desc {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-weight {
  flex: none;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* 贵模型（weight >= 20）用警示色提醒成本 */
.model-weight.is-costly {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

.sheet-foot {
  flex: none;
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + var(--safe-b));   /* 适配 iPhone 底部安全区 */
}

.model-quota {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.sheet-empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- 14. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  max-width: 78vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(27, 27, 31, .93);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 80;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
:root[data-theme="dark"] .toast { background: rgba(240, 240, 245, .95); color: #1B1B1F; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast { background: rgba(240, 240, 245, .95); color: #1B1B1F; }
}

/* ---------- 15. 登录页 ---------- */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(28px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  display: block;
}

.auth-title {
  margin: 0 0 28px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
}

.auth-field { display: block; margin-bottom: 14px; }

.auth-label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 13px;
  color: var(--muted);
}

.auth-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 8px 0 14px;
  transition: border-color .15s ease;
}
.auth-input-row:focus-within { border-color: rgba(var(--brand-rgb), .55); }
.auth-input-row.is-error { border-color: var(--danger); }

.auth-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: 16px;              /* 防 iOS 聚焦缩放 */
  font-family: inherit;
  padding: 13px 0;
}
.auth-input::placeholder { color: var(--muted); }

.eye-btn {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

/* ==========================================================================
   登录方式切换（验证码 / 密码 / 注册）
   三个视图共用一张卡片：切换时已输入的手机号要保留，
   换成三个页面就会丢，用户得重输一遍。
   ========================================================================== */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  margin: 4px 0 18px;
  border-radius: 12px;
  background: var(--input-bg);
}
.auth-tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 6px;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.auth-tab.is-on {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 20, 45, .10);
}
:root[data-theme="dark"] .auth-tab.is-on { background: #35353d; }

/* 未选中的视图必须真正隐藏（含其中的必填控件），否则浏览器会拦截提交 */
.auth-view { display: none; }
.auth-view.is-on { display: block; }

/* 「获取验证码」按钮：贴在输入行右侧，与 .eye-btn 同位置 */
.code-btn {
  flex: none;
  height: 30px;
  margin-right: 3px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(var(--brand-rgb), .10);
  color: var(--brand);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease;
}
.code-btn:active { background: rgba(var(--brand-rgb), .20); }
.code-btn:disabled { opacity: .55; cursor: default; }
.code-btn.is-counting { color: var(--muted); background: transparent; }

.auth-optional {
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}

/* 角色说明：注册前让用户知道会得到什么身份 */
.role-note {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 11px;
  background: rgba(var(--brand-rgb), .07);
  border: 1px solid rgba(var(--brand-rgb), .16);
}
.role-note-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
}
.role-note-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
  color: var(--fg-2);
}

.auth-switch {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.link-btn {
  border: 0;
  background: transparent;
  padding: 2px 4px;
  color: var(--brand);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.auth-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  padding: 14px;
  margin-top: 8px;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.auth-submit:active { background: var(--brand-strong); }
.auth-submit:disabled { opacity: .6; cursor: default; }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  animation: ds-spin .7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

.auth-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
}

.auth-hint {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 16. 桌面端：只居中限宽，不做两栏 ---------- */
@media (min-width: 769px) {
  .msg-list { padding-left: 0; padding-right: 0; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .md { font-size: 16px; }
}

/* ---------- 17. 无障碍 / 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

.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;
}

/* ==========================================================================
   出图面板（AI 家装效果图）
   复用 .sheet / .sheet-head / .sheet-body / .sheet-foot 骨架，
   这里只补它独有的：更高的弹层、上传区、分段选择、滑块、结果区。
   ========================================================================== */

/* 出图面板内容比模型列表长，70vh 装不下，单独放宽 */
.sheet-render { max-height: 88vh; max-height: 88dvh; }

.render-body { padding: 4px 18px 12px; }

.render-sec { margin-bottom: 16px; }

.render-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
}
.render-label b { color: var(--brand); font-weight: 700; }

.render-hint {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}
.render-hint b { color: var(--fg-2); font-weight: 600; }

/* ---- 上传区 ---- */

/* 必须显式处理 [hidden]：浏览器给 hidden 的 display:none 优先级极低，
   会被下面 .render-upload-empty{display:flex} 这种作者样式盖掉，
   结果选完线稿后占位符与预览图同时显示（浏览器实测发现的 bug）。 */
[hidden] { display: none !important; }

.render-upload {
  display: block;
  width: 100%;
  padding: 0;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--fg-2);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .18s ease, background .18s ease;
}
.render-upload:hover,
.render-upload:focus-visible { border-color: var(--brand); background: rgba(var(--brand-rgb), .05); }
.render-upload.is-set { border-style: solid; padding: 0; }

.render-upload-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 12px;
  color: var(--muted);
}
.render-upload-empty span { font-size: 13px; color: var(--fg-2); font-weight: 500; }
.render-upload-empty small { font-size: 11px; color: var(--muted); }

.render-upload-preview {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  background: #fff;                 /* 线稿多为白底，固定白底避免深色模式下看着发灰 */
}

/* ---- 分段选择（精度） ---- */
.render-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.render-seg-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s ease;
}
.render-seg-btn small { font-size: 10.5px; font-weight: 400; color: var(--muted); }
.render-seg-btn.is-active {
  border-color: var(--brand);
  background: rgba(var(--brand-rgb), .08);
  color: var(--brand);
}
.render-seg-btn.is-active small { color: var(--brand); opacity: .8; }

/* ---- 滑块 ---- */
.render-range {
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.render-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}
.render-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.render-range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--border); }
.render-range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--bg);
}

/* ---- 描述输入 ---- */
.render-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  min-height: 74px;
}
.render-textarea:focus { outline: none; border-color: var(--brand); }

/* ---- 进度 ---- */
.render-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.render-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  transition: width .3s ease;
}
.render-progress { margin-bottom: 10px; }

/* ---- 结果 ---- */
.render-result img {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.render-result-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.render-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border: none;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s ease, opacity .18s ease;
}
.render-btn-primary:hover { background: var(--brand-strong); }
.render-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.render-btn-wide { width: 100%; }

.render-btn-ghost {
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--fg-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.render-btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

.render-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---- 离线提示 ---- */
.render-offline {
  padding: 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.65;
}
.render-offline strong { color: var(--danger); display: block; margin-bottom: 4px; }
.render-offline p { margin: 0; }

.render-foot { padding: 10px 18px calc(14px + var(--safe-b)); }
.render-foot .render-hint { text-align: center; margin-top: 8px; }

/* 出图面板打开时隐藏聊天输入区，避免两层底部元素叠在一起 */
.app.is-render-open .composer { display: none; }


/* ================================================================ 空间出图
 *
 * 和线稿出图共用 .render-* 那套（上传框、进度条、按钮），
 * 只有"多参考图"和"4 张结果网格"是新的 —— 这两块是空间出图特有的。
 */

/* 必填 / 选填标记：写在 label 里而不是另起一行，
   面板已经够长了，多一行说明就得多滚一次 */
.render-req,
.render-opt {
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}
.render-req { color: var(--danger); }
.render-opt { color: var(--muted); }

/* 参考图上传框比现状照片矮一些 —— 视觉上区分主次：
   现状照片是必填且唯一，参考图可选且多张 */
.render-upload-multi { min-height: 92px; }
.render-upload-multi .render-upload-empty { gap: 6px; }

/* 参考图缩略图网格：每张右上角一个 × 删除。
   ⚠️ 删除按钮必须**始终可见**（不能只在 hover 时出现）——
      手机上没有 hover，那样等于删不掉。 */
.space-refs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.space-refs:empty { display: none; }
.space-ref {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.space-ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.space-ref-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
}
.space-ref-del:hover { background: var(--danger); }
/* 参考图上的编号：说明"这是第几张"，删除后编号会自动重排 */
.space-ref-no {
  position: absolute;
  left: 3px; bottom: 3px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 10px;
  line-height: 15px;
}

/* 4 张结果网格。手机上 2×2（每张够大能看清），宽屏一行 4 张 */
.space-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}
@media (min-width: 640px) {
  .space-grid { grid-template-columns: repeat(4, 1fr); }
}
.space-grid:empty { display: none; }
.space-cell {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--bg-soft);
  cursor: pointer;
  padding: 0;
}
.space-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.space-cell:hover { border-color: rgba(var(--brand-rgb), .45); }
/* 选中的那张：品牌色描边 + 勾。描边而不是缩放，
   因为缩放会让网格跳动，选第 3 张时前面的图动一下很难受。 */
.space-cell.is-picked { border-color: var(--brand); }
.space-cell.is-picked::after {
  content: '✓';
  position: absolute;
  top: 4px; right: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

/* 选中后的大图 + 保存按钮 */
.space-picked { margin-top: 12px; }
.space-picked img {
  width: 100%;
  border-radius: 10px;
  display: block;
  border: 1px solid var(--line);
}
.space-picked .render-result-actions { margin-top: 10px; }