/* 配色：默认跟随系统 prefers-color-scheme；“⋯”菜单的“外观”通过 html[data-theme="light|dark"] 覆盖（存 localStorage）。
   暗色沿用 cmux 当前的 Dracula 终端主题；浅色为白底深字。终端画面（.term-box 内）始终使用 cmux 终端主题色，不随界面主题变化。 */
:root {
  --bg: #FFFFFF;
  --panel: #F5F6FA;
  --raise: #FFFFFF;
  --card: #F6F7FB;
  --line: #E4E6EE;
  --text: #1F2330;
  --muted: #5C6275;
  --accent: #6A46D6;
  --accent-ink: #FFFFFF;
  --accent-soft: #EFEAFB;
  /* 主题色令牌（对比度用 node scripts/accent-contrast.mjs 自查）：偏好“主题色”选 blue / teal / orange / rose 时由下面的 :root[data-accent] 规则取用（accent-ink 沿用各明暗的默认值）；色块也用它显示当前明暗下的颜色 */
  --sw-purple: #6A46D6; --sw-blue: #1F5FD6; --sw-teal: #0B6E65; --sw-orange: #A2470B; --sw-rose: #B8285F;
  --sw-blue-soft: #E8F0FD; --sw-teal-soft: #E3F3F1; --sw-orange-soft: #FBEDE3; --sw-rose-soft: #FBE7EF;
  --danger: #D63A3A;
  --working: #1E9E55;
  --waiting: #A07800;
  --idle: #7A4FD6;
  --background: #62C08F;
  --background-text: #2F8F5E;
  --term: #6B7390;
  --press: #E4E6EE;
  --bubble: #ECE7FA;
  --code-bg: #F1F2F7;
  --cap: #FFFFFF;
  --cap-edge: #C7CBDA;
  --placeholder: #7C8296;
  --mask: rgba(20, 22, 35, 0.42);
  --shadow: 0 8px 24px rgba(30, 35, 60, 0.16);
  --ui: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --bar-h: 52px;
  --chat-fs: 16px;
  /* 终端画面的兜底底色与前景（真正的颜色来自 cmux 的 replay，由终端渲染器通过 CSSOM 设置） */
  --term-bg: #282A36;
  --term-fg: #F8F8F2;
  /* 流量图的两个系列色：下行（紫）、上行（青），与状态色分开，不挪作它用；两套主题分别用 dataviz 的 validate_palette 按各自的表面色校验：
     浅色（#6A46D6 / #0B8AA8，表面 #FFFFFF）全部通过，相邻 CVD 色差 12.0（tritan）、常规视觉色差 20.6；
     暗色（#8D68E0 / #2AA3B8，表面 #282A36）全部通过，相邻 CVD 色差 11.5、常规视觉色差 19.9 */
  --viz-down: #6A46D6;
  --viz-up: #0B8AA8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #282A36;
    --panel: #21222C;
    --raise: #2E3040;
    --card: #2E3040;
    --line: #343746;
    --text: #F8F8F2;
    --muted: #9AA0B8;
    --accent: #BD93F9;
    --accent-ink: #282A36;
    --accent-soft: rgba(189, 147, 249, 0.12);
    --sw-purple: #BD93F9; --sw-blue: #8BB4FF; --sw-teal: #5FD4C4; --sw-orange: #FFB86C; --sw-rose: #FF79C6;
    --sw-blue-soft: rgba(139, 180, 255, 0.12); --sw-teal-soft: rgba(95, 212, 196, 0.12); --sw-orange-soft: rgba(255, 184, 108, 0.12); --sw-rose-soft: rgba(255, 121, 198, 0.12);
    --danger: #FF5555;
    --working: #50FA7B;
    --waiting: #F1FA8C;
    --idle: #BD93F9;
    --background: #86C79B;
    --background-text: #86C79B;
    --term: #6272A4;
    --press: #404459;
    --bubble: #3B3E54;
    --code-bg: #1E1F29;
    --cap: #343746;
    --cap-edge: #181920;
    --placeholder: #7a809a;
    --mask: rgba(0, 0, 0, 0.6);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --viz-down: #8D68E0;
    --viz-up: #2AA3B8;
  }
}
:root[data-theme="dark"] {
  --bg: #282A36;
  --panel: #21222C;
  --raise: #2E3040;
  --card: #2E3040;
  --line: #343746;
  --text: #F8F8F2;
  --muted: #9AA0B8;
  --accent: #BD93F9;
  --accent-ink: #282A36;
  --accent-soft: rgba(189, 147, 249, 0.12);
  --sw-purple: #BD93F9; --sw-blue: #8BB4FF; --sw-teal: #5FD4C4; --sw-orange: #FFB86C; --sw-rose: #FF79C6;
  --sw-blue-soft: rgba(139, 180, 255, 0.12); --sw-teal-soft: rgba(95, 212, 196, 0.12); --sw-orange-soft: rgba(255, 184, 108, 0.12); --sw-rose-soft: rgba(255, 121, 198, 0.12);
  --danger: #FF5555;
  --working: #50FA7B;
  --waiting: #F1FA8C;
  --idle: #BD93F9;
  --background: #86C79B;
  --background-text: #86C79B;
  --term: #6272A4;
  --press: #404459;
  --bubble: #3B3E54;
  --code-bg: #1E1F29;
  --cap: #343746;
  --cap-edge: #181920;
  --placeholder: #7a809a;
  --mask: rgba(0, 0, 0, 0.6);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --viz-down: #8D68E0;
  --viz-up: #2AA3B8;
}
/* 主题色覆盖：紧跟在三处基础定义之后；:root[data-accent] 与 :root[data-theme="dark"] 同级且写在其后，所以不会被基础的 --accent 盖掉；
   令牌在各明暗块里已按明暗取值（指定浅色时 :not([data-theme="light"]) 不生效，系统暗色下也用浅色令牌）；purple 为默认，不设 data-accent */
:root[data-accent="blue"] { --accent: var(--sw-blue); --accent-soft: var(--sw-blue-soft); --bubble: var(--sw-blue-soft); }
:root[data-accent="teal"] { --accent: var(--sw-teal); --accent-soft: var(--sw-teal-soft); --bubble: var(--sw-teal-soft); }
:root[data-accent="orange"] { --accent: var(--sw-orange); --accent-soft: var(--sw-orange-soft); --bubble: var(--sw-orange-soft); }
:root[data-accent="rose"] { --accent: var(--sw-rose); --accent-soft: var(--sw-rose-soft); --bubble: var(--sw-rose-soft); }
html[data-font="s"] { --chat-fs: 14px; }
html[data-font="l"] { --chat-fs: 18px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--ui); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body.no-scroll { overflow: hidden; }
#app { min-height: 100%; display: flex; flex-direction: column; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; touch-action: manipulation; background: none; border: 0; padding: 0; }
button:disabled { opacity: 0.5; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- 通用按钮 ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; background: var(--line); color: var(--text); font-weight: 500; }
.btn:active { background: var(--press); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { filter: brightness(0.92); }
.btn.danger { background: var(--danger); color: var(--accent-ink); }
.btn.danger:active { filter: brightness(0.92); }
.btn.block { width: 100%; }
.btn.text { background: none; color: var(--muted); padding: 0 10px; min-height: 40px; }
.btn.text:active { color: var(--text); background: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center;
  justify-content: center; color: var(--text); flex: none; }
.icon-btn:active { background: var(--press); }

/* ---------- 顶栏与页面栏宽 ---------- */
.bar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex: none; }
.bar-in { max-width: 760px; margin: 0 auto; height: var(--bar-h); display: flex; align-items: center; gap: 4px;
  padding: 0 8px 0 14px; position: relative; }
.bar-in.has-back { padding-left: 6px; }
.bar-in.has-nav { padding-left: 8px; }
.bar-spacer { flex: 1; min-width: 0; }
.nav-switch { flex: none; }
.nav-switch .seg-opt { padding: 0 12px; font-weight: 600; } /* 两段恒为粗体：高亮切换时宽度不变，两页控件尺寸一致 */
@media (max-width: 400px) { .nav-switch .seg-opt { padding: 0 8px; } }
.bar-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col { width: 100%; max-width: 760px; margin: 0 auto; flex: 1; }

/* ---------- 弹出菜单 ---------- */
/* 透明遮罩：盖住整页吞掉菜单外的点击，只关闭菜单，不穿透到下面的键帽或按钮；菜单在遮罩之上 */
.menu-mask { position: fixed; inset: 0; z-index: 19; background: transparent; }
.menu { position: absolute; right: 8px; top: calc(var(--bar-h) - 6px); min-width: 220px; max-width: calc(100vw - 16px);
  background: var(--raise); border: 1px solid var(--line); border-radius: 12px; padding: 6px; z-index: 20;
  box-shadow: var(--shadow); }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 44px;
  padding: 0 12px; border-radius: 8px; text-align: left; }
.menu-item:active, .menu-item:hover { background: var(--line); }
.menu-note { margin: 4px 12px 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: var(--line); position: relative; flex: none; transition: background 120ms; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: transform 120ms, background 120ms; }
.switch[aria-checked="true"] .track { background: var(--accent); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); background: var(--accent-ink); }

/* ---------- 登录 ---------- */
.login { width: 100%; max-width: 360px; margin: 16vh auto 0; padding: 24px 20px 20px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.login-logo { width: 64px; height: 64px; border-radius: 22%; align-self: center; object-fit: cover; }
.login h1 { font-size: 20px; margin: 0; text-align: center; }
.login p { margin: -8px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.field { width: 100%; min-height: 44px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
.field::placeholder, textarea::placeholder { color: var(--placeholder); }
.field:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.err { color: var(--danger); font-size: 13px; margin-top: -6px; }
.err:empty { display: none; }

/* ---------- 列表页 ---------- */
.filters { display: flex; gap: 6px; padding: 12px 14px 4px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); }
.chip .n { margin-left: 6px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.group-title { padding: 18px 14px 6px; font-size: 13px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px 8px 11px; position: relative; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--panel); }
.row.selected { background: var(--accent-soft); }
.row.selected .name { font-weight: 600; }
.row .bar3 { align-self: stretch; width: 3px; border-radius: 2px; background: var(--st, var(--term)); flex: none; margin: 2px 0; }
.row .main { flex: 1; min-width: 0; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .st { flex: none; font-size: 13px; color: var(--st-text, var(--muted)); }
.row .st-col { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row .ago { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.recent-sec { border-bottom: 1px solid var(--line); }
.s-working { --st: var(--working); --st-text: var(--working); }
.s-waiting { --st: var(--waiting); --st-text: var(--waiting); }
.s-idle { --st: var(--idle); --st-text: var(--idle); }
.s-background { --st: var(--background); --st-text: var(--background-text); }
.s-hibernated { --st: var(--term); --st-text: var(--muted); }
.s-unknown { --st: var(--term); --st-text: var(--muted); }
.s-terminal { --st: var(--term); --st-text: var(--muted); }
.row.s-working .bar3 { animation: breathe 2.4s ease-in-out infinite; }
.row.s-hibernated .bar3 { opacity: 0.45; }
/* 后台运行：工作中颜色的浅色版，徽章前带一个小圆点 */
.row.s-background .st::before, .st-pill.s-background::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.empty { text-align: center; color: var(--muted); padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .lead { color: var(--text); font-size: 16px; }
.empty .btn.primary { min-width: 160px; }

/* ---------- 终端页 ---------- */
.term-page { position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100dvh; max-width: 1100px; margin: 0 auto;
  display: flex; flex-direction: column; background: var(--bg); }
.term-bar { display: flex; align-items: center; gap: 2px; height: var(--bar-h); padding: 0 8px 0 6px; flex: none;
  background: var(--panel); border-bottom: 1px solid var(--line); position: relative; }
.tb-main { flex: 1; min-width: 0; padding: 0 6px; }
.tb-title { display: flex; align-items: center; gap: 8px; font-weight: 600; line-height: 1.3; }
/* 状态小胶囊：状态色文字加同色淡底（不支持 color-mix 的浏览器退回面板底色） */
.st-pill { flex: none; font-size: 11px; font-weight: 500; line-height: 1; padding: 4px 8px; border-radius: 999px; color: var(--st-text, var(--muted));
  background: var(--panel); background: color-mix(in srgb, var(--st, var(--term)) 16%, transparent); }
.tb-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tb-sub { font-size: 12px; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-box { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; background: var(--term-bg); color: var(--term-fg); -webkit-overflow-scrolling: touch; }
.term-box.scroll-x { overflow-x: auto; }
.term { font-family: var(--mono); white-space: pre; margin-left: 8px; }
.term-probe { position: absolute; visibility: hidden; white-space: pre; font-family: var(--mono); }
.ln { white-space: pre; overflow: hidden; }
.sp { display: inline-block; white-space: pre; overflow: hidden; vertical-align: top; }
.sp.cursor { outline: 1px solid #fff; background: rgba(255, 255, 255, 0.55); color: #000; }

.dock { flex: none; position: relative; background: var(--bg); padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
.term-page.kb .dock { padding-bottom: 10px; }
.tip-bar { position: absolute; right: 10px; bottom: calc(100% + 8px); max-width: calc(100% - 20px); display: none; align-items: center;
  gap: 2px; padding: 2px 4px 2px 10px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line); }
.tip-bar.on { display: flex; }
.tip-bar.err { border-color: var(--danger); }
.tip { color: var(--muted); font-size: 13px; line-height: 1.4; padding: 3px 0; overflow-wrap: anywhere; }
.tip.bad { color: var(--danger); }
.tip-x { display: none; flex: none; min-width: 44px; min-height: 32px; padding: 0 8px; border-radius: 12px; color: var(--muted); font-size: 13px; }
.tip-bar.err .tip-x { display: inline-flex; align-items: center; justify-content: center; }
.tip-x:active { background: var(--line); color: var(--text); }
.safety-bar { display: flex; align-items: center; gap: 4px; max-width: 820px; margin: 0 auto 8px; padding: 0 4px 0 10px; border-radius: 8px;
  background: var(--raise); color: var(--muted); font-size: 12px; line-height: 1.4; }
.safety-bar span { flex: 1; min-width: 0; padding: 5px 0; }
.safety-x { flex: none; min-width: 44px; min-height: 32px; padding: 0 8px; border-radius: 8px; color: var(--muted); font-size: 12px; }
.safety-bar.switch-only { background: none; padding: 0 4px; }
.safety-bar[hidden] { display: none; }
.safety-x:active { background: var(--line); color: var(--text); }
/* 行内文字链接（“看终端”）：与文字同行，链接色，可点区域高度不小于 32px */
.inline-link { display: inline-flex; align-items: center; vertical-align: middle; min-height: 32px; padding: 0 6px; margin: 0 2px; border-radius: 8px; background: none; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.inline-link[hidden] { display: none; }
.inline-link:active { background: var(--line); }

/* 输入区卡片：textarea 占满整宽（默认 2 行，脚本自动增高到最多 6 行），底部一行操作：(+) 提示 [发送] */
.composer { max-width: 820px; margin: 0 auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.composer textarea { display: block; width: 100%; min-height: 64px; max-height: 160px; resize: none; border: 0; outline: none; background: transparent;
  padding: 12px 14px 4px; font-size: 16px; line-height: 24px; overflow-y: hidden; border-radius: 14px 14px 0 0; }
.composer-bar { display: flex; align-items: center; gap: 10px; padding: 4px 10px 10px; }
.composer-hint { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.hint-mobile { display: none; }
@media (max-width: 600px) {
  .hint-desktop { display: none; }
  .hint-mobile { display: inline; }
}
.queue-hint { flex: none; font-size: 12px; color: var(--waiting); white-space: nowrap; }
.queue-hint:empty { display: none; }
.send-btn { flex: none; display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 14px 0 18px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 600; }
.send-btn:active { filter: brightness(0.92); }
.send-btn svg { stroke-width: 2.2; }

/* ---------- 加号浮层 ---------- */
.plus-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; }
.plus-btn:active { background: var(--press); }
.plus-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.plus-btn svg { flex: none; }
.plus-mask { position: fixed; inset: 0; z-index: 45; background: transparent; }
.plus-pop { position: absolute; min-width: 168px; padding: 6px; background: var(--raise); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.plus-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 14px 0 12px; border-radius: 8px; text-align: left; font-size: 15px; color: var(--text); }
.plus-item:active, .plus-item:hover { background: var(--line); }
.plus-item svg { flex: none; color: var(--accent); }

/* ---------- 底部弹层 ---------- */
.sheet-mask { position: fixed; inset: 0; z-index: 50; background: transparent; display: flex; align-items: flex-end;
  justify-content: center; transition: background 180ms ease-out; }
.sheet-mask.open { background: var(--mask); }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 180ms ease-out; }
.sheet-mask.open .sheet { transform: none; }
.grip { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; flex: none; }
.sheet:focus { outline: none; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; flex: none; }
.sheet-body { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.sheet-btns { display: flex; gap: 10px; margin-top: 16px; flex: none; }
.sheet-btns .btn { flex: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.codeblock { margin: 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 30vh; overflow-y: auto; }
.note { margin: 12px 0 0; color: var(--waiting); font-size: 13px; }
.sheet-safety { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 12px; flex: none; }
.preset-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 56px; padding: 8px 4px; text-align: left; }
.preset-item + .preset-item { border-top: 1px solid var(--line); }
.preset-item:active { background: var(--bg); }
.preset-item .pv { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.opt { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 56px; padding: 8px 12px; text-align: left; border-radius: 10px; border: 1px solid transparent; }
.opt + .opt { margin-top: 4px; }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt .pv { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }

/* ---------- 操作记录 ---------- */
.audit-list { padding-bottom: 24px; }
.au { padding: 12px 14px; }
.au + .au { border-top: 1px solid var(--line); }
.au .l1 { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.au .tm, .au .ac { white-space: nowrap; }
.au .tm { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.au .ac { font-weight: 500; }
.au .rs { margin-left: auto; font-size: 13px; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.au .l2 { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au .l3 { margin-top: 4px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.au .l3.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.au .more { min-height: 32px; padding: 0; color: var(--accent); font-size: 13px; }
.r-ok { color: var(--working); }
.r-rejected { color: var(--danger); }
.r-unknown { color: var(--waiting); }
.table-wrap { overflow-x: auto; padding: 0 14px 24px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td.content { max-width: 320px; word-break: break-all; white-space: pre-wrap; font-family: var(--mono); }
td.nowrap { white-space: nowrap; }
@media (min-width: 900px) {
  .bar-in.wide { max-width: 1100px; }
  .col.wide { max-width: 1100px; }
}
.page-loading { padding: 40px 14px; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .row.s-working .bar3 { animation: none; }
  .sheet, .sheet-mask, .switch .track, .switch .track::after { transition: none; }
}

/* ---------- 流量统计 ---------- */
.traffic { padding-bottom: 32px; }
.tbody { transition: opacity 120ms; }
.tbody.loading { opacity: 0.5; }
.tlegendrow { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 0; }
.tlegend, .td-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.tkey { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tsw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.tsw.down { background: var(--viz-down); }
.tsw.up { background: var(--viz-up); }
.tchart { display: flex; margin: 4px 14px 0; outline-offset: 2px; }
.tchart-y { flex: none; }
.tchart-scroll { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.tchart-scroll::-webkit-scrollbar { display: none; }
.tchart svg { display: block; }
.tplot .grid { stroke: var(--line); stroke-width: 1; }
.tplot .axis { stroke: var(--muted); stroke-width: 1; }
.tchart .tick { fill: var(--muted); font-size: 11px; font-family: var(--ui); }
.tplot .bar.down { fill: var(--viz-down); }
.tplot .bar.up { fill: var(--viz-up); }
.tplot .tsel { fill: var(--raise); opacity: 0; }
.tplot .tsel.on { opacity: 1; }
.tplot .thit { fill: transparent; cursor: pointer; }
.tdetail { margin: 8px 14px 0; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; min-height: 40px; }
.td-title { font-weight: 600; margin-bottom: 4px; }
.td-total { margin-left: auto; color: var(--text); font-weight: 500; }
.td-cats { margin-top: 4px; color: var(--muted); font-size: 12px; }
.ttotals { padding: 16px 14px 0; }
.ttiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ttile { padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.tval { margin-top: 4px; font-size: 26px; font-weight: 600; line-height: 1.2; }
.tpeak { margin-top: 8px; font-size: 13px; }
.trank { padding: 20px 14px 0; }
.trank h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.trow { padding: 8px 0; }
.trow + .trow { border-top: 1px solid var(--line); }
.tr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tr-val { flex: none; font-variant-numeric: tabular-nums; font-size: 14px; }
.tbar { height: 8px; margin: 6px 0 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.tfill { display: block; height: 100%; border-radius: 4px; background: var(--term); }
.tr-sub { font-size: 12px; }
.ttable-wrap { margin: 8px 14px 0; max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.ttable th, .ttable td { padding: 6px 10px; }
.ttable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ttable th { position: sticky; top: 0; background: var(--panel); }
@media (prefers-reduced-motion: reduce) {
  .tbody { transition: none; }
}

/* 发送队列提示：有待发项时显示一行小字；结果未知暂停时显示说明与两个按钮 */
.queue-bar { display: none; align-items: center; gap: 4px; max-width: 820px; margin: 0 auto 8px; padding: 0 4px 0 10px; border-radius: 8px;
  background: var(--raise); color: var(--muted); font-size: 12px; line-height: 1.4; }
.queue-bar.on { display: flex; }
.queue-bar.paused { display: flex; flex-wrap: wrap; color: var(--waiting); border: 1px solid var(--waiting); padding-top: 2px; padding-bottom: 2px; }
.queue-text { flex: 1 1 100%; min-width: 0; padding: 5px 0 2px; }
.queue-bar.on .queue-text { flex: 1; padding: 5px 0; }
.queue-btn { display: none; flex: none; min-height: 36px; padding: 0 12px; border-radius: 8px; color: var(--text); font-size: 13px; background: var(--line); }
.queue-bar.paused .queue-btn { display: inline-flex; align-items: center; margin: 0 6px 4px 0; }

/* 发送队列暂停条里的危险操作（仍然发送）与只读输入框提示 */
.queue-btn.danger { color: var(--danger); }
/* 休眠提示条：位于输入卡片上方，说明会话已休眠并给出唤醒 / 恢复会话两个按钮 */
.wake-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 820px; margin: 0 auto 8px; padding: 6px 6px 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 13px; }
.wake-bar[hidden] { display: none; }
.wake-bar .wake-text { flex: 1; min-width: 6em; }
.wake-act { flex: none; min-height: 40px; padding: 0 14px; border-radius: 8px; font-size: 14px; background: var(--line); color: var(--text); }
.wake-act.wake-btn { background: var(--accent); color: var(--accent-ink); }
.composer textarea.locked { opacity: 0.6; cursor: progress; }

/* 失败的文字保持锁定时的提示 */
.lock-hint { max-width: 820px; margin: 0 auto 8px; padding: 5px 10px; border-radius: 8px; background: var(--raise); color: var(--waiting); font-size: 12px; line-height: 1.4; }

/* ---------- 会话页：对话视图 ---------- */
.back-chat { display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 0 12px 0 4px; border-radius: 10px; flex: none; font-size: 15px; }
.back-chat:active { background: var(--press); }
.chat-host { flex: 1; min-height: 0; display: flex; }
.chat-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.chat-box { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: var(--bg); }
.chat-box:focus { outline: none; }
.chat-inner { max-width: 760px; margin: 0 auto; padding: 18px 16px 26px; }
.older-btn { display: block; margin: 0 auto 10px; min-height: 36px; padding: 0 14px; border-radius: 18px; color: var(--muted); font-size: 13px; }
.older-btn:active { background: var(--press); }
.chat-empty { text-align: center; color: var(--muted); padding: 18vh 16px 24px; }
.chat-empty .lead { color: var(--text); font-size: 16px; }
.chat-empty .hint { margin: 8px auto 0; max-width: 22em; font-size: 14px; line-height: 1.6; }
.chat-empty.err .lead { color: var(--danger); }

.msg { min-width: 0; }
.msg + .msg { margin-top: 26px; }
.msg.cmd { text-align: center; margin-top: 18px; margin-bottom: 18px; color: var(--muted); font-size: 13px; }
/* 每条消息上方的小标签：“你”右对齐，“Claude”靠左 */
.msg-label { margin-bottom: 6px; font-size: 12px; line-height: 1.4; color: var(--muted); }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .msg-label { text-align: right; }
.msg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.msg-head .msg-label { margin-bottom: 0; }
.msg.user .msg-head { justify-content: flex-end; }
/* 复制按钮：小而淡，不抢视觉；颜色全部走主题变量，暗色下同样可读 */
.copy-btn { min-height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; line-height: 24px; color: var(--muted); background: transparent; border: 1px solid transparent; }
.copy-btn:hover, .copy-btn:active { color: var(--text); background: var(--line); }
.md .md-codebox { position: relative; margin: 0 0 0.8em; }
.md .md-codebox pre.md-code { margin: 0; padding-top: 30px; } /* 给右上角“复制”按钮留出一行，不遮挡首行代码 */
.md .md-codebox .code-copy { position: absolute; top: 4px; right: 4px; min-height: 22px; line-height: 22px; background: var(--panel); border-color: var(--line); opacity: 0.85; }
.msg.user .bubble { max-width: 85%; padding: 10px 14px; background: var(--bubble); border-radius: 12px 12px 3px 12px; font-size: var(--chat-fs); line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.pendings:empty { display: none; }
.pendings { margin-top: 26px; }
.pendings .msg + .msg { margin-top: 10px; }
.msg.pending .bubble { opacity: 0.8; }
.msg.pending.bad .bubble { opacity: 1; box-shadow: inset 0 0 0 1.5px var(--danger); }
.pend-row { display: flex; align-items: center; gap: 2px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.msg.pending.bad .pend-label { color: var(--danger); }
.msg.pending.waiting .pend-label { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; }
.msg.pending.waiting .pend-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pend-wait 1.4s ease-in-out infinite; }
@keyframes pend-wait { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .msg.pending.waiting .pend-label::before { animation: none; } }
.pend-x { min-height: 32px; padding: 0 8px; color: var(--muted); font-size: 12px; border-radius: 8px; }
.pend-x:active { background: var(--press); }

/* 助手回复：左侧无框的正文，Markdown */
.md { max-width: 78ch; font-size: var(--chat-fs); line-height: 1.8; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.7em; }
.md h3, .md h4, .md h5, .md h6 { margin: 1.1em 0 0.4em; line-height: 1.35; font-weight: 650; }
.md h3 { font-size: 1.14em; }
.md h4 { font-size: 1.06em; }
.md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.md li + li { margin-top: 0.2em; }
.md li > ul, .md li > ol { margin: 0.2em 0 0; }
.md li > p { margin: 0; }
.md code { font-family: var(--mono); font-size: 0.86em; padding: 0.1em 0.38em; background: var(--code-bg); border-radius: 4px; }
.md pre.md-code { margin: 0 0 0.8em; padding: 10px 12px; background: var(--code-bg); border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.5; -webkit-overflow-scrolling: touch; }
.md pre.md-code code { padding: 0; background: none; font-size: inherit; white-space: pre; }
.md blockquote { margin: 0 0 0.7em; padding: 0 0 0 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md .md-table-wrap { margin: 0 0 0.8em; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: collapse; font-size: 0.92em; }
.md th, .md td { padding: 5px 10px; border: 1px solid var(--line); white-space: nowrap; }
.md th { background: var(--panel); font-weight: 600; }

/* 工具调用：连续的操作合并成一行“执行了 N 个操作”，点击展开逐条显示；每条仍是一行细条，可再点开看输入与结果 */
.msg.tools { margin-top: 12px; color: var(--muted); }
.msg.tools + .msg { margin-top: 20px; }
.tools-row { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 36px; padding: 2px 10px 2px 4px; border-radius: 8px; text-align: left; font-size: 13px; color: var(--muted); }
.tools-row:active, .tools-row:hover { background: var(--panel); }
.tools-row[aria-expanded="true"] .tool-chev { transform: rotate(90deg); }
.tools-label { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.msg.tools.bad .tools-dot { background: var(--danger); }
.tools-body { margin: 2px 0 4px 10px; padding-left: 8px; border-left: 2px solid var(--line); }
.tool-item { color: var(--muted); }
.tool-item + .tool-item { margin-top: 2px; }
.tool-row { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; padding: 2px 8px 2px 2px; border-radius: 6px; text-align: left; font-size: 13px; }
.tool-row:active { background: var(--panel); }
.tool-chev { flex: none; display: inline-flex; width: 14px; transition: transform 120ms; }
.tool-row[aria-expanded="true"] .tool-chev { transform: rotate(90deg); }
.tool-name { flex: none; font-weight: 600; color: var(--text); }
.tool-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.tool-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.tool-item.bad .tool-dot { background: var(--danger); }
.tool-detail { margin: 2px 0 6px 20px; }
.tool-detail pre { margin: 0 0 6px; padding: 8px 10px; background: var(--code-bg); border-radius: 6px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; color: var(--text); }
.tool-detail pre.tool-input { color: var(--muted); }
.tool-detail pre.err { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.tool-note { font-size: 12px; color: var(--muted); }

.new-pill { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 14px 0 10px;
  border-radius: 18px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }

/* ---------- 等待确认卡片 ---------- */
.choice-card { flex: none; max-height: 62%; overflow-y: auto; margin: 0; padding: 12px 14px 10px; background: var(--panel); border-top: 2px solid var(--waiting); }
.choice-head { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.choice-card.answered { border-top-color: var(--line); }
.choice-card.answered .choice-head { font-weight: 400; opacity: .75; }
.choice-text { margin: 0 0 10px; padding: 8px 10px; background: var(--code-bg); border-radius: 8px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow: auto; }
.choice-keys { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }
.choice-key { flex: 1 1 56px; min-width: 52px; min-height: 46px; padding: 0 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 16px; font-weight: 600; font-family: var(--mono); color: var(--text); }
.choice-key[data-key="up"], .choice-key[data-key="down"], .choice-key[data-key="enter"] { font-size: 22px; font-family: var(--ui); }
.choice-key:active { background: var(--press); }
.choice-key.stop { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.choice-lock { margin: 6px 0 0; font-size: 13px; color: var(--waiting); }
.choice-keys + .choice-lock { margin-top: 8px; }
.choice-paused { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.choice-foot { display: flex; gap: 8px; margin-top: 10px; }
.choice-term { min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 14px; color: var(--muted); }
.choice-term:active { background: var(--press); }
/* 结构化回答区（web/feed-panel.mjs）：选择题 / 权限请求 / 退出计划 */
.feed-panel { margin: 0 0 6px; }
.feed-tag { display: inline-block; margin: 0 0 6px; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.feed-prompt { margin: 0 0 8px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.feed-pre { margin: 0 0 10px; padding: 8px 10px; background: var(--code-bg); border-radius: 8px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 28vh; overflow: auto; }
.feed-pre.plan { max-height: 34vh; }
.feed-options { display: flex; flex-direction: column; gap: 8px; margin: 0 0 8px; }
.feed-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 48px; padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--text); text-align: left; }
.feed-opt:active { background: var(--press); }
.feed-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.feed-opt-label { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.feed-opt-desc { font-size: 13px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.feed-step { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.feed-note { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
/* 不显眼的文字按钮：卡片底部“其他（自己输入）”与超时卡片的“隐藏”（点按区域仍 >= 44px） */
.feed-other, .feed-dismiss, .feed-handback { display: block; min-height: 44px; margin: 0 0 4px; padding: 0 4px; border: none; background: none; color: var(--muted); font-size: 13px; text-align: left; text-decoration: underline; }
.feed-other.on { color: var(--accent); }
.feed-other-input { display: block; width: 100%; box-sizing: border-box; min-height: 44px; margin: 0 0 8px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
.feed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.feed-actions.col { flex-direction: column; }
.feed-act, .feed-submit { flex: 1 1 96px; min-height: 46px; padding: 0 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 15px; font-weight: 600; color: var(--text); }
.feed-act:active, .feed-submit:active { background: var(--press); }
.feed-act.primary, .feed-submit { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.feed-act.primary:active, .feed-submit:active { filter: brightness(0.92); }
.feed-act.danger { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.feed-panel button:disabled { opacity: 0.5; }
.feed-block { margin: 0 0 8px; }
.feed-label { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.feed-block .feed-pre { margin-bottom: 4px; }
.feed-fold { display: block; margin: 0 0 6px; min-height: 36px; padding: 0 10px; border-radius: 8px; font-size: 13px; color: var(--accent); }
.feed-fold:active { background: var(--press); }
.feed-warn { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--danger); }
.feed-timer { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- 按键面板 ---------- */
.kp-mask { position: fixed; inset: 0; z-index: 40; background: var(--mask); display: flex; align-items: flex-end; justify-content: center; }
.keypanel { width: 100%; max-width: 520px; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
.kp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kp-title { font-size: 15px; font-weight: 600; }
.kp-done { min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--accent); font-size: 15px; font-weight: 600; }
.kp-done:active { background: var(--press); }
.kp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* 按键：大按钮；底部 2px 边营造按下前的立体感，按下时下沉 */
.cap { height: 56px; border-radius: 12px; background: var(--cap); color: var(--text); border: 1px solid var(--line); border-bottom: 3px solid var(--cap-edge);
  font-family: var(--mono); font-size: 18px; font-weight: 500; }
.cap[data-glyph] { font-family: var(--ui); font-size: 22px; }
.cap:active { transform: translateY(2px); border-bottom-width: 1px; }
.cap.stop { color: var(--danger); border-color: var(--danger); }

/* ---------- 菜单：分段选择 ---------- */
.menu-seg { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 4px 8px 4px 12px; }
.seg-label { flex: none; }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--line); border-radius: 9px; }
.seg-opt { min-height: 34px; padding: 0 10px; border-radius: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg-opt[aria-checked="true"], .nav-switch .seg-opt[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }

/* ---------- 宽屏两栏：左侧会话列表常驻（320px），右侧是当前会话 ---------- */
.split { flex: none; /* 不能是 flex: 1：#app 是 flex 列容器且高度不定，flex-basis 为 0 的子项会按内容高度撑开，列表很长时整个两栏被撑到几千像素、输入区跑出屏幕；高度由下面的 height 决定 */ display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 0; }
.pane-list { min-width: 0; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); }
.pane-list .bar-in, .pane-list .col { max-width: none; }
.pane-list .filters { padding: 12px 12px 4px; gap: 4px; }
.pane-list .chip { padding: 0 9px; font-size: 13px; }
.pane-list .chip .n { margin-left: 4px; }
.pane-list .row:hover { background: var(--line); }
.pane-list .row.selected { background: var(--accent-soft); }
.pane-session { position: relative; min-width: 0; min-height: 0; }
.pane-session .term-page { position: relative; inset: auto; height: 100%; max-width: none; margin: 0; }
.pane-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; color: var(--muted); }
.pane-empty .lead { color: var(--text); font-size: 17px; }
.pane-empty .hint { margin: 0; font-size: 14px; }
@media (min-width: 1000px) {
  .split .back-list { display: none; }
  .split .term-bar { padding-left: 16px; }
  .chat-inner { max-width: 820px; padding: 28px 32px 32px; }
}

/* ---------- 图片附件：输入卡片里的附件条 ---------- */
.attach-bar { padding: 8px 10px 0; }
.att-list { display: flex; gap: 10px; overflow-x: auto; padding: 8px 8px 2px 4px; -webkit-overflow-scrolling: touch; }
.att-item { position: relative; flex: none; width: 56px; height: 56px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.att-img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 9px; -webkit-user-drag: none; }
.att-ph { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 11px; font-weight: 600; color: var(--muted); }
.att-item.working .att-img, .att-item.working .att-ph { opacity: 0.4; }
.att-item.bad { border-color: var(--danger); box-shadow: 0 0 0 1.5px var(--danger); }
.att-item.done { border-color: var(--accent); }
.att-spin { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent); animation: att-rot 0.8s linear infinite; }
@keyframes att-rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .att-spin { animation-duration: 2.4s; } }
.att-x { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: var(--text); color: var(--bg);
  font-size: 16px; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px var(--card); }
.att-x::after { content: ''; position: absolute; inset: -11px; }
.att-x:disabled { opacity: 0.35; }
.att-meta { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0 0; min-height: 36px; }
.att-orig { flex: none; min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 13px; }
.att-orig.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.att-status { flex: 1; min-width: 0; font-size: 12px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.att-status.bad { color: var(--danger); }

/* 对话里用户气泡中的附件缩略图 */
.msg.user .bubble.has-att { white-space: normal; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-text + .att-grid { margin-top: 8px; }
.att-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.att-thumb { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; padding: 0; overflow: hidden; border-radius: 8px;
  background: var(--code-bg); border: 1px solid var(--line); }
.att-thumb:active { opacity: 0.85; }
.att-thumb.broken { cursor: default; }
.att-thumb-img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.att-broken { padding: 4px; font-size: 11px; line-height: 1.3; color: var(--muted); text-align: center; }
.att-note { margin-top: 6px; font-size: 12px; line-height: 1.4; color: var(--muted); }

/* 图片全屏预览 */
.lightbox { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.92); }
.lb-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-note { color: #F8F8F2; font-size: 14px; }
.lb-close { position: absolute; top: 12px; right: 12px; min-width: 44px; min-height: 44px; padding: 0 16px; border-radius: 22px; background: rgba(255, 255, 255, 0.16); color: #F8F8F2; font-size: 14px; }
.lb-close:active { background: rgba(255, 255, 255, 0.28); }

/* 网页预览：路径后面的“预览”按钮与全屏 / 居中弹层（手机全屏，桌面居中大弹层） */
.pv-btn { display: inline-flex; align-items: center; min-height: 24px; margin: 0 4px; padding: 0 8px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 12px; line-height: 1; vertical-align: baseline; }
.pv-btn:active { opacity: 0.7; }
.pv-btn.pv-tool { margin: 2px 0 4px 20px; }
.pv-mask { position: fixed; inset: 0; z-index: 75; display: flex; align-items: stretch; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.pv-panel { display: flex; flex-direction: column; width: 100%; height: 100%; background: var(--bg); }
.pv-bar { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); background: var(--card); }
.pv-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.pv-newtab, .pv-close { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--line); color: var(--text); font-size: 13px; white-space: nowrap; }
.pv-body { position: relative; flex: 1; min-height: 0; background: #FFFFFF; }
.pv-frame { display: block; width: 100%; height: 100%; border: 0; background: #FFFFFF; }
.pv-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--bg); font-size: 14px; }
@media (min-width: 900px) {
  .pv-mask { align-items: center; padding: 24px; }
  .pv-panel { width: min(1100px, 100%); height: min(860px, 100%); border-radius: 14px; overflow: hidden; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4); }
}

/* 偏好设置页：每项一行，标题在左、分段选择在右，下方是说明；窄屏上分段选择换到标题下面 */
.pref-list { margin: 12px 12px 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.pref-row { padding: 12px 14px; border-top: 1px solid var(--line); }
.pref-row:first-child { border-top: 0; }
.pref-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pref-label { font-weight: 600; }
/* 偏好行里的分段控件通用规则：放得下就一行（与原来一致，选项不撑开）；选项文案长、一行放不下时（如“回车键”）自动换到下一行并各占满整行，文字也允许换行 */
.pref-head > .seg { max-width: 100%; flex-wrap: wrap; }
.pref-head > .seg .seg-opt { flex: 1 1 auto; white-space: normal; }
/* 主题色色块：颜色取 --sw-* 令牌（当前明暗下的值）；选中项加外圈描边；窄屏允许换行不溢出 */
.accent-group { display: flex; flex-wrap: wrap; gap: 10px; max-width: 100%; }
.accent-swatch { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: var(--sw-purple); }
.accent-swatch[data-accent="blue"] { background: var(--sw-blue); }
.accent-swatch[data-accent="teal"] { background: var(--sw-teal); }
.accent-swatch[data-accent="orange"] { background: var(--sw-orange); }
.accent-swatch[data-accent="rose"] { background: var(--sw-rose); }
.accent-swatch[aria-pressed="true"] { border-color: var(--bg); box-shadow: 0 0 0 3px var(--text); }
.pref-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pref-foot { margin: 12px 16px 24px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pref-list + .err { margin: 10px 16px 0; }

/* 新建会话：按目录 / 最近项目；偏好页的总目录与常用分类 */
.nw .seg { margin-bottom: 12px; }
.nw-seg { flex: 1; min-height: 40px; }
.nw-pane[hidden], .nw-list[hidden] { display: none; }
.nw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.nw-chip { min-height: 44px; padding: 0 16px; font-size: 15px; }
.nw-chip .n { opacity: 0.7; }
.nw-more { color: var(--accent); border-style: dashed; }
.nw-hint { margin: 8px 0 0; min-height: 20px; font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.nw-hint.new { color: var(--accent); }
.nw-hint.invalid { color: var(--danger); }
.nw-list { margin-top: 8px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.nw-item { min-height: 48px; justify-content: center; border-radius: 0; border-width: 0; }
.nw-item + .nw-item { margin-top: 0; border-top: 1px solid var(--line); }
.nw-item:active { background: var(--press); }
.nw-item-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.nw-tag { padding: 1px 8px; font-size: 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.nw-tag.dim { background: var(--line); color: var(--muted); }
.nw-err { margin-top: 10px; }
.nw-base { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.nw-base .field { flex: 1 1 240px; }
.pref-row .nw-chips { margin-top: 8px; }

/* ---------- Mac 桌面页（#/desktop） ---------- */
.desk-page { position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.desk-page [hidden] { display: none !important; }
.desk-page .bar-in { max-width: none; }
/* 761-999px：列表页是单栏（顶栏限宽 760 居中），桌面页顶栏同样限宽居中，两页的切换控件位置一致；>= 1000px 列表页是左栏（顶栏在左栏内、不限宽），桌面页保持不限宽，与左栏同样靠左 */
@media (min-width: 761px) and (max-width: 999px) { .desk-page .bar-in { max-width: 760px; } }
.desk-state { flex: none; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--muted); }
.desk-traffic { flex: none; display: flex; flex-direction: column; align-items: flex-end; margin-right: 6px; font-size: 10px; line-height: 1.25; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 400px) { .desk-traffic { margin-right: 4px; font-size: 9px; } }
.desk-state.connected { background: var(--accent-soft); color: var(--working); }
.desk-state.connecting { color: var(--waiting); }
.desk-state.error { color: var(--danger); }
.desk-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #000; touch-action: none; }
.desk-keys { flex: none; display: flex; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; background: var(--panel); border-top: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.desk-key { flex: none; min-width: 48px; min-height: 40px; padding: 0 12px; border-radius: 8px; background: var(--cap); border: 1px solid var(--cap-edge); color: var(--text); font-size: 14px; }
.desk-key:active { background: var(--press); }
.desk-key[hidden] { display: none; }
.desk-keys-note { flex: none; align-self: center; padding: 0 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.kp-hidden-note { grid-column: 1 / -1; margin: 6px 0; text-align: center; color: var(--muted); font-size: 13px; }
/* 偏好页“快捷键”弹层 */
.keys-pref-group { margin: 0 0 14px; }
.keys-pref-group h4 { margin: 0 0 6px; font-size: 14px; }
.keys-pref-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; padding: 0 4px; border-top: 1px solid var(--line); text-align: left; }
.keys-pref-item:first-of-type { border-top: 0; }
.desk-key.once { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.desk-key.lock { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.desk-kbinput { position: absolute; left: -40px; width: 1px; height: 1px; border: 0; padding: 0; background: #fff; color: #fff; z-index: -1; }
.desk-overlay { position: absolute; left: 0; right: 0; top: var(--bar-h); bottom: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0, 0, 0, 0.78); }
.desk-msg { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: #F8F8F2; }
.desk-msg-text { font-size: 17px; font-weight: 600; }
.desk-msg-hint { font-size: 13px; line-height: 1.6; color: #C7CBDA; overflow-wrap: anywhere; }
.desk-msg-hint:empty { display: none; }
.desk-dialog-mask { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--mask); }
.desk-dialog { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.desk-dialog h3 { margin: 0; font-size: 17px; }
.desk-dialog p { margin: 0; font-size: 13px; line-height: 1.6; }
.desk-clip { resize: vertical; min-height: 96px; }
.desk-auth-form { display: flex; flex-direction: column; gap: 10px; }
/* VNC 密码模式的固定账号名字段：必须保持可见（Safari 会忽略 display:none / hidden 的用户名字段），只弱化外观 */
.desk-auth-account { min-height: 32px; padding: 4px 12px; font-size: 13px; opacity: 0.6; }
.desk-auth-label { font-size: 13px; color: var(--muted); }
/* Mac 桌面：noVNC 的承载层（自定义视口时按帧缓冲像素大小摆放并用 transform 缩放平移）、触摸层、本地光标指示、显示器选择条 */
.desk-vp { position: absolute; inset: 0; }
.desk-vp.custom { inset: auto; left: 0; top: 0; transform-origin: 0 0; }
.desk-touch { position: absolute; inset: 0; z-index: 2; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.desk-cursor { position: absolute; left: 0; top: 0; z-index: 3; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2px solid #fff; background: rgba(255, 70, 70, 0.55); box-shadow: 0 0 0 1px #000; pointer-events: none; }
.desk-displays { flex: none; display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.desk-displays .seg { flex: 1 1 auto; }
.desk-apps { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.desk-app { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; background: var(--cap); border: 1px solid var(--cap-edge); color: var(--text); font-size: 15px; text-align: left; }
.desk-apps-head { font-size: 12px; color: var(--muted); margin-top: 6px; }
.desk-space-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.desk-space-main .muted { font-size: 12px; overflow-wrap: anywhere; }
.desk-app:disabled { opacity: .55; }
.desk-app.front { border-color: var(--accent); color: var(--accent); }
.desk-check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
/* 桌面页“输入面板”：贴在页面底部（按键条下方），不遮住桌面画面；页面高度跟随可视区域，软键盘弹出时面板在键盘上方 */
.desk-typepanel { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.desk-typepanel-head { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.desk-typepanel-spacer { flex: 1; }
.desk-typepanel-ta { resize: none; min-height: 72px; max-height: 30vh; }
.desk-typepanel-hint { font-size: 12px; line-height: 1.5; }
.desk-typepanel-err { font-size: 13px; }
.desk-typepanel-err:empty { display: none; }
.desk-typepanel-btns { display: flex; gap: 8px; }
.desk-typepanel-btns .btn { flex: 1; }
.desk-typepanel-btns .btn:disabled { opacity: 0.5; }

/* ---------- 公网访问（自带中转）：等待 Mac 批准、二维码、插件已接入、公网标签 ---------- */
.login-form { display: contents; }
.pending-login { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.pending-login h2 { font-size: 16px; margin: 0; }
.pending-login .hint { margin: 0; color: var(--muted); font-size: 13px; }
.match-code { font-size: 44px; font-weight: 700; letter-spacing: 8px; padding-left: 8px; font-variant-numeric: tabular-nums; color: var(--accent); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.qr-box .hint { margin: 0; color: var(--muted); font-size: 13px; }
.qr-canvas { width: 220px; height: 220px; image-rendering: pixelated; background: #FFFFFF; border-radius: 8px; }
.st-pill.plugin-on { --st: var(--accent); --st-text: var(--accent); }
.via-tag { margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: 11px; color: var(--accent); background: var(--accent-soft); }
