/* 本文件由 gen-override.py 自动生成，请勿手改 —— 改生成器或改上游。
 *
 * 作用：把 codex-webui 对齐 xhu4ng.com 博客的观感（霞鹜文楷 + zinc 配色）。
 * 上游 app.css 有 133 处硬编码颜色绕过 CSS 变量，必须逐条改写，
 * 这也是上游自带 light 主题切了没效果的原因。
 *
 * 重新生成：
 *   python3 gen-override.py <上游 public/app.css 路径> web/override.css
 */

.sidebar {
  background: #fef3c7;
}

.brand-mark {
  color: #d1fae5;
  background: linear-gradient(145deg, #dc2626, #2563eb);
}

.new-thread:hover {
  border-color: #fef3c7;
}

.fleet-chip.working {
  border-color: rgba(37, 99, 235, 0.3);
}

.fleet-chip.needs {
  border-color: rgba(24, 24, 27, 0.35);
}

.thread-heading {
  color: #b45309;
}

.thread-item {
  color: #b45309;
}

.thread-item:hover {
  background: #fef3c7;
}

.thread-item span {
  color: #b45309;
}

.connection i, .status-pill i {
  background: #fef3c7;
}

.topbar {
  background: rgba(254, 243, 199, 0.96);
}

.usage-chip.ok {
  border-color: rgba(37, 99, 235, 0.25);
}

.activity-toggle {
  color: #b45309;
}

.activity-toggle:hover, .activity-toggle.active {
  border-color: #fef3c7;
  background: #fef3c7;
}

.activity-pulse {
  background: #fef3c7;
}

.mode-pill {
  color: #047857;
  background: #d1fae5;
  border: 1px solid #059669;
}

.mode-pill.full-access {
  color: #18181b;
  background: #f4f4f5;
  border-color: #e4e4e7;
}

.orb {
  border: 1px solid #d1fae5;
  background: radial-gradient(circle at 35% 25%, #d1fae5, #fef3c7 68%);
}

.suggestions button {
  color: #b45309;
  background: #fef3c7;
}

.suggestions button:hover {
  border-color: #fef3c7;
}

.avatar {
  color: #d1fae5;
}

.message.user .avatar {
  color: #dc2626;
  background: #d1fae5;
}

.message-body {
  color: #059669;
}

.message-body.streaming {
  color: #b45309;
}

.message-body > .md-h3 {
  color: #059669;
}

.message-body > blockquote {
  border-left: 3px solid rgba(37, 99, 235, 0.4);
  color: #059669;
}

.message-body strong {
  color: #047857;
}

.message-body em {
  color: #059669;
}

.message-body .md-link {
  color: #2563eb;
}

.message-body .md-link:hover {
  color: #2563eb;
}

.message-body code.md-inline,
.message-body :not(pre) > code {
  background: rgba(209, 250, 229, 0.9);
  color: #047857;
}

.message-body .md-code-block {
  background: #fef3c7;
}

.message-body .md-code-lang {
  color: #b45309;
  background: #d1fae5;
}

.message-body pre, .event-card pre, .approval-copy pre {
  color: #059669;
  background: #fef3c7;
}

.message.user .message-body {
  background: rgba(209, 250, 229, 0.32);
  border: 1px solid rgba(209, 250, 229, 0.22);
  color: #047857;
}

.message-image-link {
  background: #fef3c7;
}

.event-card {
  background: #fef3c7;
  border: 1px solid #fef3c7;
}

.event-card strong {
  color: #b45309;
}

.progress-card {
  background: #fef3c7;
  border: 1px solid #fef3c7;
}

.progress-card summary {
  color: #b45309;
}

.progress-card[open] summary {
  border-bottom: 1px solid #fef3c7;
  color: #059669;
}

.progress-update {
  border-bottom: 1px solid rgba(24, 24, 27, 0.05);
}

.jump-latest {
  color: #059669;
  background: #fef3c7;
  border: 1px solid #fef3c7;
}

.jump-latest:hover {
  color: #d1fae5;
}

.activity-rail {
  background: #fef3c7;
}

.activity-state {
  color: #b45309;
  background: #fef3c7;
}

.activity-state #token-usage {
  color: #fef3c7;
}

.plan-panel {
  background: rgba(37, 99, 235, 0.035);
}

.plan-panel h2, .activity-feed-wrap h2 {
  color: #b45309;
}

.plan-panel > p {
  color: #b45309;
}

.plan-step {
  color: #b45309;
  background: #d1fae5;
  border: 1px solid #fef3c7;
}

.plan-marker {
  color: #b45309;
  border: 1px solid #fef3c7;
}

.plan-copy small {
  color: #b45309;
}

.plan-step.in-progress {
  background: rgba(37, 99, 235, 0.09);
  border-color: rgba(37, 99, 235, 0.5);
}

.plan-step.in-progress .plan-marker {
  color: #d1fae5;
}

.plan-step.completed {
  color: #b45309;
  background: rgba(5, 150, 105, 0.05);
}

.plan-step.completed .plan-marker {
  color: #18181b;
  background: #059669;
  border-color: #059669;
}

.plan-step.completed .plan-copy small {
  color: #047857;
}

.activity-empty {
  color: #fef3c7;
}

.activity-entry {
  background: #fef3c7;
  border: 1px solid #fef3c7;
}

.activity-entry::before {
  background: #fef3c7;
}

.activity-entry.done::before {
  background: #059669;
}

.activity-entry strong {
  color: #b45309;
}

.activity-entry time {
  color: #fef3c7;
}

.activity-entry pre, .activity-entry p {
  color: #b45309;
}

.activity-entry.reasoning p {
  color: #b45309;
}

.approval-drawer {
  background: #fafafa;
  border: 1px solid #e4e4e7;
}

.approval-icon {
  color: #fafafa;
}

.approval-copy p {
  color: #3f3f46;
}

.primary {
  color: #d1fae5;
}

.secondary {
  border-color: #fef3c7;
}

.danger {
  color: #18181b;
  background: #d1fae5;
  border-color: #d1fae5;
}

.command-menu {
  background: #fef3c7;
}

.composer {
  background: #fef3c7;
  border: 1px solid #fef3c7;
}

.composer:focus-within {
  border-color: #fef3c7;
}

.tip-modal {
  background: rgba(209, 250, 229, 0.78);
}

.tip-dialog {
  border: 1px solid rgba(220, 38, 38, 0.28);
  background: linear-gradient(160deg, #d1fae5, #d1fae5);
}

.tip-icon {
  border: 1px solid rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.1);
}

.tip-amounts button:hover {
  border-color: #d1fae5;
}

.tip-custom-link:hover {
  background: rgba(220, 38, 38, 0.08);
}

.tip-fine {
  color: #fef3c7;
}

.prefs-modal {
  background: rgba(209, 250, 229, 0.78);
}

.prefs-amt-status.ok {
  border-color: rgba(37, 99, 235, 0.28);
}

.empty-badge {
  border: 1px solid rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
}

#active-workspace {
  color: #b45309;
}

.send-button {
  color: #d1fae5;
}

.toast {
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fef3c7;
}

.toast.error {
  border-color: #059669;
}

.login-page {
  background: radial-gradient(circle at 50% 30%, #d1fae5, var(--bg) 42%);
}

.login-card {
  background: rgba(254, 243, 199, 0.9);
}

.login-card label {
  color: #b45309;
}

.login-card input {
  background: #d1fae5;
  border: 1px solid #fef3c7;
}

.secure-note {
  color: #b45309;
}

/* ===== 以下为手写规则（改 gen-override.py 的 TAIL，不要改本文件） ===== */
/*
 * 博客基准：样本中的 zinc 侧栏色、霞鹜文楷、.025em 导航字距，
 * 以及 8 / 16 / 24px 留白。正文使用任务要求的 17px / 1.8。
 * 本段不能使用 @import：前面已有普通规则，导入会被浏览器忽略。
 * 霞鹜文楷由宿主页加载 /fonts/lxgw/style.css；未加载时使用本地回退。
 */
:root,
body:not([data-theme="dark"]) {
  --bg: #ffffff;
  --panel: #fafafa;
  --panel-2: #f4f4f5;
  --panel-3: #e4e4e7;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #52525b;
  --accent: #047857;
  --accent-2: #065f46;
  --green: #047857;
  --blue: #2563eb;
  --red: #dc2626;
  --amber: #92400e;
  --purple: #7c3aed;
  --chip-bg: #f4f4f5;
  --chip-border: #e4e4e7;
  --shadow: none;
  color-scheme: light;
}
body[data-theme="dark"] {
  --bg: #09090b;
  --panel: #18181b;
  --panel-2: #27272a;
  --panel-3: #3f3f46;
  --border: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #34d399;
  --accent-2: #6ee7b7;
  --green: #34d399;
  --blue: #93c5fd;
  --red: #f87171;
  --amber: #fbbf24;
  --purple: #c4b5fd;
  --chip-bg: #27272a;
  --chip-border: #3f3f46;
  --shadow: none;
  color-scheme: dark;
}
/* 保留 Preferences 的强调色选项；语义状态仍由 green / amber / red 表达。 */
body[data-accent="green"], body[data-theme][data-accent="green"] { --accent: var(--green); --accent-2: var(--green); }
body[data-accent="blue"], body[data-theme][data-accent="blue"] { --accent: var(--blue); --accent-2: var(--blue); }
body[data-accent="purple"], body[data-theme][data-accent="purple"] { --accent: var(--purple); --accent-2: var(--purple); }
body[data-accent="gold"], body[data-theme][data-accent="gold"] { --accent: var(--amber); --accent-2: var(--amber); }

:root {
  /* 阅读列放宽：880 → 1080（≥1600px 的屏幕再放到 1200）。原值是按博客正文
     720px 的阅读感定的，实际对话内容是消息气泡 + 代码块，880 在大屏上两侧
     空得太多。侧栏同步 288 → 320。 */
  --chat-max: min(1200px, calc(100% - 48px));
  --chat-pad-x: max(24px, calc((100% - min(1200px, 100% - 48px)) / 2));
  font-family: "LXGW WenKai", "LXGW WenKai GB", "PingFang SC",
    "Microsoft YaHei", system-ui, sans-serif;
}
@media (min-width: 1600px) {
  :root {
    --chat-max: min(1360px, calc(100% - 64px));
    --chat-pad-x: max(32px, calc((100% - min(1360px, 100% - 64px)) / 2));
  }
}
html { font-size: 16px; }
body {
  font-family: inherit;
  font-size: 17px;
  line-height: 1.8;
  font-weight: 400;
  letter-spacing: .015em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { letter-spacing: inherit; }
button, input, select, textarea,
.new-thread, .thread-item, .fleet-chip, .usage-chip, .status-pill, .mode-pill,
.activity-toggle, .workspace-picker, .empty-badge, .message-body,
.message-body .md-code-block, .message-body pre, .message-body code.md-inline,
.message-body :not(pre) > code, .message-image-link, .event-card, .progress-card,
.jump-latest, .activity-entry, .plan-step, .plan-marker, .approval-drawer,
.approval-icon, .attach-chip, .attach-chip img, .command-menu, .composer,
.tip-dialog, .tip-icon, .prefs-dialog, .prefs-section, .prefs-amt-status,
.prefs-tool, .prefs-tool .tier, .gallery-card, .message-queue, .queue-choice,
.queued-message, .toast, .login-card { border-radius: 2px; }

/* 覆盖上游带父级限定的控件圆角；状态圆点与旋转指示器仍为圆形。 */
.icon-button, .text-button, .attach-button, .send-button, .primary, .secondary, .danger,
.thread-item .pin-btn, .session-search input, .composer-settings select,
.tip-amounts button, .tip-custom-link, .gallery-toolbar select, .suggestions button {
  border-radius: 2px;
}

/* 焦点与状态不依赖颜色或鼠标悬停；保留上游 hidden、动画和交互节点。 */
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input, select, textarea {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  accent-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button:disabled, input:disabled, select:disabled, textarea:disabled,
[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
button:not(:disabled), a, select, summary {
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
::selection { color: var(--text); background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
* { scrollbar-width: thin; scrollbar-color: var(--panel-3) var(--bg); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* 侧栏用浅层底色与留白组织，只有当前会话有窄竖标。 */
.shell { grid-template-columns: 340px minmax(0, 1fr); }
.sidebar { padding: 24px 16px 16px; background: var(--panel); font-size: 15px; }
.brand-row { gap: 12px; padding: 0 8px 24px; }
/* 文字节点整块移除：只 font-size:0 的话那个空 div 仍占 flex 位置，
   会在小鸟与右侧之间留一段空隙。 */
.brand-row > div:not(.brand-mark) { display: none; }
.message .avatar, .message.user .avatar, .brand-mark.small, .orb {
  padding: 0;
  font-size: 0;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: url("/static/bird-day.png?v=4") center / cover no-repeat;
  box-shadow: none;
}
body[data-theme="dark"] .message .avatar,
body[data-theme="dark"] .brand-mark.small,
body[data-theme="dark"] .orb { background-image: url("/static/bird-night.png?v=4"); }
.brand-mark.small { flex: 0 0 46px; width: 46px; height: 46px; }
.message .avatar { width: 40px; height: 40px; margin-top: 0; }
/* ★ 图片 URL 必须带 ?v=：网关对 /static/* 下发 Cache-Control: max-age=14400
   （4 小时）。换图不改版本号，浏览器会一直用缓存里的旧图 —— 曾因此
   「Codex 头像改了却看不到」。改图时同时递增 v，并递增 override.css 的 ?v=。 */
/* 助手侧不是鸟，是 Codex 的终端标记 —— 两个角色各有身份。
   必须排在上面共用鸟图规则之后才盖得掉 background-image。 */
.message.assistant .avatar {
  background-image: url("/static/codex-mark.svg?v=4");
  background-color: var(--panel-2);
}
.new-thread {
  min-height: 44px; padding: 8px 16px; text-align: center;
  font-size: 15px; font-weight: 600; line-height: 1.6;
  color: var(--text); background: var(--bg); border-color: var(--border);
}
.new-thread:hover { color: var(--accent); background: var(--bg); border-color: var(--accent); }
.fleet-strip { gap: 8px; margin: 12px 0; }
.fleet-chip, .usage-chip {
  min-height: 24px; padding: 0 8px; font-size: 12px; line-height: 1.6;
  font-weight: 400; letter-spacing: 0; color: var(--muted);
  background: var(--chip-bg); border: 0;
}
.fleet-chip.working, .usage-chip.ok { color: var(--green); border-color: var(--chip-border); }
.fleet-chip.needs, .usage-chip.warn { color: var(--amber); border-color: var(--chip-border); }
.session-search { margin: 0 0 8px; }
.session-search input { min-height: 40px; padding: 8px 12px; font-size: 14px; background: var(--bg); }
.thread-heading {
  margin: 16px 8px 8px; color: var(--muted);
  font-size: 12px; line-height: 1.6; font-weight: 600; letter-spacing: .05em;
}
.icon-button, .text-button { min-height: 32px; padding: 4px 8px; line-height: 1.6; }
.icon-button { min-width: 32px; font-size: 20px; }
.text-button { font-size: 14px; }
.icon-button:hover, .text-button:hover { color: var(--text); background: var(--panel-2); }
.thread-list { padding-bottom: 16px; }
.thread-item {
  position: relative; margin: 0 0 4px; padding: 12px;
  font-size: 15px; line-height: 1.6; color: var(--muted); background: none;
}
.thread-item strong { gap: 8px; font-size: 15px; font-weight: 400; }
.thread-item span { margin-top: 4px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.thread-item .item-row { gap: 8px; }
.thread-item:hover { color: var(--text); background: var(--panel-2); }
.thread-item.active { color: var(--text); background: var(--panel-2); box-shadow: none; }
.thread-item.active::before {
  content: ""; position: absolute; inset: 8px auto 8px 0; width: 2px; background: var(--accent);
}
.thread-item.active strong { font-weight: 600; }
.thread-item button {
  min-width: 28px; min-height: 28px; padding: 4px; font-size: 14px;
  line-height: 1; color: var(--muted); border-radius: 2px;
}
.thread-item .pin-btn { min-width: 28px; min-height: 28px; padding: 4px; font-size: 17px; }
.thread-item button:hover { color: var(--text); background: var(--panel-3); }
.thread-activity { width: 12px; height: 12px; border-width: 2px; }
#open-tip, #logout, #open-cli-map, #copy-last, #export-thread { display: none !important; }
/* LOCAL (shell): 网页终端入口。和 #open-cli-map 那种隐藏的对照表不同，
   这是一个真链接（/shell，新标签页），必须可见。 */
.top-terminal { text-decoration: none; white-space: nowrap; }
.top-terminal .t-label { margin-left: 4px; }
@media (max-width: 720px) {
  .top-terminal .t-label { display: none; }
  .top-terminal { padding: 6px 7px; }
}
.sidebar-footer { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 0 0; }
.sidebar-footer-actions { justify-content: flex-start; gap: 4px; }
/* LOCAL (page-entry): 加入 Pages 后三个按钮必须一行放下（容器 255px，
   原尺寸合计 270px）。横向 padding 12→9、gap 8→6 后合计 248px。 */
.sidebar-footer-actions .text-button { min-height: 40px; padding: 8px 9px; }
/* LOCAL (page-entry): Pages 入口是 <a> 不是 <button>。.text-button 已给
   color，只差链接下划线；hover 态由既有规则覆盖，不用重复写。 */
a.text-button { text-decoration: none; }
/* LOCAL (bird-buttons): 侧栏四颗按钮的逐帧小鸟。胶片 1086×362（4 帧），
   background-size 400% + steps(1) 硬切逐帧；hover 播一遍停在挥手帧，
   移开指针动画移除自动回第 1 帧。素材在网关 /static/（no-cache + ETag，
   二次加载 304）。归档按用户要求纯图标、title 悬浮提示。 */
.bird-flip { display: inline-block; flex-shrink: 0; margin-right: 1px;
  background: 0 0 / 400% 100% no-repeat; vertical-align: middle; }
/* 原始精灵每帧 271×362，按钮只有 18×24，直接缩 15 倍就是一团灰；且帧内上下
   还有约 70px 空白，鸟实际只占 71% 高度。现在用 tools/gen-bird-sprites.py
   把每帧按内容裁切后重排成精确的 1x（72×24）/ 2x（144×48）两档，
   1x 屏不必再让浏览器拿大图硬缩，视网膜屏拿 2x 原尺寸使用。 */
.bf-settings { background-image: url("/static/bird-settings-2x.png"); width: 24px; height: 32px; }
.bf-files { background-image: url("/static/bird-files-2x.png"); width: 24px; height: 32px; }
.bf-pages { background-image: url("/static/bird-pages-2x.png"); width: 24px; height: 32px; }
.bf-archive { background-image: url("/static/bird-archive-2x.png"); width: 24px; height: 32px; margin: 0; }
.bf-upload { background-image: url("/static/bird-upload-2x.png"); width: 24px; height: 32px; margin: 0; }
.bf-settings { background-image: image-set(url("/static/bird-settings-1x.png") 1x, url("/static/bird-settings-2x.png") 2x); }
.bf-files { background-image: image-set(url("/static/bird-files-1x.png") 1x, url("/static/bird-files-2x.png") 2x); }
.bf-pages { background-image: image-set(url("/static/bird-pages-1x.png") 1x, url("/static/bird-pages-2x.png") 2x); }
.bf-archive { background-image: image-set(url("/static/bird-archive-1x.png") 1x, url("/static/bird-archive-2x.png") 2x); }
.bf-upload { background-image: image-set(url("/static/bird-upload-1x.png") 1x, url("/static/bird-upload-2x.png") 2x); }
/* 附加文件按钮：上游定的是 32×32，鸟放大到 26×35 后装不下，点击区域也偏小 */
#attach-button { display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; margin-top: 0; border-radius: 10px; }
/* 每条会话行尾的归档按钮：用户要求不含鸟，纯 SVG 档案柜（currentColor 随主题）；
   15px 视觉偏重，压到 12px 与同行 ✎/✕ 文本符号的笔画量级对齐 */
.thread-act .arch-ico { display: block; margin: auto; width: 16px; height: 16px; }
#toggle-archived { display: inline-flex; align-items: center; justify-content: center; }
/* 鸟 24px + 上下 padding 6px < min-height 40px，行高不变；
   三颗按钮合计 252px ≤ 容器 255px，一行放下（鸟再大就会换行） */
/* 鸟放大到 22×29 后要腾出横向空间：padding 9→7、gap 6→4、图标右间距 2→1，
   三颗按钮合计约 245px，仍在 255px 容器内 */
/* 三颗按钮等宽：Settings 比 Files/Pages 多三个字母，按内容撑开就是「一大两小」。
   flex:1 让三格均分整行，内容居中，视觉上才是一组。 */
.sidebar-footer-actions .text-button {
  flex: 1 1 0; min-width: 0; padding: 6px 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  white-space: nowrap;
}
@keyframes birdflip { 0% { background-position: 0% 50%; } 25% { background-position: 33.333% 50%; }
  50% { background-position: 66.666% 50%; } 75%, 100% { background-position: 100% 50%; } }
.text-button:hover .bird-flip, .text-button:focus-visible .bird-flip,
.icon-button:hover .bird-flip, .icon-button:focus-visible .bird-flip,
.attach-button:hover .bird-flip, .attach-button:focus-visible .bird-flip {
  animation: birdflip .52s steps(1, end) 1 both; }
@media (prefers-reduced-motion: reduce) {
  .text-button:hover .bird-flip, .icon-button:hover .bird-flip,
  .attach-button:hover .bird-flip {
    animation: none; background-position: 100% 50%; } }
/* LOCAL (msg-times): 消息时间戳/耗时/日期分隔线 —— 层次靠尺寸差与细线 */
.message-label { display: flex; align-items: baseline; gap: 6px; }
.msg-time { margin-left: auto; font-size: 11px; font-weight: 400; letter-spacing: 0;
  text-transform: none; color: var(--muted); opacity: .72; white-space: nowrap; }
.msg-dur { opacity: .85; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px;
  font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.connection {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px;
  padding: 8px 12px; font-size: 13px; line-height: 1.6;
  color: var(--muted); background: none; border: 1px solid var(--border);
  border-radius: 2px; cursor: pointer;
}
.connection:hover, .connection:focus-visible { color: var(--text); background: var(--panel-2); border-color: var(--muted); }
.connection::after { content: "点击登出"; margin-left: auto; color: var(--muted); font-size: 12px; }
.connection i, .status-pill i, .activity-pulse { flex: 0 0 8px; width: 8px; height: 8px; background: var(--muted); }
.connection i.online, .status-pill.online i { background: var(--green); box-shadow: none; }
.workspace.has-activity .activity-pulse { background: var(--green); box-shadow: none; }

/* 顶栏辅助信息压到 12/13px；正文与输入框共享 880px 阅读列。 */
.topbar { min-height: 64px; padding: 12px 24px; gap: 16px; background: var(--bg); backdrop-filter: none; }
.thread-meta strong { font-size: 15px; line-height: 1.6; font-weight: 600; }
.thread-meta > span { margin-top: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.usage-strip { gap: 8px; margin-top: 4px; }
.usage-chip { min-height: 20px; background: none; padding: 0; }
.thread-meta .usage-chip { font-size: 12px; }
.top-actions { gap: 8px; }
.activity-toggle { gap: 8px; min-height: 36px; padding: 8px 12px; font-size: 13px; line-height: 1.4; color: var(--muted); background: none; border-color: var(--border); }
.activity-toggle:hover, .activity-toggle.active { color: var(--text); background: var(--panel-2); border-color: var(--muted); }

/* LOCAL (md-tables): 消息内 GFM 表格 —— 细线与留白，无外框 */
.md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md-table { border-collapse: collapse; }
.md-table th, .md-table td { text-align: left; vertical-align: top;
  padding: 6px 18px 6px 0; border: 0; border-bottom: 1px solid var(--border); }
.md-table th { font-weight: 600; }
.md-table tr:last-child td { border-bottom: 0; }
.status-pill, .mode-pill { min-height: 28px; padding: 4px 8px; font-size: 12px; line-height: 1.6; font-weight: 400; }
.status-pill { gap: 8px; color: var(--muted); background: none; border: 0; }
.mode-pill { color: var(--green); background: var(--chip-bg); border-color: var(--chip-border); }
.mode-pill.full-access { color: var(--amber); background: var(--chip-bg); border-color: var(--chip-border); }
.empty-state { padding: 32px 24px; }
/* 空状态：文案精简后重排间距（见 empty-state 补丁）。
   说明句限宽居中，避免在 880px 列里拉成一条长带。 */
.empty-state h1 { font-size: 24px; font-weight: 600; letter-spacing: 0; margin: 0 0 8px; }
.empty-state > p { max-width: 42ch; margin: 0 0 24px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.empty-state .eyebrow { display: none; }
.empty-badges { display: none; }
.orb { width: 72px; height: 72px; margin: 0 auto 24px; }
.eyebrow { font-size: 12px; line-height: 1.6; font-weight: 500; letter-spacing: .05em; color: var(--muted); }
.empty-state h1 { margin: 8px 0 16px; font-size: 24px; line-height: 1.4; font-weight: 600; letter-spacing: .015em; }
.empty-state > p:not(.eyebrow) { max-width: 480px; font-size: 15px; line-height: 1.8; }
.empty-badges { gap: 8px; margin: 16px 0 0; }
.empty-badge { min-height: 24px; padding: 0 8px; color: var(--muted); background: var(--chip-bg); border: 0; font-size: 12px; font-weight: 400; }
.workspace-picker { gap: 12px; margin: 24px auto 0; padding: 12px 16px; font-size: 14px; background: var(--panel); }
.workspace-picker select { min-width: 0; flex: 1; }
.workspace-acts { display: inline-flex; gap: 4px; }
select { padding: 8px 12px; font-size: 14px; line-height: 1.6; }
.suggestions { display: none; }
.conversation { padding: 32px var(--chat-pad-x); }
.message { grid-template-columns: 40px minmax(0, 1fr); gap: 16px; margin-bottom: 32px; }
.message-label { margin-bottom: 4px; font-size: 12px; line-height: 1.6; font-weight: 400; letter-spacing: .05em; color: var(--muted); }
.message-body, .message.user .message-body {
  font-size: 17px; line-height: 1.8; letter-spacing: .015em;
  color: var(--text); text-align: start;
}
.message-body.streaming { color: var(--text); }
.message.user .message-body { padding: 12px 16px; background: var(--panel); border: 0; border-radius: 2px; }
/* 紧凑密度仅收紧段间距，不降低正文和代码字号。 */
body[data-density="compact"] .message { margin-bottom: 24px; }
body[data-density="compact"] .message-body { font-size: 17px; line-height: 1.8; }
body[data-density="compact"] .message-label { margin-bottom: 4px; }

/* Markdown：按语义排版，兼容上游 md-h 类和原生 h1–h3 标签。 */
.message-body p { margin: 0 0 16px; }
.message-body > p { margin: 0 0 16px; }
.message-body > :last-child, .message-body li > :last-child { margin-bottom: 0; }
.message-body > .md-h, .message-body h1, .message-body h2, .message-body h3 {
  margin: 24px 0 12px; font-weight: 600; line-height: 1.5;
  letter-spacing: .015em; color: var(--text); overflow-wrap: anywhere;
}
.message-body > .md-h1, .message-body h1 { font-size: 24px; }
.message-body > .md-h2, .message-body h2 { font-size: 20px; }
.message-body > .md-h3, .message-body h3 { font-size: 17px; color: var(--text); font-weight: 600; }
.message-body > .md-h:first-child, .message-body > :is(h1, h2, h3):first-child { margin-top: 0; }
.message-body > .md-list, .message-body ul, .message-body ol { margin: 0 0 16px; padding-left: 24px; }
.message-body > .md-list li, .message-body li { margin: 4px 0; padding-left: 4px; }
.message-body li > :is(ul, ol) { margin-top: 8px; margin-bottom: 8px; }
.message-body li > p { margin-bottom: 8px; }
.message-body > blockquote, .message-body blockquote {
  margin: 16px 0; padding: 0 0 0 16px;
  border-left: 2px solid var(--border); color: var(--muted);
}
.message-body > blockquote p, .message-body blockquote p { margin: 0 0 8px; }
.message-body > blockquote p:last-child { margin-bottom: 0; }
.message-body > hr { margin: 24px 0; border: 0; border-top: 1px solid var(--border); }
.message-body strong { color: var(--text); font-weight: 700; }
.message-body em { color: var(--text); }
.message-body a, .message-body .md-link {
  color: var(--accent); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.message-body a:hover, .message-body .md-link:hover { color: var(--accent-2); text-decoration-thickness: 2px; }
.message-body pre, .message-body code, .event-card pre, .approval-copy pre,
.activity-entry pre, .command-item strong, #active-workspace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px; line-height: 1.7; letter-spacing: 0;
  font-variant-ligatures: none; tab-size: 4;
}
.message-body code.md-inline, .message-body :not(pre) > code {
  padding: 0 4px; font-size: 15px; line-height: inherit;
  color: var(--text); background: var(--panel-2); border: 0; border-radius: 2px;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  overflow-wrap: anywhere;
}
.message-body .md-code-block { margin: 16px 0 24px; background: var(--panel); border: 1px solid var(--border); border-radius: 2px; }
.message-body .md-code-lang { padding: 4px 16px; font-size: 12px; line-height: 1.6; font-weight: 400; letter-spacing: .025em; color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--border); }
.message-body pre, .event-card pre, .approval-copy pre {
  max-width: 100%; margin: 16px 0; padding: 16px;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 2px;
  white-space: pre; overflow-wrap: normal; word-break: normal; overflow: auto;
  overscroll-behavior-x: contain;
}
.message-body .md-code-block pre { margin: 0; border: 0; border-radius: 0; }
.message-body pre code { padding: 0; border: 0; background: none; color: var(--text); font-size: 15px; white-space: inherit; }
.message-body table { display: block; max-width: 100%; margin: 16px 0 24px; overflow-x: auto; border-collapse: collapse; font-size: 15px; line-height: 1.8; }
.message-body th, .message-body td { padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
.message-body th { background: var(--panel); font-weight: 600; }
.message-body img { max-width: 100%; height: auto; }
.message-image-link { max-width: min(100%, 560px); margin: 16px 0; background: var(--panel); border-color: var(--border); }
.message-image-link:hover { border-color: var(--accent); }
.message-image { max-height: min(70vh, 520px); }

/* 工具与进度属于次级叙事，左边缘对齐正文而非头像。 */
.event-card, .progress-card { margin: 0 0 24px 56px; max-width: none; color: var(--muted); background: var(--panel); border: 0; font-size: 14px; line-height: 1.6; }
.event-card { padding: 12px 16px; }
.event-card strong, .progress-card summary { color: var(--muted); font-weight: 500; }
.event-card pre, .approval-copy pre { margin: 8px 0 0; padding: 12px; }
.progress-card summary { padding: 12px 16px; font-size: 14px; }
.progress-card[open] summary { color: var(--text); border-bottom: 1px solid var(--border); }
.progress-updates { padding: 0 16px; }
.progress-update { padding: 12px 0; border-bottom: 1px solid var(--border); line-height: 1.8; }
.progress-update > p { margin: 0 0 8px; }
.jump-latest { padding: 8px 16px; font-size: 13px; line-height: 1.6; color: var(--text); background: var(--bg); border: 1px solid var(--border); box-shadow: none; }
.jump-latest:hover { color: var(--accent); background: var(--panel); border-color: var(--accent); }

/* 活动栏：条目左边框首尾相接，竖线随内容滚动且节点不越过裁切边界。 */
.activity-rail { width: min(360px, 100%); background: var(--panel); box-shadow: none; }
.workspace.activity-open .conversation { width: calc(100% - min(360px, 100%)); }
/* LOCAL PATCH (activity-wide): 展开档。命令行输出/补丁这类条目在 360px 里
   只能横向滚，展开到 760px（且不超过 62vw）一次看全。conversation 同步让位，
   两条宽度必须一起改，否则消息区会被压在面板底下。 */
.workspace.activity-wide .activity-rail { width: min(760px, 62vw); }
.workspace.activity-wide.activity-open .conversation { width: calc(100% - min(760px, 62vw)); }
.workspace.activity-wide.activity-open .jump-latest { margin-right: min(400px, 34vw); }
.activity-header-actions { display: flex; align-items: center; gap: 2px; }
.activity-header-actions .icon-button { font-size: 20px; }
.workspace.activity-open .jump-latest { margin-right: 180px; }
.activity-header { min-height: 72px; padding: 16px; }
.activity-header .eyebrow { margin: 0 0 4px; font-size: 12px; }
.activity-header strong { font-size: 15px; font-weight: 600; }
.activity-header .icon-button { width: 40px; height: 40px; font-size: 24px; }
.activity-state { grid-template-columns: 8px minmax(0, 1fr); gap: 8px; padding: 12px 16px; color: var(--muted); background: none; font-size: 13px; line-height: 1.6; }
.activity-state strong { font-weight: 500; }
.activity-state #token-usage { color: var(--muted); font-size: 12px; }
.plan-panel { flex-shrink: 0; max-height: 40%; overflow-y: auto; padding: 16px; background: none; }
.plan-panel h2, .activity-feed-wrap h2 { margin: 0 0 12px; font-size: 12px; line-height: 1.6; font-weight: 500; letter-spacing: .05em; color: var(--muted); }
.plan-panel > p { margin: 0 0 12px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.plan-panel ol { gap: 8px; }
.plan-step { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 8px; color: var(--muted); background: none; border: 0; }
.plan-marker { width: 24px; height: 24px; font-size: 12px; line-height: 1; font-weight: 500; color: var(--muted); border-color: var(--border); }
.plan-copy { gap: 4px; }
.plan-copy strong { font-size: 14px; line-height: 1.6; font-weight: 400; }
.plan-copy small { font-size: 12px; line-height: 1.6; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.plan-step.in-progress { color: var(--text); background: var(--panel-2); border-color: var(--border); box-shadow: none; }
.plan-step.in-progress .plan-marker { color: var(--accent); background: var(--bg); border-color: var(--accent); }
.plan-step.completed { color: var(--muted); background: none; }
.plan-step.completed .plan-marker { color: var(--green); background: none; border-color: var(--green); }
.plan-step.completed .plan-copy small { color: var(--muted); }
.activity-feed-wrap { padding: 16px; }
.activity-feed { padding: 0 8px 8px; }
.activity-empty { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.activity-entry { margin: 0; padding: 0 0 24px 16px; background: none; border: 0; border-left: 1px solid var(--border); border-radius: 0; }
.activity-entry:last-child { padding-bottom: 16px; }
.activity-entry::before { top: 8px; left: -4px; width: 8px; height: 8px; background: var(--muted); box-shadow: 0 0 0 2px var(--panel); }
.activity-entry.running::before { background: var(--green); box-shadow: 0 0 0 2px var(--panel); }
.activity-entry.done::before { background: var(--green); }
.activity-entry.error::before { background: var(--red); }
.activity-entry header { align-items: baseline; gap: 8px; }
.activity-entry strong { color: var(--text); font-size: 14px; line-height: 1.6; font-weight: 500; }
.activity-entry time { color: var(--muted); font-size: 12px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.activity-entry p, .activity-entry pre { max-height: 240px; margin: 8px 0 0; color: var(--muted); }
.activity-entry p, .activity-entry.reasoning p { font-family: inherit; font-size: 13px; line-height: 1.8; color: var(--muted); }
.activity-entry pre { font-size: 15px; line-height: 1.7; white-space: pre; overflow-wrap: normal; }
/* 输入中没有 activity-images 类：通过真实活动条目中的图片元素定位。 */
.activity-entry a:has(img) { display: inline-block; width: 160px; height: 120px; max-width: 100%; margin-top: 8px; overflow: hidden; vertical-align: top; background: var(--panel-2); border-radius: 2px; }
.activity-entry img { display: block; width: 160px; height: 120px; max-width: 100%; object-fit: cover; border-radius: 2px; }
.activity-entry a:has(img):hover { outline: 1px solid var(--accent); outline-offset: 2px; }

/* 输入区只保留一个边框；焦点轮廓与键盘焦点同时可见。 */
.composer-wrap { padding: 16px var(--chat-pad-x) max(16px, env(safe-area-inset-bottom)); border-top: 0; }
.composer { padding: 12px 16px; background: var(--bg); border: 1px solid var(--border); box-shadow: none; }
.composer:focus-within { border-color: var(--muted); }
.composer.drag { border-color: var(--accent); }
.composer-top { gap: 8px; }
.attach-button { width: 36px; height: 36px; margin-top: 0; font-size: 20px; }
.composer textarea { min-height: 48px; padding: 4px 8px 12px; font-size: 17px; line-height: 1.8; }
.composer textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.composer-footer { gap: 12px; padding-top: 8px; }
.composer-settings { flex: 1; gap: 12px; }
.composer-settings select { min-width: 0; max-width: 192px; min-height: 36px; padding: 4px 8px; font-size: 14px; line-height: 1.6; border-color: var(--border); }
#active-workspace { min-width: 0; max-width: 240px; color: var(--muted); font-size: 12px; }
.send-button { flex: 0 0 40px; width: 40px; height: 40px; color: var(--bg); background: var(--text); font-size: 20px; font-weight: 600; }
.send-button:hover:not(:disabled) { background: var(--accent); }
.attach-chip { padding: 8px; gap: 8px; font-size: 13px; background: var(--panel); }
.attach-chip img { width: 48px; height: 48px; }
.attach-chip button { min-width: 28px; min-height: 28px; padding: 4px; font-size: 17px; }
.command-menu { background: var(--panel); box-shadow: none; }
.command-item { grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 12px 16px; }
.command-item strong { font-size: 14px; color: var(--accent); }
.command-item span { font-size: 13px; line-height: 1.6; }
.command-item:hover, .command-item.active { background: var(--panel-2); }
.command-item.unavailable { opacity: .5; cursor: not-allowed; }
.message-queue, .queue-choice { max-width: 100%; padding: 8px 12px; font-size: 13px; line-height: 1.6; }
.queue-choice { flex-wrap: wrap; }
.queue-choice span { flex-basis: 100%; }
.queued-message { gap: 8px; padding: 4px 8px; }

/* 审批、设置与文件浏览继续使用原节点，统一表单与次级信息。 */
.approval-drawer { grid-template-columns: 32px minmax(0, 1fr); gap: 16px; padding: 16px; background: var(--panel); border: 1px solid var(--border); box-shadow: none; }
.approval-icon { width: 32px; height: 32px; color: var(--bg); background: var(--text); }
.approval-copy { min-width: 0; }
.approval-copy strong { font-size: 17px; font-weight: 600; }
.approval-copy p { margin: 8px 0; font-size: 14px; line-height: 1.8; color: var(--muted); }
.approval-copy details { font-size: 13px; line-height: 1.6; }
.approval-copy summary { cursor: pointer; }
.approval-actions { grid-column: 2; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.primary, .secondary, .danger { min-height: 40px; padding: 8px 16px; font-size: 14px; line-height: 1.6; font-weight: 500; }
.primary { color: var(--bg); background: var(--text); border-color: var(--text); }
.primary:hover:not(:disabled) { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.secondary { color: var(--text); background: var(--bg); border-color: var(--border); }
.secondary:hover:not(:disabled) { background: var(--panel-2); border-color: var(--muted); }
.danger { color: var(--red); background: var(--bg); border-color: var(--red); }
.danger:hover:not(:disabled) { color: var(--red); background: var(--panel-2); }
.danger.subtle { padding: 8px 12px; }
.tip-modal, .prefs-modal { padding: 16px; background: color-mix(in srgb, var(--bg) 85%, var(--text) 15%); backdrop-filter: none; }
.tip-dialog, .prefs-dialog { padding: 24px; color: var(--text); background: var(--panel); border: 1px solid var(--border); box-shadow: none; }
.tip-close, .prefs-close { top: 12px; right: 12px; }
.tip-icon { width: 48px; height: 48px; margin-bottom: 16px; color: var(--accent); background: var(--panel-2); border-color: var(--border); }
.tip-dialog h2, .prefs-dialog h2 { margin: 0 32px 8px 0; font-size: 20px; line-height: 1.5; font-weight: 600; }
.tip-dialog > p, .prefs-lede { margin: 0 0 16px; font-size: 14px; line-height: 1.8; }
.tip-amounts button { min-height: 56px; padding: 8px; }
.tip-amounts button span { margin-top: 4px; font-size: 12px; }
.tip-amounts button:hover { border-color: var(--accent); }
.tip-custom-link { margin-top: 0; padding: 8px 12px; font-size: 14px; }
.tip-custom-link:hover { background: var(--panel-2); }
.tip-dialog .tip-fine { margin: 12px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.prefs-section { margin-bottom: 24px; padding: 16px 0 0; border: 0; border-top: 1px solid var(--border); background: none; }
.prefs-section h3 { margin: 0 0 16px; font-size: 17px; font-weight: 600; }
.prefs-section h3 small, .prefs-field span small { font-size: 12px; font-weight: 400; }
.prefs-section h4 { margin: 16px 0 8px; font-size: 14px; }
.prefs-field { gap: 8px; margin-bottom: 16px; }
.prefs-field span { font-size: 13px; font-weight: 400; }
.prefs-field input, .prefs-field select, .prefs-field textarea { min-height: 44px; padding: 8px 12px; font-size: 15px; border-radius: 2px; }
.prefs-field textarea { line-height: 1.8; }
.prefs-check { margin: 8px 0; font-size: 14px; line-height: 1.8; }
.prefs-check input { margin-top: 8px; }
.prefs-row { gap: 16px; }
.prefs-actions { gap: 8px; }
.prefs-actions button { min-height: 40px; font-size: 13px; padding: 8px; }
.prefs-hint, .prefs-amt-status { font-size: 13px; line-height: 1.8; }
.prefs-hint { margin: 0 0 12px; }
.prefs-amt-status { margin: 12px 0; padding: 12px; }
.prefs-amt-status.ok { border-color: var(--green); }
.prefs-tools-list { gap: 8px; }
.prefs-tool { padding: 8px 12px; font-size: 13px; }
.prefs-tool .tier { padding: 0 8px; font-size: 12px; }
.prefs-footer .primary { min-height: 44px; }
.gallery-toolbar { flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }
.gallery-toolbar select { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.gallery-meta { padding: 12px; }
.gallery-name { font-size: 14px; }
.gallery-detail { margin: 4px 0 8px; font-size: 12px; }
.gallery-actions { gap: 8px; }
.gallery-actions a { font-size: 13px; text-underline-offset: 4px; }
.gallery-actions a:hover { text-decoration: underline; }
.fs-crumbs, .fs-scope { display: flex; flex-wrap: wrap; gap: 4px; }
.fs-crumbs button, .fs-scope-btn { min-height: 36px; padding: 4px 8px; font-size: 14px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); }
.fs-drop { padding: 8px 12px; color: var(--muted); font-size: 13px; background: var(--panel); border: 1px dashed var(--border); }
.fs-list button { min-height: 32px; }
.fs-preview { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.fs-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; overflow-wrap: anywhere; }
#fs-preview-img { display: block; max-width: 100%; max-height: 60vh; margin: 12px auto 0; object-fit: contain; }
.toast { padding: 12px 16px; color: var(--text); background: var(--panel); border: 1px solid var(--border); box-shadow: none; font-size: 14px; line-height: 1.6; }
.toast.error { border-color: var(--red); }

/* 登录相关类在上游 CSS 中存在，共用色彩与表单规范。 */
.login-page { padding: 24px; background: var(--bg); }
.login-card { width: min(420px, 100%); padding: 32px; background: var(--panel); box-shadow: none; }
.login-card .brand-mark { margin-bottom: 24px; color: var(--bg); background: var(--text); border-radius: 2px; box-shadow: none; }
.login-card h1 { margin: 8px 0 16px; font-size: 24px; line-height: 1.5; letter-spacing: .015em; }
.login-card form { margin-top: 24px; }
.login-card label { margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.login-card input { min-height: 48px; font-size: 17px; background: var(--bg); border-color: var(--border); border-radius: 2px; }
.secure-note { margin: 24px 0 0; color: var(--muted); font-size: 13px; }
.error { font-size: 13px; }

/* 中等屏幕以覆盖式活动栏保住阅读宽度，移动端恢复单列与安全区。 */
@media (min-width: 761px) and (max-width: 1199px) {
  .activity-rail { width: 360px; }
  /* 覆盖式布局里消息区始终占满，展开只加宽浮层本身 */
  .workspace.activity-wide .activity-rail { width: min(560px, 86vw); }
  .workspace.activity-open .conversation { width: 100%; }
  .workspace.activity-open .jump-latest { margin-right: 0; }
  .status-pill { display: none; }
}
@media (max-width: 760px) {
  :root { --chat-max: calc(100% - 32px); --chat-pad-x: max(16px, env(safe-area-inset-left)); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { width: min(320px, 92vw); padding: max(24px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); box-shadow: none; }
  /* 手机侧栏只有 ~288px 内容宽，三格均分会把 Settings 挤断，恢复按内容撑开 */
  .sidebar-footer-actions .text-button { flex: 0 0 auto; padding: 6px 8px; }
  .topbar { min-height: calc(64px + env(safe-area-inset-top)); gap: 8px; padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
  .topbar > .mobile-only { flex-basis: 40px; width: 40px; height: 44px; font-size: 20px; }
  .thread-meta strong { font-size: 14px; }
  .thread-meta > span { max-width: 44vw; font-size: 12px; }
  .usage-chip { font-size: 12px; }
  .top-actions { gap: 8px; }
  .activity-toggle { min-width: 40px; min-height: 40px; padding: 8px; gap: 4px; font-size: 0; }
  .activity-toggle::after { font-size: 20px; }
  .danger.subtle { min-height: 40px; padding: 8px; }
  .empty-state { padding: 24px 16px; }
  .empty-state h1 { font-size: 24px; }
  .empty-state > p:not(.eyebrow) { font-size: 15px; line-height: 1.8; }
  .workspace-picker { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 24px; }
  .workspace-picker > span:first-child { flex-basis: 100%; }
  .workspace-picker select { width: auto; }
  .conversation { padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
  .message { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; margin-bottom: 32px; }
  .message.user .message-body { padding: 8px 12px; }
  .event-card, .progress-card { margin-left: 52px; }
  .message-body pre, .event-card pre, .approval-copy pre { padding: 12px; }
  .composer-wrap { padding: 12px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .composer { padding: 12px; }
  .composer-settings { max-width: calc(100% - 52px); }
  .composer-settings select { max-width: 100%; min-height: 40px; font-size: 17px; }
  .activity-rail { width: 100%; }
  #expand-activity { display: none; }
  .workspace.activity-open .conversation { width: 100%; }
  .workspace.activity-open .jump-latest { margin-right: 0; }
  .activity-entry p, .activity-entry pre { max-height: 34dvh; }
  .approval-drawer { grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 16px; }
  .approval-actions { grid-column: 1 / -1; }
  .approval-actions button { min-width: 88px; min-height: 48px; font-weight: 500; }
  .prefs-modal, .tip-modal { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .prefs-dialog, .tip-dialog { padding: 24px 16px; }
  .prefs-field select, .prefs-field input, .prefs-field textarea,
  .session-search input, .workspace-picker select { font-size: 17px; }
  .login-card { padding: 24px; }
}
@media (max-width: 560px) {
  .prefs-row, .prefs-actions { grid-template-columns: 1fr; }
  .usage-strip { gap: 8px; }
  .usage-chip { padding: 0; }
  .command-item { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
@media (max-width: 390px) {
  .thread-meta > span { max-width: 36vw; }
  .activity-toggle { padding: 8px; }
  .empty-badges { margin-bottom: 0; }
}
@media (max-height: 620px) and (max-width: 760px) {
  .empty-state { justify-content: flex-start; padding-top: 16px; }
  .workspace-picker { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* ══════════════════════════════════════════════════════════════════
 * 客户端化：去掉冗余控件
 *
 * 按需求移除，全部只隐藏、不删节点（功能与逻辑保留，随时可放回）：
 *   #refresh-threads   手动刷新。列表由 SSE 事件驱动自动更新，桌面客户端
 *                      也没有这个按钮。
 *   #permission-pill   权限档位展示（Restrictive / Moderate / YOLO）。
 *                      它本来就是纯展示的 <span>，不可点；改档位在 Settings
 *                      里，所以隐藏不丢功能。
 *   #fleet-strip       "0 working / 0 need input / 1 idle" 计数条。
 *                      信息在别处已有：正在工作的会话行上有旋转指示器，
 *                      等待审批会直接弹出抽屉，运行状态顶栏也有。
 * 注意必须排在 .fleet-chip 等字号规则之后才盖得住。
 * ══════════════════════════════════════════════════════════════════ */
#refresh-threads, #permission-pill, .fleet-strip { display: none !important; }

/* 推理档位下拉：空值时 effort=null，app-server 用的就是它自己的配置默认
   （model_reasoning_effort），所以 "Default reasoning" 这个选项描述的是
   已经生效的状态 —— 纯冗余。让它只在真的选了非默认档位时出现，那时它才
   在告诉你"本条消息会覆盖默认"。默认档位在 Settings 里设，功能不丢。
   :has() 选择器不认识的旧浏览器会整条丢弃，退化为"一直显示"，可接受。 */
.composer-settings select#effort:has(> option[value=""]:checked) { display: none; }
/* 归档切换按钮成了 .thread-heading-actions 里唯一的控件，右对齐即可 */
.thread-heading { justify-content: space-between; }

/* ══════════════════════════════════════════════════════════════════
 * 客户端化：线程行精简
 *
 * 按需求去掉两个行内控件：
 *   .thread-act.cli  「>」复制 codex resume 命令（CLI 对照入口已一并隐藏）
 *   .pin-btn         置顶星标（它是 <span>，不是 <button>）
 * 用 display:none 而非改 JS：节点与逻辑都保留，随时可以放回来。
 * 注意必须排在上面 .thread-item span 那条字号规则之后，否则会被它盖掉。
 * ══════════════════════════════════════════════════════════════════ */
.thread-item .pin-btn,
.thread-act.cli { display: none !important; }

/* 剩下的三个操作按钮（重命名 / 归档 / 删除）平时淡出，悬停或聚焦才显形，
   让线程行安静下来 —— 桌面客户端的列表里没有常驻图标。 */
.thread-act {
  min-width: 30px; min-height: 30px; padding: 3px 5px;
  font-size: 14px; line-height: 1;
  color: var(--muted); background: transparent; border: 0; border-radius: 2px;
  opacity: 0; transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.thread-item:hover .thread-act, .thread-act:focus-visible { opacity: 1; }
.thread-act:hover { color: var(--text); background: var(--panel-3); }
.thread-act.danger:hover { color: var(--red); }
/* 触屏没有 hover，常驻会点不到，这里一律显形 */
@media (hover: none) { .thread-act { opacity: .7; } }

/* 标题单行截断，路径退到第二行；没有星标和 CLI 后行高更紧 */
.thread-item .item-row strong {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-item { padding: 10px 12px; }
.thread-item span { margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════
 * Files 面板
 *
 * 面板的行样式原本只在我早期的 fs 补丁里写了最基础的一版（flex + 分隔线），
 * 工具栏里面包屑、筛选下拉、作用域切换、上传、刷新五组控件挤在一行，
 * 宽窄屏都容易错位。这里按「路径在上、操作在下」重排成两段。
 * ══════════════════════════════════════════════════════════════════ */
.gallery-dialog { width: min(960px, 100%); }
.fs-list {
  display: flex; flex-direction: column; min-height: 180px; max-height: 56vh;
  overflow-y: auto; border: 1px solid var(--border); border-radius: 2px;
}
.fs-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 16px; min-height: 44px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
.fs-row:last-child { border-bottom: 0; }
.fs-name { min-width: 0; text-align: left; }
.fs-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-meta { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 操作按钮平时不占注意力，悬停行或聚焦时才显形 */
.fs-acts { opacity: 0; transition: opacity .12s ease; }
.fs-row:hover .fs-acts, .fs-acts:focus-within { opacity: 1; }
@media (hover: none) { .fs-acts { opacity: 1; } }

/* 工具栏：面包屑独占一行，其余控件靠右成组 */
.gallery-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.fs-crumbs {
  flex: 1 1 100%; order: -1; min-width: 0;
  overflow-x: auto; white-space: nowrap; scrollbar-width: thin;
}
.fs-scope { flex: 0 0 auto; margin-left: auto; }
.fs-drop { border-style: dashed; }
.fs-preview img { border: 1px solid var(--border); }

/* ★ 选中态必须显式设 background。上游是
   `.fs-scope-btn.on { background: var(--accent); color: #fff }`，
   而生成器把 #fff 映射成了 #fafafa —— 绿底留在自动段，
   若这里只改 color 不改 background，就会绿字配绿底、文字彻底看不见。 */
.fs-scope-btn.on {
  color: var(--accent); background: var(--panel-2);
  border-color: var(--accent); font-weight: 600;
}
.fs-scope-btn:not(.on):hover { background: var(--panel-2); color: var(--text); }

/* 元数据列靠右贴齐并限宽，否则和文件名之间拉出一条大空档 */
.fs-row { grid-template-columns: minmax(0, 1fr) max-content max-content; gap: 12px; }
.fs-meta { text-align: right; padding-right: 4px; }
/* 操作按钮：下载是 <a>、删除是 <button>，只写 .fs-act 的话浏览器默认样式
   会让两者宽高不同（实测 28.3 vs 46px）。显式限定标签并统一。 */
.fs-acts { gap: 4px; }
a.fs-act, button.fs-act {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  width: 30px; min-width: 30px; height: 30px; min-height: 30px;
  margin: 0; padding: 0;
  font: inherit; font-size: 15px; line-height: 1;
  color: var(--muted); text-decoration: none;
  background: transparent; border: 1px solid transparent; border-radius: 2px;
  cursor: pointer;
}
a.fs-act:hover, button.fs-act:hover { color: var(--text); background: var(--panel-3); border-color: var(--border); }
.fs-act.danger:hover { color: var(--red); border-color: var(--red); background: transparent; }

/* 就地改名的输入框：要看起来像标题本身在编辑，而不是贴了个表单控件 */
.thread-rename-input {
  flex: 1 1 auto; min-width: 0; width: 100%;
  padding: 0; color: var(--text); background: var(--panel-3);
  font: inherit; font-weight: 500; line-height: inherit;
  border: 0; border-bottom: 1px solid var(--accent); border-radius: 0;
  box-shadow: none; outline: none;
}

/* 重命名不再有独立按钮（改点名称，见 rename-inline 补丁）*/
.thread-act.rename { display: none !important; }
/* 点已打开会话的名称可改名，给个「这里可以编辑」的暗示；
   但不能做下划线常显，否则整栏都是线，比按钮还吵 */
.thread-item .thread-title { cursor: pointer; text-underline-offset: 3px; }
.thread-item:hover .thread-title { text-decoration: underline dotted; text-decoration-color: var(--border); }

/* ══════════════════════════════════════════════════════════════════
 * 截图复核后的修正（这批只能靠眼睛发现）
 * ══════════════════════════════════════════════════════════════════ */

/* 1. 「点击登出」原本常驻，状态条右边一直挂着这行字，像坏掉的提示。
      改成悬停/聚焦才显形。 */
.connection::after { opacity: 0; transition: opacity .15s ease; }
.connection:hover::after, .connection:focus-visible::after { opacity: 1; }

/* 2. 发送按钮：桌面客户端是圆形，这里是 2px 圆角方块。
      必须同时压过上面那条把 .send-button 列进「圆角归 2px」的批量规则，
      所以用 !important —— 那是唯一一处需要破例的地方。 */
.send-button {
  border-radius: 50% !important;
  display: inline-flex; align-items: center; justify-content: center;
}

/* 3. 用户消息去掉气泡底色。客户端里两侧都是纯文本，靠头像与标签区分；
      只给用户侧加灰底会让两条消息视觉权重不等，反而更乱。 */
.message.user .message-body {
  padding: 0; background: none; border: 0; border-radius: 0;
  box-shadow: none;
}

/* 4. Timeline 空状态那句太长且是斜体，占了三行还显得像报错。 */
.activity-empty { font-style: normal; font-size: 13px; line-height: 1.7; }

/* ── Timeline 里的生成图片 ──
   .activity-images 由 timeline-image 补丁用 JS 创建，上游 CSS 没有它，
   不写就会拿原图铺满抽屉。 */
.activity-images { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 8px; }
.activity-images a {
  display: block; width: 160px; flex: 0 0 auto; overflow: hidden;
  border: 1px solid var(--border); border-radius: 2px; background: var(--panel-2);
  transition: border-color .15s ease;
}
.activity-images a:hover { border-color: var(--accent); }
/* cover 会裁掉方图边缘，但缩略图只求"认出是哪张"，点开是新标签页看原图 */
.activity-images img { display: block; width: 100%; height: 120px; object-fit: cover; }
.activity-img-name {
  flex: 1 1 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
