/* ============================================================
   LiteChat 网页版 SPA（v2.4.0）
   —— 复用 /style.css 的变量与 /chat.css 的消息/Markdown 样式，
      这里只负责「应用外壳」：顶栏 + 侧栏 + 吸底输入区。
   ============================================================ */

/* ---------- 外壳 ---------- */
/* 关键：.app / .boot / .auth 都显式设了 display，会盖掉 [hidden] 自带的 display:none，
   导致「隐藏」的节点仍然拦截点击（启动遮罩挡住登录按钮就是这么来的）。 */
[hidden]{display:none!important}

html, body {
  height: 100%;
  /* 关掉移动端「字体放大 / font boosting」：它会把文字放大而不重排列宽，
     中文短句被硬折成两行、气泡看起来又窄又丑，就是它干的 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body.app-body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  overflow:hidden;                 /* 页面本身不滚，滚动全部交给 .msgs / .side-list */
  overscroll-behavior:none;
}
/* 高度用 --app-h（由 JS 取 visualViewport.height 写入）：
   手机浏览器地址栏/底部工具栏会吃掉可视高度，只写 inset:0 会把输入区切掉。
   ⚠️ 回退值必须是 100vh，不能写 100dvh —— 手表/老 WebView 不认识 dvh 时
   整条声明会「计算期失效」，height 直接变回 auto，输入框就被推到屏幕外。 */
.app{
  position:fixed; top:0; left:0; right:0;
  height:100vh;
  height:var(--app-h, 100vh);
  display:flex; flex-direction:column; background:var(--bg);
}

/* ---------- 顶栏 ---------- */
.topbar{
  flex:none; height:56px; display:flex; align-items:center; gap:12px;
  padding:0 14px; border-bottom:1px solid var(--line);
  background:var(--nav-bg);
  -webkit-backdrop-filter:saturate(180%) blur(18px);
  backdrop-filter:saturate(180%) blur(18px);
  z-index:50;
}
.topbar .brand{
  display:flex; align-items:center; gap:8px; flex:none;
  font-weight:700; font-size:15px; color:var(--text); text-decoration:none;
}
.topbar .brand img{width:26px; height:26px; border-radius:8px}
.topbar-right{
  margin-left:auto; display:flex; align-items:center; gap:2px;
  font-size:13px; color:var(--muted); min-width:0;
}
.topbar-right .who{
  max-width:170px; margin-right:6px; font-size:12.5px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.tb-link{
  appearance:none; border:none; background:transparent;
  font:inherit; font-size:13px; color:var(--muted);
  padding:6px 9px; border-radius:999px; cursor:pointer;
  text-decoration:none; white-space:nowrap;
}
.tb-link:hover{color:var(--text); background:var(--surface-2)}

/* ---------- 对话类型分段控件（v2.8.0）----------
   顶栏右侧「聊天 | 任务」。纯 CSS 实现，不引任何库；颜色全部取自 style.css 的变量，
   深色模式下自动跟随。 */
.seg{
  flex:none; display:inline-flex; align-items:center;
  padding:2px; margin-right:8px;
  background:var(--surface-2);
  border:1px solid var(--line);
  border-radius:999px;
}
.seg button{
  appearance:none; border:none; background:transparent;
  font:inherit; font-size:12.5px; line-height:1;
  color:var(--muted); padding:5px 12px; border-radius:999px;
  cursor:pointer; white-space:nowrap;
  transition:background .18s var(--ease), color .18s var(--ease);
}
.seg button:hover{color:var(--text)}
.seg button.on{
  /* --accent 在明暗两套主题下都是同一个亮黄，所以选中态的文字必须固定在深色，
     用 var(--text) 会在深色模式下变成白字压黄底，几乎看不见。 */
  background:var(--accent); color:#16181d; font-weight:600;
  box-shadow:var(--shadow-1);
}

.icon-btn{
  appearance:none; flex:none;
  width:34px; height:34px; display:inline-flex; align-items:center; justify-content:center;
  border:1px solid var(--line); border-radius:10px;
  background:var(--surface); color:var(--text);
  font-size:15px; line-height:1; cursor:pointer;
}
.icon-btn:hover{background:var(--surface-2)}

/* ---------- 两栏 ---------- */
.shell{flex:1; min-height:0; display:grid; grid-template-columns:286px minmax(0,1fr)}

/* ---------- 侧栏 ---------- */
.side{
  display:flex; flex-direction:column; min-height:0;
  background:var(--surface); border-right:1px solid var(--line);
}
.side-head{flex:none; padding:12px 12px 6px; display:flex; flex-direction:column; gap:8px}
.side-head-row{display:flex; align-items:center; justify-content:space-between; gap:8px; padding:0 2px}
.side-title{font-size:12.5px; font-weight:600; color:var(--muted); letter-spacing:.02em}
.btn-new{
  width:100%; font:inherit; font-size:13.5px; font-weight:600;
  color:var(--text); background:var(--surface-2);
  border:1px solid var(--line); border-radius:12px;
  padding:10px; cursor:pointer; text-align:left;
  transition:background .2s var(--ease), border-color .2s var(--ease);
}
.btn-new:hover{border-color:rgba(245,179,1,.5); background:var(--accent-soft)}
.btn-new span{font-size:14px; margin-right:2px}
.side-search{
  width:100%; box-sizing:border-box; font:inherit; font-size:12.5px;
  color:var(--text); background:var(--surface-2);
  border:1px solid var(--line); border-radius:10px;
  padding:7px 10px; outline:none;
}
.side-search:focus{border-color:rgba(26,115,232,.45)}
.side-list{
  flex:1; min-height:0; padding:2px 8px 8px;
  overflow-y:auto; overflow-x:hidden;      /* 关键：绝不出现横向滚动条 */
}
.side-foot{
  flex:none; padding:8px 14px calc(9px + env(safe-area-inset-bottom));
  border-top:1px solid var(--line);
  font-size:11.5px; color:var(--muted);
}
.side-links{display:flex; flex-wrap:wrap; gap:12px; margin-top:7px; font-size:12px}
.side-links a{color:var(--muted); text-decoration:none; padding:2px 0}
.side-links a:hover{color:var(--text); text-decoration:underline}
.side-empty{padding:22px 10px; text-align:center; font-size:12.5px; color:var(--muted)}

.conv{
  display:flex; align-items:center; gap:8px;
  max-width:100%; overflow:hidden;
  padding:9px 10px; margin-bottom:2px;
  border:1px solid transparent; border-radius:11px;
  cursor:pointer;
  transition:background .18s var(--ease), border-color .18s var(--ease);
}
.conv:hover{background:var(--surface-2)}
.conv.on{background:var(--accent-soft); border-color:rgba(245,179,1,.35)}
.conv .pin{flex:none; font-size:10.5px; opacity:.75}
/* v2.8.0: 任务对话在列表里的标记 */
.conv .conv-badge{
  flex:none; padding:0 5px; border-radius:999px;
  font-size:10px; font-weight:700; line-height:1.7; letter-spacing:.02em;
  color:var(--text); background:var(--accent-soft);
  border:1px solid rgba(245,179,1,.4);
}
.conv .t{
  flex:1; min-width:0;
  font-size:13.5px; line-height:1.45; color:var(--text);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;   /* 超长标题省略号 */
}
.conv .n{flex:none; font-size:11px; color:var(--muted); font-variant-numeric:tabular-nums}
.conv .del{
  flex:none; border:none; background:transparent; color:var(--muted);
  font-size:15px; line-height:1; padding:2px 4px; border-radius:6px;
  cursor:pointer; opacity:0; transition:opacity .15s, color .15s, background .15s;
}
.conv:hover .del, .conv.on .del{opacity:1}
.conv .del:hover{color:#c0392b; background:rgba(192,57,43,.08)}

/* ---------- 主区 ---------- */
.main{display:flex; flex-direction:column; min-width:0; min-height:0; position:relative; background:var(--bg)}
.chat-head{
  flex:none; padding:12px 20px; border-bottom:1px solid var(--line);
}
/* 标题栏、消息列、输入区统一 900px 宽并居中对齐，桌面端不会「标题贴左、消息居中」 */
.chat-head-inner{
  display:flex; align-items:baseline; gap:10px;
  width:100%; max-width:900px; margin:0 auto; min-width:0;
}
.chat-title{
  font-size:15px; font-weight:680; letter-spacing:-.01em;
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.chat-sub{flex:none; font-size:11.5px; color:var(--muted)}
.chat-sub .agent{color:#2F6FED}
/* v2.8.0: 任务对话标题前的徽标 */
.chat-title .badge-task{
  display:inline-block; vertical-align:1.5px;
  margin-right:6px; padding:1px 7px;
  font-size:10.5px; font-weight:700; letter-spacing:.02em;
  color:var(--text); background:var(--accent-soft);
  border:1px solid rgba(245,179,1,.45); border-radius:999px;
}

.msgs{
  flex:1; min-height:0;
  display:block;                 /* 必须显式覆盖 chat.css 的 display:grid —— 否则消息流会塌成一条窄列 */
  padding:20px 20px 8px;
  overflow-y:auto; overflow-x:hidden;
  overscroll-behavior:contain;
}
/* width:100% 不能省：只写 max-width + margin:auto 时，块级元素宽度会退化成
   fit-content（短对话整列塌成气泡那么宽并居中），这正是「桌面端看起来极其奇怪」的原因。 */
.msg-flow{display:flex; flex-direction:column; gap:18px; width:100%; max-width:900px; margin:0 auto}

/* 消息微调（气泡本体由 chat.css 提供） */
/* v2.4.1: 显式 max-content —— 气泡按内容撑开、再由 max-width 封顶。
   不写这一句时，某些手机浏览器（字体放大 / 弹性基准算错）会把气泡压窄，
   一句 9 个字的中文被硬折成两行。 */
.msg .col{max-width:min(760px,92%); min-width:0; width:max-content}
.msg .bubble{width:max-content; max-width:100%}
@media (max-width:860px){
  .msg .bubble{min-width:96px}      /* 极短回复（「收到」）也不至于成一条细缝 */
}
.msg .copy{
  margin-top:6px; border:none; background:transparent; color:var(--muted);
  font:inherit; font-size:11.5px; padding:2px 0; cursor:pointer;
}
.msg .copy:hover{color:var(--text)}
.md.streaming > :last-child::after{
  content:"▍"; margin-left:2px; color:var(--muted);
  animation:lc-blink 1s steps(1) infinite;
}
@keyframes lc-blink{50%{opacity:0}}

/* 思考过程折叠块（覆盖 chat.css 的 .reason 静态块）
   v2.4.2: 只让正文滚，summary 固定 —— 原来整块 overflow:auto，
   内容一长、滚到底部时「深度思考」这行标题就滚没了，没法收起。 */
details.reason{
  margin:0 0 8px; padding:0 14px 10px;
  max-height:22em; overflow:auto; overscroll-behavior:contain;
}
/* summary 吸顶：滚到任何位置都能看到「深度思考」并收起。
   注意不能用 flex 分栏 —— Chrome 131+ 把 details 内容包进 ::details-content，
   子元素不再是 flex item，flex:1 会失效。 */
details.reason > summary{
  position:sticky; top:0; z-index:2;
  background:var(--surface-2);
  padding:10px 0 6px;
  cursor:pointer; list-style:none;
  font-size:11.5px; font-weight:600; letter-spacing:.03em; color:var(--muted);
  user-select:none;
}
details.reason > summary::-webkit-details-marker{display:none}
details.reason > summary::before{content:"▸ "; display:inline-block}
details.reason[open] > summary::before{content:"▾ "}
details.reason .md{margin-top:2px; font-size:13px; color:var(--muted)}

/* 附件 */
.att-grid{display:flex; flex-wrap:wrap; gap:6px; margin-top:8px}
.att-img{
  display:block; max-width:220px; max-height:220px;
  border-radius:10px; object-fit:cover; cursor:zoom-in;
  background:var(--surface-2);
}

/* ---------- 输入区（吸底：flex 列的最后一项，消息区自己滚） ---------- */
.composer{
  flex:none;
  background:var(--bg);
  border-top:1px solid var(--line);
  padding:10px 16px calc(10px + env(safe-area-inset-bottom));
}
.composer-inner{width:100%; max-width:900px; margin:0 auto}
.composer.drag{background:rgba(245,179,1,.08); box-shadow:inset 0 0 0 2px rgba(245,179,1,.45)}
.composer textarea{
  display:block; width:100%; box-sizing:border-box;
  font:inherit; font-size:14.5px; line-height:1.65; color:var(--text);
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  padding:11px 13px; outline:none; resize:none;
  min-height:46px; max-height:200px;
  transition:border-color .2s var(--ease);
}
.composer textarea:focus{border-color:rgba(26,115,232,.5)}
.composer-bar{display:flex; align-items:center; gap:8px; margin-top:8px; flex-wrap:wrap}
.bar-left{display:flex; align-items:center; gap:6px; flex-wrap:wrap; min-width:0}
.bar-right{display:flex; align-items:center; gap:8px; margin-left:auto}
.composer .chk{padding:5px 11px; font-size:12.5px; line-height:1.2}
.composer .sel{
  font-size:12.5px; padding:6px 28px 6px 10px;
  border-radius:10px; max-width:190px; text-overflow:ellipsis;
  background-position:right 8px center; background-size:13px;
}
.composer .btn-send{padding:8px 20px; font-size:13.5px}
.composer .btn-send:disabled{opacity:.55; cursor:default; transform:none!important; box-shadow:none!important}
.btn-stop{
  appearance:none; font:inherit; font-size:13px; font-weight:600;
  padding:8px 15px; border-radius:999px; cursor:pointer;
  border:1px solid rgba(192,57,43,.4); background:rgba(192,57,43,.06); color:#c0392b;
}
.btn-stop:hover{background:rgba(192,57,43,.12)}
.hint{font-size:11.5px; color:var(--muted); max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.hint.warn{color:#c0392b}

/* 待发送图片 */
.attach-row{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px}
.chip{
  position:relative; flex:none; width:66px; height:66px;
  border:1px solid var(--line); border-radius:10px; overflow:hidden; background:var(--surface-2);
}
.chip img{width:100%; height:100%; object-fit:cover; display:block}
.chip .bar{position:absolute; left:0; right:0; bottom:0; height:3px; background:rgba(0,0,0,.16)}
.chip .bar i{display:block; height:100%; width:0; background:#1a73e8; transition:width .2s}
.chip .x{
  position:absolute; top:2px; right:2px; width:18px; height:18px;
  display:flex; align-items:center; justify-content:center;
  border:none; border-radius:50%; background:rgba(0,0,0,.55);
  color:#fff; font-size:12px; line-height:1; cursor:pointer; padding:0;
}
.chip.err{border-color:#c0392b}
.chip.err::after{
  content:"失败"; position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background:rgba(192,57,43,.72); color:#fff; font-size:11px;
}

/* 回到底部 */
.jump{
  display:flex; width:max-content; max-width:88%;
  position:sticky; bottom:4px; z-index:6;
  margin:-42px auto 6px;
  border:1px solid #CFE0FB; background:#fff; color:#1A73E8;
  font:inherit; font-size:12.5px; padding:7px 14px; border-radius:999px;
  cursor:pointer; box-shadow:0 2px 10px rgba(0,0,0,.12);
}
.jump:hover{background:#F2F7FF; border-color:#9CC4F7}

/* ---------- 欢迎页 ---------- */
.welcome{max-width:660px; margin:min(8vh,64px) auto 0; text-align:center; color:var(--muted)}
.welcome img{width:58px; height:58px; border-radius:17px; margin-bottom:16px; box-shadow:0 12px 28px -14px rgba(16,18,24,.45)}
.welcome h2{font-size:1.16rem; font-weight:700; color:var(--text); letter-spacing:-.02em; margin-bottom:7px}
.welcome p{font-size:13.5px; line-height:1.75; margin-bottom:20px}
.sugs{display:flex; flex-wrap:wrap; gap:8px; justify-content:center}
.sug{
  font:inherit; font-size:13px; color:var(--text);
  background:var(--surface); border:1px solid var(--line);
  border-radius:12px; padding:9px 13px; cursor:pointer;
  transition:border-color .2s var(--ease), background .2s var(--ease);
}
.sug:hover{border-color:rgba(245,179,1,.55); background:var(--accent-soft)}

/* ---------- 启动 / 登录 ---------- */
.boot{
  position:fixed; inset:0; z-index:200;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px;
  background:var(--bg); color:var(--muted); font-size:13.5px;
}
.boot img{width:52px; height:52px; border-radius:16px; animation:lc-pop 1.6s ease-in-out infinite}
@keyframes lc-pop{0%,100%{transform:scale(1);opacity:.9}50%{transform:scale(1.05);opacity:1}}

/* 登录页：小屏（尤其方屏手表）上内容一定比屏幕高，必须自己滚。
   原来 #auth 没有高度约束、body 又是 overflow:hidden → 登录按钮直接被裁掉、点不到。 */
.auth-body{
  position:fixed; top:0; left:0; right:0;
  height:100vh;
  height:var(--app-h, 100vh);
  display:flex; flex-direction:column; align-items:center; justify-content:flex-start;
  overflow-y:auto; -webkit-overflow-scrolling:touch;
  padding:14px; box-sizing:border-box;
}
.auth-body .login-card{margin:auto 0; flex:none}
.auth-tabs{display:flex; gap:4px; background:var(--surface-2); border-radius:12px; padding:4px; margin-bottom:10px}
.auth-tabs button{
  flex:1; border:none; background:transparent; font:inherit; font-size:13.5px;
  color:var(--muted); padding:8px; border-radius:9px; cursor:pointer;
}
.auth-tabs button.on{background:var(--surface); color:var(--text); font-weight:600; box-shadow:var(--shadow-1)}
/* v2.4.0: 邮箱 / 手机号 二级切换 */
.chan-row{display:flex; gap:6px; justify-content:center; margin-bottom:16px}
.chan-row button{
  border:1px solid var(--line); background:transparent; font:inherit; font-size:12.5px;
  color:var(--muted); padding:5px 14px; border-radius:999px; cursor:pointer;
  transition:color .2s, border-color .2s, background .2s;
}
.chan-row button.on{color:#1a73e8; border-color:rgba(26,115,232,.45); background:rgba(26,115,232,.06)}
.auth-tip{font-size:11.5px; color:var(--muted); text-align:center; margin-top:10px}
.code-row{display:flex; gap:8px; margin-bottom:15px}
.code-row input{margin-bottom:0!important; flex:1; min-width:0}
.code-row button{
  flex:none; font:inherit; font-size:12.5px; color:var(--text);
  background:var(--surface-2); border:1px solid var(--line); border-radius:11px;
  padding:0 12px; cursor:pointer; white-space:nowrap;
}
.code-row button:disabled{opacity:.55; cursor:default}
.auth-err{
  background:rgba(214,48,49,.07); border:1px solid rgba(214,48,49,.25);
  color:#c0392b; font-size:12.5px; border-radius:10px;
  padding:8px 11px; margin-top:12px;
}

/* ---------- 轻提示 ---------- */
.toast{
  position:fixed; left:50%; transform:translateX(-50%); bottom:104px; z-index:300;
  max-width:86vw; padding:9px 15px; border-radius:999px;
  background:rgba(20,22,28,.92); color:#fff; font-size:13px;
  box-shadow:0 8px 24px rgba(0,0,0,.25);
}

/* ---------- 移动端 ---------- */
@media (max-width:860px){
  .shell{grid-template-columns:minmax(0,1fr)}
  .side{
    position:fixed; left:0; top:0; width:86%; max-width:330px; z-index:70;
    height:100vh; height:var(--app-h, 100vh);
    padding-top:env(safe-area-inset-top);
    transform:translateX(-104%); transition:transform .24s var(--ease);
    box-shadow:10px 0 30px rgba(0,0,0,.14);
  }
  .side.open{transform:none}
  .side-mask{position:fixed; inset:0; background:rgba(0,0,0,.42); z-index:65}
  .topbar{height:52px; padding:0 8px; gap:6px}
  .topbar .brand span{display:none}      /* 窄屏只留图标，别把 LiteChat 挤成「lc」 */
  .topbar-right .who{display:none}
  .topbar-right{gap:0}
  .tb-link{padding:6px 7px; font-size:12.5px}
  .seg{margin-right:4px}
  .seg button{padding:5px 9px; font-size:12px}
  .only-wide{display:none}
  .chat-head{padding:9px 12px}
  .chat-title{font-size:14px}
  .msgs{padding:12px 10px 6px}
  .msg-flow{gap:14px}
  .msg .col{max-width:92%}
  .msg .bubble{padding:11px 14px; font-size:14px; line-height:1.72}
  .composer{padding:7px 9px calc(7px + env(safe-area-inset-bottom))}
  .composer textarea{min-height:40px; padding:9px 11px; font-size:14px; line-height:1.55; max-height:150px}
  .composer-bar{margin-top:6px; gap:6px}
  .bar-left{gap:5px}
  .composer .chk{padding:4px 9px; font-size:11.5px}
  .composer .sel{max-width:112px; padding:5px 22px 5px 8px; font-size:11.5px; background-position:right 6px center; background-size:12px}
  .composer .btn-send{padding:7px 16px; font-size:13px}
  .btn-stop{padding:7px 12px; font-size:12.5px}
  .hint{display:none}
  .welcome{margin-top:4vh}
  .att-img{max-width:180px; max-height:180px}
}
@media (min-width:861px){ .only-mobile{display:none} }

/* ---------- 矮屏（方屏手表 / 横屏手机 / 分屏）----------
   目标：把顶栏、标题栏、输入区压到最薄，把高度尽量留给消息。
   320×320 下手表浏览器也能完整看到输入框和发送按钮。
   ⚠️ 必须同时限定宽度：桌面浏览器窗口拉矮（比如 1085×559）时不该被压缩，
      否则整个界面会突然「变小一号」，看起来像缩放错了。 */
@media (max-height:560px) and (max-width:900px){
  .topbar{height:44px; padding:0 6px}
  .topbar .brand img{width:22px; height:22px}
  .tb-link{padding:4px 6px; font-size:12px}
  .seg{margin-right:3px; padding:1px}
  .seg button{padding:3px 7px; font-size:11.5px}
  .icon-btn{width:30px; height:30px; font-size:14px; border-radius:9px}
  .chat-head{padding:5px 10px}
  .chat-title{font-size:13px}
  .chat-sub{display:none}
  .msgs{padding:8px 8px 4px}
  .msg-flow{gap:10px}
  .msg .bubble{padding:8px 11px; font-size:13.5px; line-height:1.6; border-radius:14px}
  .msg .col{max-width:94%}
  .composer{padding:4px 8px calc(4px + env(safe-area-inset-bottom))}
  .composer textarea{min-height:32px; max-height:88px; padding:6px 9px; font-size:13px; line-height:1.45; border-radius:11px}
  .composer-bar{margin-top:4px; gap:4px}
  .bar-left{gap:4px}
  .composer .chk{padding:2px 7px; font-size:11px}
  .composer .sel{max-width:88px; padding:4px 17px 4px 6px; font-size:11px;
    background-size:11px; background-position:right 4px center; border-radius:8px}
  .composer .btn-send{padding:5px 12px; font-size:12px}
  .btn-stop{padding:5px 10px; font-size:11.5px}
  .composer .icon-btn{width:28px; height:28px; font-size:13px}
  .attach-row{gap:5px; margin-bottom:5px}
  .chip{width:48px; height:48px; border-radius:8px}
  .welcome{margin-top:2vh}
  .welcome img{width:38px; height:38px; margin-bottom:8px}
  .welcome h2{font-size:1rem}
  .welcome p{display:none}
  .sugs{gap:5px}
  .sug{font-size:12px; padding:6px 9px; border-radius:9px}
  .auth-body{padding:8px}
  .login-card{padding:18px 14px 14px; border-radius:18px}
  .login-card .lg-icon{width:42px; height:42px; margin-bottom:8px; border-radius:13px}
  .login-card h1{font-size:1.02rem}
  .login-card .lg-sub{margin-bottom:12px; font-size:12px}
  .auth-tabs{margin-bottom:10px}
  .login-card label{font-size:11.5px; margin-bottom:5px}
  .login-card input{padding:8px 10px; margin-bottom:9px; font-size:13.5px}
  .code-row{margin-bottom:9px}
  .auth-err{font-size:11.5px; padding:6px 9px}
}

/* ==================================================================
   智能体管理（#/agents，v2.8.1）
   —— 纯前端骨架：卡片网格 / 空态 / 编辑抽屉。
      颜色与圆角全部复用 style.css 的变量，不引入新的设计系统。
   ================================================================== */
.agents{display:flex; flex-direction:column; flex:1; min-height:0; background:var(--bg)}
.agents[hidden]{display:none}
/* 智能体视图铺满 .app 时把聊天两栏整体藏掉，不叠在下面浪费绘制 */
.app.agents-mode .shell{display:none}

.agents-head{
  flex:none; padding:14px 20px 12px;
  border-bottom:1px solid var(--line); background:var(--surface);
}
.agents-head-inner{
  display:flex; align-items:center; gap:12px;
  width:100%; max-width:1000px; margin:0 auto; min-width:0;
}
.agents-titles{flex:1; min-width:0}
.agents-titles h2{font-size:16px; font-weight:700; letter-spacing:-.01em}
.agents-titles p{font-size:12px; color:var(--muted); margin-top:2px}
.agents-actions{flex:none; display:flex; align-items:center; gap:8px}

.agents-body{flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; padding:20px 20px 32px}
.agents-grid{
  display:grid; grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:14px; width:100%; max-width:1000px; margin:0 auto;
}

/* ---------- 卡片 ---------- */
.agent-card{
  display:flex; gap:12px; align-items:flex-start; min-width:0;
  padding:14px; text-align:left;
  font:inherit; color:inherit;
  background:var(--surface); border:1px solid var(--line); border-radius:16px;
  cursor:pointer;
  transition:border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.agent-card:hover{border-color:rgba(245,179,1,.5); box-shadow:var(--shadow-1); transform:translateY(-2px)}
.agent-card:focus-visible{outline:2px solid var(--accent); outline-offset:2px}

.agent-av{
  flex:none; width:56px; height:56px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; overflow:hidden;
  font-size:20px; font-weight:700; line-height:1;
  /* 底色是半透明亮黄，深色模式下依然是暗底，所以文字用 --text 两套主题都够 */
  color:var(--text); background:var(--accent-soft);
  border:1px solid rgba(245,179,1,.35);
}
.agent-av img{width:100%; height:100%; object-fit:cover; display:block}

.agent-main{flex:1; min-width:0}
.agent-top{display:flex; align-items:center; gap:8px; min-width:0}
.agent-top h3{
  flex:1; min-width:0;
  font-size:13.5px; font-weight:680; letter-spacing:-.01em;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.agent-vis{
  flex:none; padding:0 6px; border-radius:999px;
  font-size:10px; font-weight:700; line-height:1.7; letter-spacing:.02em;
  color:var(--text); background:var(--accent-soft);
  border:1px solid rgba(245,179,1,.45);
}
.agent-vis.priv{background:var(--surface-2); border-color:var(--line); color:var(--muted)}
.agent-desc{
  margin-top:5px; font-size:12px; line-height:1.6; color:var(--muted);
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2;
  overflow:hidden;
}

/* ---------- 空态 / 错误态 ---------- */
.agents-empty{
  grid-column:1 / -1; padding:44px 20px; text-align:center;
  background:var(--surface); border:1px dashed var(--line); border-radius:16px;
}
.agents-empty h3{font-size:14px; font-weight:700; letter-spacing:-.01em; margin-bottom:7px}
.agents-empty p{
  font-size:12.5px; line-height:1.75; color:var(--muted);
  max-width:34em; margin:0 auto;
}
.agents-empty b{color:var(--text); font-weight:600}

/* ---------- 编辑抽屉 ---------- */
.drawer-mask{position:fixed; inset:0; z-index:200; background:rgba(0,0,0,.42)}
.drawer-mask[hidden]{display:none}
.drawer{
  position:fixed; top:0; right:0; bottom:0; z-index:210;
  width:420px; max-width:100%;
  display:flex;
  background:var(--surface); border-left:1px solid var(--line);
  box-shadow:var(--shadow-2);
}
.drawer[hidden]{display:none}
.drawer-inner{flex:1; min-width:0; display:flex; flex-direction:column; min-height:0}

.drawer-head{
  flex:none; display:flex; align-items:center; gap:8px;
  padding:12px 14px; border-bottom:1px solid var(--line);
}
.drawer-head h3{flex:1; min-width:0; font-size:14px; font-weight:700; letter-spacing:-.01em}
.drawer-body{flex:1; min-height:0; overflow-y:auto; padding:6px 14px 16px}
.drawer-foot{
  flex:none; display:flex; gap:8px; justify-content:flex-end;
  padding:10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top:1px solid var(--line);
}

.av-row{display:flex; align-items:center; gap:12px; padding:8px 0 4px}
.av-meta{min-width:0}
.av-btn{
  padding:4px 0; font-size:12.5px; font-weight:600; color:var(--text);
  text-align:left; border-radius:8px;
}
.av-btn:hover{background:transparent; color:var(--text); text-decoration:underline}
.av-hint{font-size:11.5px; color:var(--muted); line-height:1.55; margin-top:2px}

.drawer-body label{
  display:block; margin:14px 0 5px;
  font-size:11.5px; font-weight:600; color:var(--muted);
}
.drawer-body input[type="text"],
.drawer-body input:not([type]),
.drawer-body textarea{
  width:100%; box-sizing:border-box;
  font:inherit; font-size:13.5px; line-height:1.6; color:var(--text);
  background:var(--surface-2); border:1px solid var(--line); border-radius:10px;
  padding:9px 11px; outline:none;
  transition:border-color .2s var(--ease);
}
.drawer-body input[type="text"]:focus,
.drawer-body input:not([type]):focus,
.drawer-body textarea:focus{border-color:rgba(245,179,1,.6)}
.drawer-body textarea{resize:vertical; min-height:104px; font-family:inherit}

/* 公开开关：沿用 .chk 的胶囊外观，只把它拉满一行。
   .chk 的原生 checkbox 是视觉隐藏的（靠 .on 变蓝），在表单里光看文字判断不出
   能不能点，所以这里补一个可见的方块指示器 —— 关=空框，开=亮黄实心。 */
.drawer .pub-switch{
  display:flex; width:100%; box-sizing:border-box;
  justify-content:flex-start; border-radius:12px;
  padding:10px 12px; margin-top:16px; font-size:13px;
}
.drawer .pub-switch::before{
  content:""; flex:none; width:16px; height:16px; border-radius:5px;
  box-sizing:border-box; background:transparent;
  /* 用 currentColor 跟着 .chk 自身的文字色走：关=灰框空框，开=实心（.chk.on 的蓝） */
  border:1.5px solid currentColor;
  opacity:.55;
  transition:background .2s var(--ease), opacity .2s var(--ease);
}
.drawer .pub-switch.on::before{background:currentColor; opacity:.85}

@media (max-width:1000px){
  .agents-grid{grid-template-columns:repeat(2, minmax(0, 1fr))}
}
@media (max-width:640px){
  .agents-grid{grid-template-columns:minmax(0, 1fr); gap:10px}
  .agents-head{padding:10px 12px}
  .agents-titles h2{font-size:15px}
  .agents-body{padding:12px 12px 24px}
  .drawer{width:100%}
  .agent-card{padding:12px}
}
