/* ============================================================================
   IY · 界面 v8（2026-10-11 晚，照俞手机上的扣子截图改）
   ----------------------------------------------------------------------------
   这一版修的五件事（俞 20:14 的原话）：
     ① 对话目录点不开 —— v7 我自己引入的层叠 bug：`.app{z-index:1}` 把里面的
        抽屉锁进了一个新的层叠上下文，而 `.mask` 是 fixed/z-index:40 在 body 层，
        于是遮罩盖在抽屉**上面**，点一下就被 mask 的 closeDrawer 关掉。
        修法：html 挂底色/壁纸，body 背景透明，遮罩走 body::before 的 z-index:-1，
        .app 不再设 z-index —— 抽屉(50) 就压在遮罩(40) 之上了。
     ② 字小、行距大 —— 正文 15px/1.62 → 16px/1.5
     ③ 思考过程占地方 —— 折叠状态压成一行小灰字，去掉长摘要
     ④ 配色 —— 照扣子：近黑底 #0F0F10 + 墨绿自己的气泡 + 绿色强调点
     ⑤ 切出去再回来断线 —— 前端另有加强（app.js 的 recover），这里只管样子
   ========================================================================== */

:root {
  --page: #0F0F10;
  /* --chrome：**视口之外**那块 canvas 该显示什么颜色。
     PWA 全屏时状态栏那 60 来像素在视口外面，只有 html 的背景铺得到 ——
     以前那儿是 --page（#0F0F10 纯黑），而页面本身是深灰，
     于是屏幕最顶上就横着一条比周围更黑的带子（俞追了一晚上的"黑条"）。
     这里取的是顶栏毛玻璃叠在页面上之后的等效色，让状态栏看着像顶栏的延伸。 */
  --chrome: #17181A;
  --surface: 26 27 28;
  --panel-alpha: 72;
  --wall-shade: 0 0 0;
  --wall-shade-a: 38;

  --text: #E9E9E9;
  --muted: #9C9C9C;
  --faint: #6B6B6B;

  --line: rgb(255 255 255 / 7%);
  --line-2: rgb(255 255 255 / 13%);
  --hover: rgb(255 255 255 / 6%);

  /* 扣子的做法：自己说的话是墨绿，不是蓝 */
  --me-1: #2C4634;
  --me-2: #36543F;
  --me-ink: #EDF5EE;
  --green: #3DDC84;

  --ok: #3DDC84;
  --danger: #F87171;

  --blur: saturate(1.5) blur(24px);
  --r: 18px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sb: env(safe-area-inset-bottom, 0px);
  --st: env(safe-area-inset-top, 0px);
}

/* 背景偏亮 → 浅色主题（app.js 采样壁纸亮度后挂 data-lit="1"） */
html[data-lit="1"] {
  --page: #F6F6F4;
  --chrome: #FAFAF9;
  --surface: 255 255 255;
  --wall-shade: 255 255 255;
  --wall-shade-a: 42;
  --text: #17181A;
  --muted: #5C6167;
  --faint: #8B9096;
  --line: rgb(0 0 0 / 8%);
  --line-2: rgb(0 0 0 / 14%);
  --hover: rgb(0 0 0 / 5%);
  --green: #12A150;
  --ok: #12A150;
  --danger: #DC2626;
}

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

@property --spinq { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

html {
  margin: 0; padding: 0; height: 100%; min-height: 100dvh;
  /* 用 --chrome 而不是 --page：状态栏那块 canvas 也要跟顶栏一个色 */
  background-color: var(--chrome);
}
/* 壁纸 + 遮罩，两层一起挂在 **html 的 background** 上。
   为什么非得是 html —— 只有根元素的背景会铺满**整块 canvas**
   （含 iOS 状态栏、Safari 底部工具栏背后那一条）。
   fixed 伪元素只到 layout viewport：真机实测 iPhone 屏幕 896、壁纸层只有 835.98，
   差的那 60px 露出来的就是 html 底色 rgb(15,15,16) —— 俞追了一晚上的"黑条"。
   另外**不要加 background-attachment: fixed** —— iOS 上它会反过来把背景限制在视口内。 */
html.has-wall {
  background-image:
    linear-gradient(rgb(var(--wall-shade) / calc(var(--wall-shade-a) / 100)),
                    rgb(var(--wall-shade) / calc(var(--wall-shade-a) / 100))),
    var(--wallpaper, none);
  background-size: cover, cover;
  background-position: center center, center center;
  background-repeat: no-repeat, no-repeat;
}

/* body 背景透明 —— 否则它会盖住下面的遮罩层（body::before 是 z-index:-1） */
body {
  margin: 0; padding: 0; height: 100%; min-height: 100dvh;
  background: transparent;
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
        "HarmonyOS Sans SC", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow-x: hidden;
}


/* 注意：这里**不能**有 z-index —— 一设就会把抽屉锁进新层叠上下文，
   .mask(fixed,40) 就会盖到抽屉(50) 上面去（v7 的 bug） */
.app { position: relative; height: 100dvh; }

/* ================= 侧栏 ================= */
.sidebar {
  display: flex; flex-direction: column;
  background: rgb(var(--surface) / calc(var(--panel-alpha) / 100));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--st)) 14px 12px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-avatar { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; }
.brand-text { display: grid; gap: 2px; min-width: 0; }
.brand-name { font-weight: 600; font-size: 16.5px; line-height: 1.15; }
.brand-yu {
  font-size: 10px; font-weight: 700; letter-spacing: .16em;
  background: linear-gradient(90deg, #6B83FF, #A78BFA 55%, #5EEAD4);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

.conv-list { flex: 1; overflow-y: auto; padding: 6px 10px; }
.conv-avatar {
  flex: 0 0 auto; width: 40px; height: 40px; margin-left: 8px;
  border-radius: 50%; object-fit: cover;
}
.conv-item {
  width: 100%; display: flex; align-items: center; gap: 4px;
  border-radius: 12px; transition: background .16s;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--hover); }
.conv-main {
  flex: 1; min-width: 0; text-align: left; color: var(--text); font: inherit;
  background: transparent; border: 0; cursor: pointer;
  padding: 10px 4px 10px 12px; display: grid; gap: 4px;
}
.conv-item .ct { font-size: 16px; font-weight: 550; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .cp { font-size: 13.5px; color: var(--faint); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del {
  flex: 0 0 auto; width: 28px; height: 28px; margin-right: 6px;
  display: grid; place-items: center;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--faint); font-size: 15px; line-height: 1; cursor: pointer;
  opacity: 0; transition: background .16s, color .16s, opacity .16s, width .16s;
}
.conv-item:hover .conv-del, .conv-item.active .conv-del { opacity: 1; }
.conv-del:hover { background: rgb(248 113 113 / 14%); color: var(--danger); }
.conv-del.arm { opacity: 1; width: auto; padding: 0 10px; font-size: 11.5px; background: rgb(248 113 113 / 16%); color: var(--danger); }

.side-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px calc(14px + var(--sb));
  font-size: 12px; color: var(--faint);
}
.foot-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.foot-dot.busy {
  background: conic-gradient(from var(--spinq), var(--me-2), var(--green), var(--me-2));
  animation: pulse 1.2s ease-in-out infinite, spinq 2.6s linear infinite;
}
@keyframes spinq { to { --spinq: 360deg; } }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ================= 两栏：对话 / 我的（照扣子的底部 tab）=================
   以前「外观」是个折叠小抽屉贴在列表底下，俞说太丑。
   现在拆成两栏：对话 = 会话列表，我的 = 外观设置，底部 tab 切换。 */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane[hidden] { display: none; }

.mine-list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 18px 20px;
  display: flex; flex-direction: column; gap: 24px;
}
.mine-card { display: flex; flex-direction: column; gap: 11px; }
.mine-label { font-size: 15px; font-weight: 550; color: var(--text); }
.mine-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.mine-dim { font-size: 13px; color: var(--faint); }
.mine-tip { font-size: 13.5px; color: var(--faint); line-height: 1.5; }

.tabbar {
  display: flex; align-items: stretch;
  border-top: 1px solid var(--line);
  padding-bottom: var(--sb);
  background: rgb(var(--surface) / calc(var(--panel-alpha) / 100));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 10px 0 8px;
  background: none; border: 0; cursor: pointer;
  color: var(--faint); font: inherit; font-size: 12.5px;
  transition: color .16s;
}
.tab svg { width: 23px; height: 23px; }
.tab.on { color: var(--text); font-weight: 600; }
.tab:active { opacity: .7; }

.look-row { display: flex; align-items: center; gap: 10px; }
.look-row .lv { flex: 0 0 46px; text-align: right; font: 13.5px var(--mono); color: var(--faint); }
.look-tip { font-size: 13.5px; color: var(--faint); line-height: 1.5; }

input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: var(--line-2); outline: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text); border: 0; cursor: pointer;
}

.seg { display: flex; flex: 1; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button {
  flex: 1; padding: 8px 0; background: none; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 14px;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--text); color: var(--page); font-weight: 600; }

.tool-btn {
  flex: 1; text-align: center; padding: 10px 0; border-radius: 11px;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer;
}
.tool-btn:active { background: var(--hover); color: var(--text); }

/* ================= 主区 ================= */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto auto;
  height: 100dvh;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.top {
  display: flex; align-items: center; gap: 4px;
  padding: calc(8px + var(--st)) 10px 8px;
  background: linear-gradient(180deg,
    rgb(var(--surface) / calc(var(--panel-alpha) / 100)) 55%,
    rgb(var(--surface) / 0%));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.title-wrap {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 1px;
}
.top .t {
  min-width: 0; max-width: 100%;
  font-weight: 550; font-size: 16px; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.top .sub {
  font-size: 11px; color: var(--faint); line-height: 1.2;
  display: flex; align-items: center; gap: 4px;
}
.top .sub .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }

.icon-btn {
  flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.menu { display: none; }

.model-menu {
  position: absolute; bottom: calc(96px + var(--sb)); left: 12px; right: 12px; z-index: 60;
  padding: 6px;
  background: rgb(var(--surface) / 96%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: 0 20px 50px rgb(0 0 0 / 40%);
}
.model-menu[hidden] { display: none; }
.model-menu .mi {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  color: var(--text); font: inherit; padding: 11px 12px; border-radius: 12px;
  display: grid; gap: 2px;
}
.model-menu .mi:hover { background: var(--hover); }
.model-menu .mi.active { background: var(--hover); }
.model-menu .mi .mn { font-size: 14.5px; font-weight: 550; }
.model-menu .mi .md { font-size: 12px; color: var(--faint); }

/* ================= 消息流 ================= */
.feed {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overflow-x: hidden; min-width: 0;
  padding: 14px max(16px, calc((100% - 760px) / 2)) 10px;
  display: flex; flex-direction: column; gap: 16px;
}
/* 消息**从上往下排**（俞 2026-10-11 晚确认：不要再贴底了，顶部对齐才看着舒服）。
   上一版我理解反了，把第一条的 margin-top 设成 auto 让它贴底，反而别扭。 */

.empty { margin: auto; display: grid; justify-items: center; gap: 12px; padding-bottom: 10vh; text-align: center; }
.empty img { width: 64px; height: 64px; border-radius: 19px; object-fit: cover; }
.empty .et { font-size: 16px; font-weight: 550; }
.empty .es { font-size: 13px; color: var(--faint); }

.msg { display: flex; gap: 10px; align-items: flex-start; animation: in .2s ease-out; min-width: 0; max-width: 100%; }
@keyframes in { from { opacity: 0; transform: translateY(3px); } }
/* 自己的消息也在左边、也带头像（俞 2026-10-11 要的） */
.avatar { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; margin-top: 2px; }
.avatar.txt {
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--me-2), var(--me-1));
  color: var(--me-ink); font-size: 13px; font-weight: 600; line-height: 1;
}

.bubble {
  max-width: min(82%, 44rem);
  padding: 10px 14px; border-radius: var(--r);
  white-space: pre-wrap; word-break: break-word;
  font-size: 16px; line-height: 1.42;
}
/* 鱼的话不用气泡 —— 一块灰底最容易显廉价（扣子也这么干） */
.msg.fish { align-items: flex-start; }
.msg.fish .bubble {
  flex: 1 1 auto; min-width: 0;
  background: none; padding: 0;
  max-width: min(100%, 48rem);
  text-shadow: 0 1px 3px rgb(0 0 0 / 45%);
}
html[data-lit="1"] .msg.fish .bubble { text-shadow: none; }
/* 有壁纸时另说：纯文字压在花纹上读不动，把毛玻璃底衬请回来
   （没壁纸就不加 —— 干净的纯文字才是最不廉价的样子） */
body.has-wall .msg.fish .bubble {
  background: rgb(var(--surface) / 64%);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  max-width: min(86%, 44rem);
  text-shadow: none;
}
body.has-wall .think > summary { text-shadow: 0 1px 3px rgb(0 0 0 / 35%); }
html[data-lit="1"] body.has-wall .think > summary,
body.has-wall html[data-lit="1"] .think > summary { text-shadow: none; }
.msg.me .bubble {
  background: linear-gradient(160deg, var(--me-2), var(--me-1));
  color: var(--me-ink);
  border-bottom-left-radius: 6px;
}

.caret::after {
  content: ""; display: inline-block; width: 6px; height: 16px; margin-left: 3px; vertical-align: -3px;
  border-radius: 2px; background: var(--green); animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ================= 思考 / 工具（压到最轻）================= */
.turn { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 100%; }
.block { margin-left: 38px; max-width: calc(100% - 38px); min-width: 0; }

/* 一轮的「过程」整包折叠（俞 2026-10-11：应该默认折叠起来，只展示正文）
   —— 思考和所有工具调用都塞进这一个 details，默认只占一行：
      ▸ 过程  思考 · 3 个工具
   正文永远在外面、直接可见。 */
.trace { margin: 0; }
.trace > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0; font-size: 13px; color: var(--faint); min-width: 0;
}
.trace > summary::-webkit-details-marker { display: none; }
.trace > summary .lb { flex: 0 0 auto; opacity: .75; }
.trace > summary .st { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace > summary .ar { flex: 0 0 auto; font-size: 10px; transition: transform .2s; }
.trace[open] > summary .ar { transform: rotate(180deg); }
.trace[open] > summary { color: var(--green); }
.trace > .tbody { display: flex; flex-direction: column; gap: 8px; padding: 7px 0 4px; }
.trace .trace-think {
  margin: 0; padding: 10px 12px;
  background: rgb(var(--surface) / calc(var(--panel-alpha) / 100 * .5));
  border-radius: 12px;
  white-space: pre-wrap; word-break: break-word;
  font: 12px/1.55 var(--mono); color: var(--muted);
  max-height: 40vh; overflow: auto;
}
.trace .trace-label { font-size: 10px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin-bottom: -5px; }

.think { margin: 0; }
.think > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0; font-size: 13px; color: var(--faint);
  min-width: 0;
}
.think > summary::-webkit-details-marker { display: none; }
.think > summary .lb { flex: 0 0 auto; }
.think > summary .st {
  flex: 1 1 0; min-width: 0; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: .8;
}
.think > summary .ar { flex: 0 0 auto; font-size: 10px; transition: transform .2s; }
.think[open] > summary .ar { transform: rotate(180deg); }
.think[open] > summary { color: var(--green); }
.think pre {
  margin: 6px 0 2px; padding: 10px 12px;
  background: rgb(var(--surface) / calc(var(--panel-alpha) / 100 * .5));
  border-radius: 12px;
  white-space: pre-wrap; word-break: break-word;
  font: 12px/1.55 var(--mono); color: var(--muted);
  max-height: 32vh; overflow: auto; max-width: 100%;
}

.tool { border-radius: 12px; overflow: hidden; max-width: 100%; }
.tool .thead { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; user-select: none; min-width: 0; }
.tool .dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.tool.running .dot {
  background: conic-gradient(from var(--spinq), var(--me-2), var(--green), var(--me-2));
  animation: pulse 1.2s ease-in-out infinite, spinq 2.6s linear infinite;
}
.tool.done .dot { background: var(--green); }
.tool.fail .dot { background: var(--danger); }
.tool .tname { flex: 0 0 auto; font: 600 12.5px var(--mono); color: var(--muted); }
.tool .tsum { flex: 1 1 0; min-width: 0; display: block; font: 12px var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool .chev { flex: 0 0 auto; color: var(--faint); font-size: 10px; }
.tool .tbody { display: none; margin-top: 4px; padding: 10px 12px; border-radius: 12px; background: rgb(var(--surface) / calc(var(--panel-alpha) / 100 * .5)); }
.tool.open .tbody { display: block; }
.tool .lbl { padding: 0 0 2px; font-size: 10px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; }
.tool pre {
  margin: 0; padding: 2px 0 6px; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.5 var(--mono); color: var(--muted); max-height: 36vh; overflow: auto; max-width: 100%;
}
.usage { margin-left: 38px; font-size: 10px; color: var(--faint); opacity: .3; font-family: var(--mono); }

/* ================= 状态行（只在忙/错时浮出）================= */
.status {
  display: flex; align-items: center; gap: 7px; justify-content: center;
  height: 20px; font-size: 12px; color: var(--faint); padding: 0 14px;
  opacity: 0; transition: opacity .2s;
}
.status.show, .status.working, .status.error { opacity: 1; }
.status .sdot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.status.working .sdot {
  background: conic-gradient(from var(--spinq), var(--me-2), var(--green), var(--me-2));
  animation: breathe 1.3s ease-in-out infinite, spinq 2.6s linear infinite;
}
.status.error { color: var(--danger); }
.status.error .sdot { background: var(--danger); animation: none; }
@keyframes breathe { 0%,100% { opacity: .3; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }

/* ================= 输入（扣子那种：一个大方框，工具行在里面）================= */
.composer {
  /* --kb 是键盘高度（app.js 写）。键盘弹起时按它把自己顶上去，
     没键盘时退回安全区高度 —— 取两者大的那个，不会重复叠。 */
  padding: 6px 12px calc(max(var(--kb, 0px), var(--sb)) + 8px);
  background: linear-gradient(180deg,
    rgb(var(--surface) / 0) 0%,
    rgb(var(--surface) / calc(var(--panel-alpha) / 100 * .5)) 45%,
    rgb(var(--surface) / calc(var(--panel-alpha) / 100 * .68)) 100%);
}
.box {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 10px 8px;
  background: rgb(var(--surface) / calc(var(--panel-alpha) / 100 * 1.15));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: 22px;
  transition: border-color .16s;
}
.box:focus-within { border-color: var(--line-2); }
#input {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  color: var(--text); font: inherit; font-size: 16px; line-height: 1.5;
  max-height: 32vh; padding: 2px 4px 4px;
}
#input::placeholder { color: var(--faint); }

.box .row { display: flex; align-items: center; gap: 6px; }
.box .row .grow { flex: 1; }

/* 模型选择挪进输入框的工具行（扣子也放这儿） */
.model-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 3px;
  max-width: 46%; padding: 4px 8px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: background .16s, color .16s;
}
.model-btn:hover { background: var(--hover); color: var(--text); }
.model-btn .mname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .chev { flex: 0 0 auto; }

.img-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
label.img-btn {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background .16s, color .16s;
}
label.img-btn:hover { background: var(--hover); color: var(--text); }

.send {
  flex: 0 0 auto; width: 32px; height: 32px;
  border: 0; border-radius: 50%;
  background: var(--green); color: #0F1A12;
  display: grid; place-items: center; cursor: pointer;
  transition: transform .14s, opacity .16s;
}
.send:active { transform: scale(.92); }
.send.stop { background: var(--danger); color: #fff; }

/* 发出去的图：直接显示在图气泡里（俞 2026-10-11：别让我干等识别） */
.msg.me .bubble .shot {
  display: block; max-width: 100%; max-height: 46vh;
  border-radius: 12px; object-fit: cover;
}
.msg.me .bubble .shot-text { margin-top: 8px; }

.img-preview { display: flex; align-items: center; gap: 10px; padding: 0 4px 8px; }
.img-preview img { width: 54px; height: 54px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line-2); }
.img-preview button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--muted); cursor: pointer; }

/* ================= 「电脑上的对话」态 =================
   ⚠️ 别把输入框灰掉/禁掉（俞 2026-10-11：「什么鬼，我不能发信息吗」）。
   他在这里打字是完全合理的诉求 —— 只是那些内容属于电脑那头的 dsh 实例，
   所以做法是：**照常能打，发的时候自动在手机上开个新对话接着聊**（见 app.js 的 send）。 */
body.readonly .composer { border-color: transparent; }
body.readonly #input::placeholder { color: var(--muted); }
/* 列表里「电脑上的对话」压暗一点，跟本机的分开 */
.conv-item[data-src="dh"] .ct { color: var(--muted); font-weight: 500; }

/* ================= 诊断浮层（真机排障用）================= */
.diag {
  position: fixed; inset: 0; z-index: 200;
  background: rgb(0 0 0 / 94%);
  color: #fff;
  padding: calc(16px + var(--st)) 16px calc(16px + var(--sb));
  display: flex; flex-direction: column; gap: 12px;
  overflow: auto;
}
.diag[hidden] { display: none; }
.diag-head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 600; }
.diag-head button {
  background: none; border: 1px solid rgb(255 255 255 / 34%); color: #fff;
  border-radius: 9px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer;
}
.diag pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font: 13.5px/1.7 var(--mono); color: #d8ffd8;
}

/* ================= 抽屉遮罩 ================= */
.mask { position: fixed; inset: 0; background: rgb(0 0 0 / 42%); opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 40; }
.mask.show { opacity: 1; pointer-events: auto; }

/* ================= 登录 ================= */
.login {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: rgb(0 0 0 / 62%);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
html[data-lit="1"] .login { background: rgb(255 255 255 / 66%); }
.login[hidden] { display: none; }
.login-card {
  width: min(88vw, 316px); display: grid; justify-items: center; gap: 11px;
  padding: 30px 22px 22px;
  background: rgb(var(--surface) / 92%);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-2); border-radius: 24px;
  box-shadow: 0 30px 70px rgb(0 0 0 / 40%);
}
.login-avatar { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; }
.login-name { font-size: 17px; font-weight: 600; }
.login-sub { font-size: 13px; color: var(--faint); text-align: center; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--hover); border: 1px solid var(--line-2); border-radius: 13px; outline: 0;
}
.login-card input:focus { border-color: var(--green); }
.login-btn {
  width: 100%; margin-top: 3px; padding: 12px;
  font: inherit; font-size: 15px; font-weight: 600; color: #0F1A12;
  background: var(--green);
  border: 0; border-radius: 13px; cursor: pointer;
}
.login-btn:disabled { opacity: .5; }
.login-err { min-height: 15px; font-size: 12.5px; color: var(--danger); }

/* ================= 响应式 ================= */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 272px 1fr; }
  .sidebar { height: 100dvh; border-right: 1px solid var(--line); }
  .main { height: 100dvh; }
  .menu { display: none; }
  .model-menu { left: auto; right: 22px; width: 300px; }
}
/* 手机上是两级页面（照扣子）：进来先看到「多个对话」，点进去才是聊天，
   聊天页左上角 ← 回到列表。
   v9.1：**不再用 display 硬切** —— 那一下太生硬（俞：缺少流畅的转场，显得廉价）。
   现在两层都常驻，靠 transform 推拉：列表往左退并淡出，聊天页从右侧滑进来。 */
@media (max-width: 899px) {
  /* ⚠️ 两层都钉死在 top:0，**绝不能用 visualViewport.offsetTop**。
     iOS 弹键盘会把可视区"往上推"，offsetTop 变成正值；谁把它写进 top，
     整个 App 就被推下去几十像素，顶上立刻空出一条底色 —— 俞报的"黑条"就是这个。
     （2026-10-11 实测：设 --vv-t:40px，sidebar.top 立刻变 40，顶部露 40px。）
     键盘遮挡改用另一条路：composer 自己撑开内边距（见下面的 --kb）。 */
  /* ⚠️ 这里要用 inset:0 **填满整个视口**，不能写 height:100dvh。
     俞 2026-10-11 实测：Safari 里正常、**主屏图标（PWA 全屏）里才有黑条**。
     原因：PWA 全屏时 dvh 算出来不含底部安全区（home indicator 那 34px），
     两层就矮一条，露出下面的 html 底色 —— 又是那条黑。
     `inset:0` 填的是 containing block（配合 viewport-fit=cover = 整块屏幕），
     安全区也盖得住。键盘遮挡不靠高度解决，靠 composer 的 --kb 内边距（见下）。 */
  .sidebar {
    position: fixed; inset: 0;
    width: auto; z-index: 40;
    transform: none;
    transition: transform .36s cubic-bezier(.22,.68,0,1), opacity .3s ease;
    will-change: transform, opacity;
  }
  .main {
    position: fixed; inset: 0;
    z-index: 50;
    display: grid;                       /* 常驻，靠 transform 控制在哪 */
    transform: translateX(100%);
    transition: transform .36s cubic-bezier(.22,.68,0,1);
    background: transparent;             /* 别挡着下面的壁纸层 */
    will-change: transform;
  }
  body:not(.in-chat) .main { pointer-events: none; }
  body.in-chat .sidebar { transform: translateX(-22%); opacity: 0; pointer-events: none; }
  body.in-chat .main { transform: none; }
  /* 聊天页进来时，消息轻轻往上浮一下 */
  body.in-chat .feed { animation: feedIn .4s cubic-bezier(.22,.68,0,1); }
  .mask { display: none; }
  .menu { display: grid; }

  /* 列表页按扣子的手感放大一点 */
  .side-head { padding: calc(18px + var(--st)) 14px 12px 18px; }
  .conv-main { padding: 14px 4px 14px 12px; gap: 6px; }
  .conv-item .ct { font-size: 17px; }
  .conv-item .cp { font-size: 14px; }
  .conv-list { padding: 4px 10px; }
  .conv-avatar { width: 44px; height: 44px; }
  .tab { font-size: 13px; padding: 11px 0 9px; }
  .tab svg { width: 24px; height: 24px; }
  .mine-list { padding: 4px 18px 22px; gap: 26px; }
  .mine-label { font-size: 15.5px; }
}

@keyframes feedIn { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ================= 电脑远控栏（2026-10-14 俞要） ================= */
.pc-state { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text); }
.foot-dot.off { background: var(--faint); }
.pc-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.pc-btns .tool-btn { padding: 12px 0; font-size: 14.5px; }
.tool-btn.pc-danger { border-color: color-mix(in srgb, var(--red, #e5484d) 55%, transparent); color: var(--red, #e5484d); }
.tool-btn.pc-danger:active { background: color-mix(in srgb, var(--red, #e5484d) 18%, transparent); }
.pc-log { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.pc-row { display: flex; gap: 8px; align-items: baseline; }
.pc-when { color: var(--faint); font-variant-numeric: tabular-nums; }
.pc-what { color: var(--text); white-space: nowrap; }
.pc-ok { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ================= 全屏远程桌面（2026-10-14） ================= */
.tool-btn.pc-cta { border-color: color-mix(in srgb, var(--ok, #3ddc84) 45%, transparent); color: var(--ok, #3ddc84); font-size: 15px; padding: 13px 0; }
.tool-btn.pc-cta:active { background: color-mix(in srgb, var(--ok, #3ddc84) 16%, transparent); }
.rt-overlay { position: fixed; inset: 0; z-index: 9999; background: #0f0f10; }
.rt-overlay iframe { width: 100%; height: 100%; border: 0; display: block; }
.rt-close { position: fixed; right: 10px; top: calc(8px + env(safe-area-inset-top)); z-index: 10000;
  font: inherit; font-size: 13px; color: #e8e8ea; background: rgba(40,40,48,.92); border: 1px solid #33333a;
  border-radius: 9px; padding: 7px 11px; backdrop-filter: blur(6px); }
body.rt-on .tabbar { display: none; }