/* ============================================================================
 * 白泽 App · 移动端设计层（2026-10-28 重做）
 * ----------------------------------------------------------------------------
 * 定位：只在「手机视口 / PWA standalone」接管门户，桌面门户零变化。
 * 结构：底部 5 格（首页 · 最多 3 个模块 · 我的）+ 三个自绘页面（首页 / 白泽晓 / 我的）
 *      + 各子系统同源 iframe 面板。
 *
 * 三条硬规则（沿用家族约束）：
 *   1. 颜色只走 --c-* 令牌，深浅两套由 baize.tokens.css 提供，不写死十六进制；
 *   2. 无 emoji 图标，一律内联 SVG（app-icons.js），颜色 currentColor；
 *   3. 触达区 ≥ 44px（iOS HIG / Material 共同底线），字号 ≥ 11px。
 * ============================================================================ */

:root {
  --bar-h: 58px;
  --nav-h: 48px;
  --page-pad: 16px;
  /* 模块强调色：九个系统各一。浅色底不能在这里算 —— :root 上 --tile 为空，
     color-mix 会整条失效变成透明；必须在设置 --tile 的元素上就地求值（见 .mod/.recent-row/.sheet-item）。 */
}

/* 壳激活时隐藏门户桌面件 */
body.baize-app .topbar,
body.baize-app .hero,
body.baize-app .cards,
body.baize-app .xiao,
body.baize-app .footer,
body.baize-app .wx-hint,
body.baize-app .install-bar,
body.baize-app #main {
  display: none !important;
}
body.baize-app {
  overflow: hidden;
  background: var(--c-bg);
  overscroll-behavior: none;
}

#baizeShell { display: none; }
body.baize-app #baizeShell { display: block; }

/* ============================================================================
   一、页面容器
   ============================================================================ */

#baizeShell .shell-pages {
  position: fixed;
  left: 0; right: 0; top: 0;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  background: var(--c-bg);
  overflow: hidden;
}

#baizeShell .shell-page {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
#baizeShell .shell-page.on { display: block; }

/* 子系统面板容器：只有当前视图是模块时才显示 */
#baizeShell #shellPanes {
  position: absolute; inset: 0;
  display: none;
}
#baizeShell #shellPanes.on { display: block; }

/* 子系统面板：iframe 自己滚，外层不滚 */
#baizeShell .shell-pane {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  background: var(--c-bg);
}
#baizeShell .shell-pane.on { display: block; }
/* 首次加载骨架：品牌图标 + 模块名 + 进度条，替代一片空白 */
#baizeShell .shell-pane .pane-load {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  background: var(--c-bg);
  pointer-events: none;
}
#baizeShell .shell-pane .pane-load .pl-ico {
  width: 56px; height: 56px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--tile);
  background: color-mix(in srgb, var(--tile) 12%, var(--c-surface));
  background: var(--c-surface-2);
  animation: bzPulse 1.6s ease-in-out infinite;
}
#baizeShell .shell-pane .pane-load .pl-ico svg { width: 27px; height: 27px; }
#baizeShell .shell-pane .pane-load .pl-name {
  font-size: 14px; font-weight: 600; color: var(--c-text);
}
#baizeShell .shell-pane .pane-load .pl-tip {
  font-size: 12px; color: var(--c-muted);
}
#baizeShell .shell-pane .pane-load .pl-bar {
  margin-top: 4px; width: 96px; height: 3px; border-radius: 2px;
  background: var(--c-surface-3); overflow: hidden;
}
#baizeShell .shell-pane .pane-load .pl-bar i {
  display: block; width: 40%; height: 100%; border-radius: 2px;
  background: var(--c-primary);
  animation: bzSlide 1.25s ease-in-out infinite;
}
@keyframes bzPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes bzSlide { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }

#baizeShell .shell-pane iframe {
  width: 100%; height: 100%; border: 0; display: block; background: transparent;
}

/* 白泽慧远程桌面：提示条 + iframe 竖排占满剩余高度。
   `.on` 的 display:block 要压过，故特异度提到 has-top.on。 */
#baizeShell .shell-pane.has-top.on { display: flex; flex-direction: column; }
#baizeShell .shell-pane.has-top iframe { flex: 1 1 auto; height: auto; min-height: 0; }
#baizeShell .pane-top {
  flex: 0 0 auto;
  height: 36px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  font-size: 12px; color: var(--c-muted);
}
#baizeShell .pane-top .pt-tip {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .pane-top .pt-btn {
  flex: 0 0 auto;
  min-width: 44px; height: 28px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  background: var(--c-surface-2);
  color: var(--c-text);
  font: inherit; font-size: 12px;
  cursor: pointer;
}
#baizeShell .pane-top .pt-btn:active { background: var(--c-surface-3); }
#baizeShell .pane-top .pt-btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 1px; }

/* 沉浸全屏：只藏壳体 chrome，iframe 本身不缩放（远程桌面按原比例渲染） */
body.bz-immersive #baizeShell .shell-bar,
body.bz-immersive #baizeShell .pane-top { display: none; }

/* ============================================================================
   二、底部页签
   ============================================================================ */

#baizeShell .shell-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  background: var(--c-surface);
  border-top: 1px solid var(--c-line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -1px 0 rgba(16, 32, 64, .02);
}

#baizeShell .shell-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 2px 4px;
  font: inherit; font-size: 11.5px; line-height: 1.1; letter-spacing: .2px;
  color: var(--c-muted);
  -webkit-tap-highlight-color: transparent;
  transition: color .16s ease;
}
#baizeShell .shell-tab .tab-ico {
  width: 23px; height: 23px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .16s cubic-bezier(.2, .8, .3, 1);
}
#baizeShell .shell-tab .tab-ico svg { width: 22px; height: 22px; display: block; }
#baizeShell .shell-tab span.tab-label {
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .shell-tab.on { color: var(--c-primary); }
#baizeShell .shell-tab.on .tab-label { font-weight: 600; }
#baizeShell .shell-tab.on .tab-ico { transform: translateY(-1px); }
#baizeShell .shell-tab:active .tab-ico { transform: scale(.92); }
#baizeShell .shell-tab:focus-visible {
  outline: 2px solid var(--c-primary); outline-offset: -3px; border-radius: 12px;
}

/* ============================================================================
   三、通用页面件（首页 / 白泽晓 / 我的 共用）
   ============================================================================ */

#baizeShell .page-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  height: var(--nav-h);
  padding: 0 var(--page-pad);
  background: color-mix(in srgb, var(--c-bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
#baizeShell .page-head.scrolled { border-bottom-color: var(--c-line); }
#baizeShell .page-head h1 {
  margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .2px;
  color: var(--c-text);
}
#baizeShell .page-head .head-sub {
  font-size: 11px; color: var(--c-muted); margin-left: 2px; font-weight: 400;
}
#baizeShell .page-head .spacer { flex: 1 1 auto; }

#baizeShell .icon-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .icon-btn svg { width: 21px; height: 21px; }
#baizeShell .icon-btn:active { background: var(--c-surface-3); }

#baizeShell .page-body {
  padding: 4px var(--page-pad) calc(24px + env(safe-area-inset-bottom, 0px));
}

#baizeShell .sec {
  margin-top: 22px;
}
#baizeShell .sec:first-child { margin-top: 4px; }
#baizeShell .sec-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0 2px 10px;
  font-size: 13px; font-weight: 600; color: var(--c-text); letter-spacing: .2px;
}
#baizeShell .sec-title .sec-more {
  margin-left: auto; font-size: 12px; font-weight: 400; color: var(--c-muted);
  background: none; border: 0; padding: 4px 0; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 2px;
}
#baizeShell .sec-title .sec-more svg { width: 14px; height: 14px; }

/* ============================================================================
   四、首页
   ============================================================================ */

#baizeShell .home-hero {
  padding: 6px var(--page-pad) 0;
}
#baizeShell .home-hello {
  margin: 8px 0 2px;
  font-size: 23px; line-height: 1.24; font-weight: 650; letter-spacing: -.2px;
  color: var(--c-text);
}
#baizeShell .home-hello small {
  display: block; margin-top: 5px;
  font-size: 12.5px; font-weight: 400; color: var(--c-muted); letter-spacing: 0;
}

/* 问白泽晓：首页最显眼的入口，点击进 AI 页 */
#baizeShell .ask-bar {
  margin: 14px 0 0;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-line);
  border-radius: 15px;
  background: var(--c-surface);
  color: var(--c-muted);
  font: inherit; font-size: 13.5px; text-align: left;
  cursor: pointer;
  box-shadow: var(--c-shadow);
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .ask-bar svg { width: 19px; height: 19px; flex: none; color: var(--c-primary); }
#baizeShell .ask-bar .ask-txt {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .ask-bar .ask-go {
  flex: none; display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; color: var(--c-primary); font-weight: 500;
}
#baizeShell .ask-bar:active { transform: scale(.995); }

/* 模块宫格 */
#baizeShell .mod-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 6px;
}
#baizeShell .mod {
  --tile-soft: color-mix(in srgb, var(--tile) 12%, var(--c-surface));
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 2px 0;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .mod .tile {
  position: relative;
  width: 54px; height: 54px;
  border-radius: 17px;
  display: flex; align-items: center; justify-content: center;
  color: var(--tile);
  background: var(--c-surface-2);          /* 不支持 color-mix 的内核回退 */
  background: var(--tile-soft);
  transition: transform .16s cubic-bezier(.2, .8, .3, 1);
}
#baizeShell .mod .tile svg { width: 26px; height: 26px; }
#baizeShell .mod:active .tile { transform: scale(.93); }
#baizeShell .mod .dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--r-green, #2A9D8F);
  box-shadow: 0 0 0 2px var(--tile-soft);
}
#baizeShell .mod .dot.off { background: var(--c-line-2); }
#baizeShell .mod .m-name {
  font-size: 11.5px; line-height: 1.2; color: var(--c-text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .mod.on .m-name { color: var(--c-primary); font-weight: 600; }
/* 2026-10-29：宫格补功能说明 —— 代号（白泽闻）为主、功能名（情报收集）为辅，
   最多 2 行，避免诗意代号让新用户猜不出每个格子干什么。 */
#baizeShell .mod .m-desc {
  font-size: 10px; line-height: 1.25; color: var(--c-muted);
  max-width: 100%; margin-top: -3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* 2026-11-03 首页宫格置顶：复用桌面 .card-pin 的令牌配色，不新增色值。
   未置顶态只显示文字（弱化噪音），置顶态沿用 .card-pin.on 的实心药丸；
   按钮高度 44px，满足触控下限。 */
#baizeShell .mod-cell { display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
#baizeShell .mod-cell .mod { width: 100%; }
#baizeShell .mod-pin {
  margin: 0; width: 100%; max-width: 80px;
  height: 44px; min-height: 44px; padding: 0 6px;
  border-color: transparent; background: transparent;
  font-size: 11px;
}
#baizeShell .mod-cell.pinned .tile { box-shadow: 0 0 0 2px var(--c-primary); }

/* 白泽晓卡片 */
#baizeShell .ai-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 16px;
  border: 0; border-radius: 18px;
  font: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
  box-shadow: var(--c-shadow-up);
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .ai-card::after {
  content: ''; position: absolute; right: -34px; top: -46px;
  width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
#baizeShell .ai-card .ai-ico {
  flex: none; width: 40px; height: 40px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .18);
}
#baizeShell .ai-card .ai-ico svg { width: 23px; height: 23px; }
#baizeShell .ai-card .ai-txt { min-width: 0; }
#baizeShell .ai-card .ai-t {
  font-size: 15px; font-weight: 600; letter-spacing: .2px;
}
#baizeShell .ai-card .ai-d {
  margin-top: 3px; font-size: 11.5px; line-height: 1.35; opacity: .82;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
#baizeShell .ai-card .ai-go {
  margin-left: auto; flex: none; opacity: .8;
}
#baizeShell .ai-card .ai-go svg { width: 20px; height: 20px; }

/* 最近访问 */
#baizeShell .recent-list { display: flex; flex-direction: column; gap: 2px; }
#baizeShell .recent-row {
  --tile-soft: color-mix(in srgb, var(--tile) 12%, var(--c-surface));
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 2px;
  font: inherit; text-align: left; color: var(--c-text);
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .recent-row .tile {
  flex: none; width: 36px; height: 36px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--tile);
  background: var(--c-surface-2);
  background: var(--tile-soft);
}
#baizeShell .recent-row .tile svg { width: 19px; height: 19px; }
#baizeShell .recent-row .r-main { flex: 1 1 auto; min-width: 0; }
#baizeShell .recent-row .r-t { font-size: 13.5px; font-weight: 500; }
#baizeShell .recent-row .r-d {
  font-size: 11.5px; color: var(--c-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .recent-row .r-go { color: var(--c-line-2); flex: none; }
#baizeShell .recent-row .r-go svg { width: 17px; height: 17px; }
#baizeShell .recent-row:active { background: var(--c-surface-2); }

#baizeShell .home-foot {
  margin-top: 26px; text-align: center;
  font-size: 11px; line-height: 1.9; color: var(--c-muted);
}
#baizeShell .home-foot a { color: inherit; text-decoration: none; }
#baizeShell .home-foot .foot-links {
  display: flex; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 6px;
}
#baizeShell .home-foot button {
  appearance: none; border: 0; background: none; padding: 0;
  font: inherit; color: var(--c-muted); cursor: pointer;
}

/* ============================================================================
   五、我的
   ============================================================================ */

#baizeShell .me-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 18px;
  box-shadow: var(--c-shadow);
}
#baizeShell .me-card .avatar {
  flex: none; width: 52px; height: 52px; border-radius: 16px;
  background: var(--c-primary-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#baizeShell .me-card .avatar {
  font-size: 21px; font-weight: 600; color: var(--c-primary); letter-spacing: 0;
}
/* 兜底：任何直接挂在 .cell 下的 svg 都不能被 flex 撑满 */
#baizeShell .cell > svg { width: 18px; height: 18px; flex: none; }
#baizeShell .me-card .u-main { min-width: 0; flex: 1 1 auto; }
#baizeShell .me-card .u-name {
  font-size: 17px; font-weight: 600; letter-spacing: .2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .me-card .u-meta {
  margin-top: 4px; font-size: 11.5px; color: var(--c-muted);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
#baizeShell .me-card .u-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 10.5px; line-height: 1.5;
  background: var(--c-primary-soft); color: var(--c-primary);
}
#baizeShell .me-card .u-tag.plain { background: var(--c-surface-3); color: var(--c-muted); }

#baizeShell .cells {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--c-shadow);
}
#baizeShell .cell {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 0 var(--page-pad) 0 14px;
  min-height: 52px;
  font: inherit; font-size: 14px; text-align: left; color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .cell + .cell { border-top: 1px solid var(--c-line); }
#baizeShell .cell .c-ico {
  flex: none; width: 30px; height: 30px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-surface-3); color: var(--c-muted);
}
#baizeShell .cell .c-ico svg { width: 18px; height: 18px; }
#baizeShell .cell .c-label { flex: 1 1 auto; min-width: 0; }
#baizeShell .cell .c-val {
  flex: none; max-width: 46%; font-size: 12.5px; color: var(--c-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#baizeShell .cell .c-go { flex: none; color: var(--c-line-2); display: flex; }
#baizeShell .cell .c-go svg { width: 17px; height: 17px; }
#baizeShell .cell:active { background: var(--c-surface-2); }
#baizeShell .cell[disabled] { opacity: .55; }
#baizeShell .cell.danger { color: #C0392B; justify-content: center; font-weight: 500; }
#baizeShell .cell.danger .c-ico { background: rgba(192, 57, 43, .1); color: #C0392B; }

/* ============================================================================
   六、白泽晓（AI 页）
   ============================================================================ */

#baizeShell .ai-page {
  display: flex; flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#baizeShell .ai-log {
  flex: 1 1 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px var(--page-pad) 20px;
  display: flex; flex-direction: column; gap: 12px;
}
#baizeShell .msg {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px; line-height: 1.62;
  white-space: pre-wrap; word-break: break-word;
}
#baizeShell .msg.is-ai {
  align-self: flex-start;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-bottom-left-radius: 6px;
  color: var(--c-text);
  box-shadow: var(--c-shadow);
}
#baizeShell .msg.is-user {
  align-self: flex-end;
  background: var(--c-primary);
  color: #fff;
  border-bottom-right-radius: 6px;
}
#baizeShell .msg strong { font-weight: 600; color: var(--c-text); }
#baizeShell .msg.is-user strong { color: #fff; }
#baizeShell .msg code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .92em;
  padding: 1px 5px; border-radius: 6px;
  background: var(--c-surface-3); color: var(--c-text);
}
#baizeShell .msg.is-user code { background: rgba(255, 255, 255, .2); color: #fff; }
#baizeShell .msg.is-err {
  align-self: center; max-width: 100%;
  background: rgba(192, 57, 43, .08); color: #C0392B;
  font-size: 12.5px; border-radius: 12px;
}
#baizeShell .msg .typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
#baizeShell .msg .typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-muted); opacity: .5;
  animation: bzBlink 1.1s infinite ease-in-out;
}
#baizeShell .msg .typing i:nth-child(2) { animation-delay: .16s; }
#baizeShell .msg .typing i:nth-child(3) { animation-delay: .32s; }
@keyframes bzBlink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

#baizeShell .ai-welcome { display: flex; flex-direction: column; gap: 14px; }
#baizeShell .ai-welcome .w-hello {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; border-radius: 18px;
  background: var(--c-surface); border: 1px solid var(--c-line);
  box-shadow: var(--c-shadow);
}
#baizeShell .ai-welcome .w-pet {
  flex: none; width: 44px; height: 44px; border-radius: 14px;
  background: var(--c-primary-soft); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#baizeShell .ai-welcome .w-pet img { width: 100%; height: 100%; object-fit: contain; }
#baizeShell .ai-welcome .w-t { display: block; font-size: 14.5px; font-weight: 600; }
#baizeShell .ai-welcome .w-d { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.65; color: var(--c-muted); }
#baizeShell .chips { display: flex; flex-wrap: wrap; gap: 8px; }
#baizeShell .chip {
  appearance: none; cursor: pointer; font: inherit;
  padding: 9px 13px; border-radius: 999px;
  border: 1px solid var(--c-line); background: var(--c-surface);
  color: var(--c-text); font-size: 12.5px; line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .chip:active { background: var(--c-primary-soft); border-color: var(--c-primary-ring); }

#baizeShell .ai-composer {
  flex: none;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px var(--page-pad) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--c-surface);
  border-top: 1px solid var(--c-line);
}
#baizeShell .ai-composer input {
  flex: 1 1 auto; min-width: 0;
  height: 44px; padding: 0 14px;
  border: 1px solid var(--c-line); border-radius: 14px;
  background: var(--c-surface-2); color: var(--c-text);
  /* 16px 是硬底线：低于 16px 时 iOS/WebView 聚焦会整页放大且不自动缩回 */
  font: inherit; font-size: 16px;
  outline: none;
}
#baizeShell .ai-composer input:focus { border-color: var(--c-primary-ring); background: var(--c-surface); }
#baizeShell .ai-composer .send {
  flex: none; width: 44px; height: 44px; border-radius: 14px;
  border: 0; background: var(--c-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .16s ease, transform .12s ease;
}
#baizeShell .ai-composer .send svg { width: 20px; height: 20px; }
#baizeShell .ai-composer .send:active { transform: scale(.94); }
#baizeShell .ai-composer .send[disabled] { opacity: .45; }
/* 回答中按钮即「停止」：形状由方形图标表达，颜色降为中性格，避免与发送同色误读 */
#baizeShell .ai-composer .send.is-stop {
  background: var(--c-surface-3); color: var(--c-text);
  border: 1px solid var(--c-line);
}
#baizeShell .ai-composer .send.is-stop:active { transform: scale(.94); }

/* 停止后的一行说明（不是错误，不用红色） */
#baizeShell .msg.is-note {
  align-self: center; max-width: 100%;
  background: var(--c-surface-2); color: var(--c-muted);
  font-size: 12.5px; border-radius: 12px;
  display: flex; align-items: center; gap: 8px;
}
#baizeShell .msg .note-op {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--c-primary);
  padding: 2px 4px; border-radius: 6px;
  text-decoration: underline; text-underline-offset: 2px;
}
/* 失败行是居中文本，按钮跟在同一行末，不与正文重叠 */
#baizeShell .msg.is-err .note-op { margin-left: 6px; }
/* 每条回答下方的一排动作（复制 / 重试）：默认低调，点过才给反馈 */
#baizeShell .msg-ops {
  display: flex; gap: 4px; margin-top: 6px;
  opacity: .66;
}
#baizeShell .msg-ops:active { opacity: 1; }
#baizeShell .msg-op {
  appearance: none; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 28px; padding: 2px 8px;
  border: 0; border-radius: 8px;
  background: none; color: var(--c-muted);
  font-size: 12px; line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .msg-op svg { width: 14px; height: 14px; }
#baizeShell .msg-op:active { background: var(--c-surface-3); color: var(--c-text); }
#baizeShell .msg-op.is-done { color: var(--c-primary); opacity: 1; }

/* ============================================================================
   七、弹层（底栏编辑器 / 重命名等仍用底部弹层）
   ============================================================================ */

#baizeShell .shell-sheet {
  position: fixed; left: 0; right: 0; top: 0;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  background: rgba(10, 16, 24, .42);
  display: flex; align-items: flex-end;
  animation: bzFade .18s ease;
}
@keyframes bzFade { from { opacity: 0; } to { opacity: 1; } }
#baizeShell .sheet-card {
  position: relative;
  width: 100%;
  background: var(--c-surface);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 78vh; overflow-y: auto;
  animation: bzUp .22s cubic-bezier(.2, .8, .3, 1);
  box-shadow: var(--c-shadow-up);
}
/* 2026-10-29：底栏编辑器补可见的关闭按钮（此前只能点遮罩或「完成」）
   2026-10-31：热区 32→44，用负 margin 抵回，卡头高度不涨。 */
#baizeShell .sheet-x {
  position: absolute; top: 4px; right: 6px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--c-surface-2);
  color: var(--c-muted);
  font-family: inherit; font-size: 20px; line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .sheet-x:active { transform: scale(.92); }
@keyframes bzUp { from { transform: translateY(14px); } to { transform: translateY(0); } }
#baizeShell .sheet-grab {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--c-line-2); margin: -4px auto 12px;
}
#baizeShell .sheet-title {
  font-size: 15px; font-weight: 600; color: var(--c-text);
  margin: 0 0 4px;
  padding-right: 44px; /* 让出右上关闭按钮的热区，长标题不压字 */
}
#baizeShell .sheet-desc {
  font-size: 12px; line-height: 1.6; color: var(--c-muted);
  margin: 0 0 14px;
}
#baizeShell .sheet-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 4px;
}
#baizeShell .sheet-item {
  --tile-soft: color-mix(in srgb, var(--tile) 12%, var(--c-surface));
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px 2px; border-radius: 14px; font: inherit; font-size: 11px;
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .sheet-item .tile {
  width: 50px; height: 50px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--tile);
  background: var(--c-surface-2);
  background: var(--tile-soft);
  position: relative;
}
#baizeShell .sheet-item .tile svg { width: 24px; height: 24px; }
#baizeShell .sheet-item:active { background: var(--c-surface-2); }
#baizeShell .sheet-item.pinned .tile {
  box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-primary);
}
#baizeShell .sheet-item.pinned span { color: var(--c-primary); font-weight: 600; }
#baizeShell .sheet-item .badge {
  position: absolute; right: -3px; bottom: -3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--c-surface);
}
#baizeShell .sheet-item .badge svg { width: 11px; height: 11px; }
#baizeShell .sheet-item.pinned .badge { display: flex; }

#baizeShell .sheet-ops { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
#baizeShell .sheet-op {
  appearance: none; border: 1px solid var(--c-line); background: var(--c-surface);
  cursor: pointer; text-align: center; padding: 13px 12px;
  font: inherit; font-size: 14px; color: var(--c-text);
  border-radius: 13px;
  -webkit-tap-highlight-color: transparent;
}
#baizeShell .sheet-op.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 500; }
#baizeShell .sheet-op.ghost { border-color: transparent; color: var(--c-muted); }
#baizeShell .sheet-op:active { background: var(--c-surface-2); }
#baizeShell .sheet-op.danger { color: #C0392B; border-color: rgba(192, 57, 43, .3); }

/* 旧口径兼容（其他位置仍在用的类名） */
#baizeShell .sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 2px 12px; }
#baizeShell .sheet-user img { width: 44px; height: 44px; border-radius: 13px; }
#baizeShell .sheet-user .u-name { font-weight: 600; font-size: 15px; }
#baizeShell .sheet-user .u-role { font-size: 11.5px; color: var(--c-muted); }

/* ============================================================================
   八、手机端登录门（桌面保持「品牌分栏」，手机改为紧凑品牌头 + 表单）
   ============================================================================ */

@media (max-width: 680px) {
  /* 手机上「未登录」时顶栏没有存在意义（唯一的主题按钮在登录后也能从「我的」改），
     且它是 sticky 的，会把登录页顶部压住半截 logo。登录门全屏化，顶栏让位。 */
  body:has(#gate:not([hidden])) .topbar { display: none; }
  body:not(.baize-app) .gate { padding: 0; align-items: stretch; }
  .gate-shell {
    display: block !important;
    max-height: none; height: 100%;
    background: var(--c-surface);
    border-radius: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow-y: auto;
  }
  .gate-brand {
    display: block !important;
    padding: calc(28px + env(safe-area-inset-top, 0px)) 24px 20px !important;
    background: var(--c-grad-hero), var(--c-surface) !important;
    border: 0 !important;
  }
  .gate-brand .gate-mark { width: 52px !important; height: 52px !important; }
  .gate-brand .gate-brand-name { font-size: 19px !important; margin-top: 12px !important; }
  .gate-brand .gate-brand-en { font-size: 10px !important; letter-spacing: .16em; }
  .gate-brand .gate-brand-desc { font-size: 12.5px !important; line-height: 1.6; margin: 8px 0 0 !important; }
  .gate-brand .gate-points { display: none !important; }
  .gate-box {
    padding: 22px 24px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
    border: 0 !important; background: transparent !important;
  }
  .gate-box h1 { font-size: 20px !important; }
  .gate-box .gate-sub { font-size: 12.5px !important; margin-bottom: 18px !important; }
  .gate-box .bz-field { margin-bottom: 14px; }
  .gate-box input { height: 46px; font-size: 15px; }
  .gate-box .bz-btn.primary { height: 48px; font-size: 15px; letter-spacing: .08em; }
  .gate-foot { font-size: 11.5px !important; margin-top: 16px !important; }
  .gate-icp { font-size: 11px !important; }
}

/* ============================================================================
   九、暗色适配补充（令牌已覆盖主色，这里只处理两处写死的白/黑）
   ============================================================================ */

/* 暗档：--c-primary 变浅蓝，白字压在上面只有 2:1 左右（不可读）。
   AI 卡在暗色下改成「深底 + 浅字 + 主色描边」，保住品牌感又不牺牲对比度。 */
html.dark #baizeShell .ai-card {
  background: linear-gradient(135deg, #16233A 0%, #101A2C 100%);
  color: var(--c-text);
  border: 1px solid rgba(127, 166, 255, .28);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
html.dark #baizeShell .ai-card .ai-ico {
  background: rgba(127, 166, 255, .16);
  color: var(--c-primary);
}
html.dark #baizeShell .ai-card::after { background: rgba(127, 166, 255, .07); }
html.dark #baizeShell .ai-card .ai-d { opacity: .72; }
html.dark #baizeShell .shell-sheet { background: rgba(0, 0, 0, .58); }
html.dark #baizeShell .cell.danger { color: #FF8A80; }
html.dark #baizeShell .cell.danger .c-ico { background: rgba(255, 138, 128, .12); color: #FF8A80; }
html.dark #baizeShell .msg strong { font-weight: 600; color: var(--c-text); }
#baizeShell .msg.is-user strong { color: #fff; }
#baizeShell .msg code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .92em;
  padding: 1px 5px; border-radius: 6px;
  background: var(--c-surface-3); color: var(--c-text);
}
#baizeShell .msg.is-user code { background: rgba(255, 255, 255, .2); color: #fff; }
#baizeShell .msg.is-err { background: rgba(255, 138, 128, .1); color: #FF8A80; }

/* 首页兜底提示（既无 AI 卡也无最近访问时的空白填充） */
#baizeShell .home-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: var(--c-surface-2);
  color: var(--c-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
#baizeShell .home-hint svg { width: 18px; height: 18px; flex: none; opacity: 0.7; }

/* ----------------------------------------------------------------------------
   待发送记录（离线写队列的可视化）
   ----------------------------------------------------------------------------
   首页顶部一条计数条 + 「我的」一行入口 + 共用同一个弹层。队列本体在
   app-write.js（浏览器侧 localStorage），这里只管呈现。
   只在真有积压时出现：正常状态不该被做成一个待处理的待办。
---------------------------------------------------------------------------- */

#baizeShell .queue-strip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--c-line-2);
  background: var(--c-surface-2);
  color: var(--c-text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}
#baizeShell .queue-strip:active { background: var(--c-surface-3); }
#baizeShell .queue-strip .qs-ico {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--c-primary-soft);
  color: var(--c-primary);
}
#baizeShell .queue-strip .qs-ico svg { width: 17px; height: 17px; }
#baizeShell .queue-strip .qi-t {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}
#baizeShell .queue-strip .qs-go {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12.5px;
  color: var(--c-muted);
}
#baizeShell .queue-strip .qs-go svg { width: 15px; height: 15px; }

/* 计数条常驻 DOM（值为 0 时 hidden），故「全部模块」这一节不再是首个子元素；
   补回首页原有的 4px 起始间距。 */
#baizeShell #homeQueueSec[hidden] + .sec { margin-top: 4px; }

#baizeShell .queue-list { display: flex; flex-direction: column; gap: 10px; }
#baizeShell .queue-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-line-2);
}
#baizeShell .queue-item .qi-main { flex: 1; min-width: 0; }
#baizeShell .queue-item .qi-t {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--c-text);
  word-break: break-word;
}
#baizeShell .queue-item .qi-d {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--c-muted);
  word-break: break-word;
}
#baizeShell .queue-item .qi-ops {
  flex: none;
  display: flex;
  gap: 6px;
}
#baizeShell .queue-item .qi-op {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
#baizeShell .queue-item .qi-op:active { background: var(--c-surface-3); }
#baizeShell .queue-item .qi-op[disabled] { opacity: .5; }
#baizeShell .queue-item .qi-op.danger { color: #C0392B; border-color: rgba(192, 57, 43, .35); }
html.dark #baizeShell .queue-item .qi-op.danger { color: #FF8A80; border-color: rgba(255, 138, 128, .35); }

#baizeShell .queue-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 14px;
  color: var(--c-muted);
  font-size: 13px;
  text-align: center;
}
#baizeShell .queue-empty svg { width: 22px; height: 22px; opacity: .55; color: var(--c-primary); }
#baizeShell .queue-empty p { margin: 0; }
