/*
 * 远程 Claude 控制台 —— 按 Claude Desktop(claude.ai 设计系统 CDS,fizzy-lake color 外观)复刻。
 * 颜色、尺寸取自 claude.ai 公开样式表里的设计令牌:
 *   侧栏 288px / 行高 26px / 行字号 13px / 分组字号 12px / 页眉 48px / 对话列 48rem
 *   浅色:正文区 #fff、侧栏 #fafafa、文字 #000 90%/60%/47%、主按钮 #191919
 *   深色:正文区 #191919、侧栏 #1f1f1f、浮层 #303030、文字 #fff 93%/57%/40%
 * Anthropic 的专有字体不随附,用系统字体回退。
 */
:root {
  color-scheme: light;
  --page: #ffffff;
  --sidebar: #fafafa;
  --surface-3: #ffffff;
  --popover: #ffffff;
  --seam: rgba(0, 0, 0, 0.1);
  --border: rgba(0, 0, 0, 0.08);
  --border-line: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.2);
  --text: rgba(0, 0, 0, 0.9);
  --text-2: rgba(0, 0, 0, 0.6);
  --text-3: rgba(0, 0, 0, 0.467);
  --ghost-hover: rgba(0, 0, 0, 0.05);
  --ghost-selected: rgba(0, 0, 0, 0.1);
  --selected-hover: rgba(0, 0, 0, 0.145);
  --fill-primary: #191919;
  --fill-primary-hover: #3c3c3c;
  --on-primary: #ffffff;
  --fill-secondary: rgba(0, 0, 0, 0.05);
  --fill-secondary-hover: rgba(0, 0, 0, 0.075);
  --alpha-1: rgba(0, 0, 0, 0.05);
  --alpha-2: rgba(0, 0, 0, 0.1);
  --composer-ring: rgba(0, 0, 0, 0.12);
  --user-bubble: rgba(0, 0, 0, 0.05);
  --code-bg: rgba(0, 0, 0, 0.03);
  --code-head: rgba(0, 0, 0, 0.04);
  --text-accent: #1757ac;
  --clay: #d97757;
  --clay-emph: #c6613f;
  --danger: #dc3c3d;
  --text-danger: #a42528;
  --bg-danger: rgba(220, 60, 61, 0.12);
  --text-success: #006c10;
  --bg-success: rgba(16, 161, 34, 0.14);
  --success: #10a122;
  --warning: #e2a113;
  --text-warning: #794c02;
  --bg-warning: rgba(251, 179, 21, 0.16);
  --new-circle: #e9e9e9;
  --seg-track: rgba(0, 0, 0, 0.05);
  --seg-thumb: #ffffff;
  --seg-thumb-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.06);
  --avatar: #3a3a3a;
  --shadow-popover: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-composer: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.035);
  --shadow-composer-focus: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.075);
  --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 24px rgba(0, 0, 0, 0.06);
  --diff-del: rgba(220, 60, 61, 0.08);
  --diff-add: rgba(16, 161, 34, 0.08);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-response: var(--font-serif);

  --sidebar-w: 288px;
  --header-h: 48px;
  --row-h: 26px;
  --row-font: 13px;
  --group-font: 12px;
  --radius-pill: 6px;
  --column: calc(48rem + 1.5rem);
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
}
:root[data-font="sans"] { --font-response: var(--font-ui); }

@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    color-scheme: dark;
    --page: #191919;
    --sidebar: #1f1f1f;
    --surface-3: #1f1f1f;
    --popover: #303030;
    --seam: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.06);
    --border-line: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.2);
    --text: rgba(255, 255, 255, 0.93);
    --text-2: rgba(255, 255, 255, 0.57);
    --text-3: rgba(255, 255, 255, 0.4);
    --ghost-hover: rgba(255, 255, 255, 0.075);
    --ghost-selected: rgba(255, 255, 255, 0.15);
    --selected-hover: rgba(255, 255, 255, 0.216);
    --fill-primary: #efefef;
    --fill-primary-hover: #d7d7d7;
    --on-primary: #191919;
    --fill-secondary: rgba(255, 255, 255, 0.15);
    --fill-secondary-hover: rgba(255, 255, 255, 0.216);
    --alpha-1: rgba(255, 255, 255, 0.05);
    --alpha-2: rgba(255, 255, 255, 0.1);
    --composer-ring: rgba(255, 255, 255, 0.08);
    --user-bubble: rgba(255, 255, 255, 0.07);
    --code-bg: rgba(255, 255, 255, 0.035);
    --code-head: rgba(255, 255, 255, 0.05);
    --text-accent: #6aabf1;
    --text-danger: #f17778;
    --bg-danger: rgba(220, 60, 61, 0.14);
    --text-success: #53c556;
    --bg-success: rgba(16, 161, 34, 0.14);
    --text-warning: #e49c06;
    --bg-warning: rgba(251, 179, 21, 0.1);
    --new-circle: #2e2e2e;
    --seg-track: rgba(255, 255, 255, 0.06);
    --seg-thumb: rgba(255, 255, 255, 0.12);
    --seg-thumb-shadow: none;
    --avatar: #d9d9d9;
    --shadow-popover: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.2);
    --shadow-composer: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.2);
    --shadow-composer-focus: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.3);
    --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 24px rgba(0, 0, 0, 0.3);
    --diff-del: rgba(220, 60, 61, 0.14);
    --diff-add: rgba(16, 161, 34, 0.14);
  }
}
:root[data-mode="dark"] {
  color-scheme: dark;
  --page: #191919;
  --sidebar: #1f1f1f;
  --surface-3: #1f1f1f;
  --popover: #303030;
  --seam: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.06);
  --border-line: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: rgba(255, 255, 255, 0.93);
  --text-2: rgba(255, 255, 255, 0.57);
  --text-3: rgba(255, 255, 255, 0.4);
  --ghost-hover: rgba(255, 255, 255, 0.075);
  --ghost-selected: rgba(255, 255, 255, 0.15);
  --selected-hover: rgba(255, 255, 255, 0.216);
  --fill-primary: #efefef;
  --fill-primary-hover: #d7d7d7;
  --on-primary: #191919;
  --fill-secondary: rgba(255, 255, 255, 0.15);
  --fill-secondary-hover: rgba(255, 255, 255, 0.216);
  --alpha-1: rgba(255, 255, 255, 0.05);
  --alpha-2: rgba(255, 255, 255, 0.1);
  --composer-ring: rgba(255, 255, 255, 0.08);
  --user-bubble: rgba(255, 255, 255, 0.07);
  --code-bg: rgba(255, 255, 255, 0.035);
  --code-head: rgba(255, 255, 255, 0.05);
  --text-accent: #6aabf1;
  --text-danger: #f17778;
  --bg-danger: rgba(220, 60, 61, 0.14);
  --text-success: #53c556;
  --bg-success: rgba(16, 161, 34, 0.14);
  --text-warning: #e49c06;
  --bg-warning: rgba(251, 179, 21, 0.1);
  --new-circle: #2e2e2e;
  --seg-track: rgba(255, 255, 255, 0.06);
  --seg-thumb: rgba(255, 255, 255, 0.12);
  --seg-thumb-shadow: none;
  --avatar: #d9d9d9;
  --shadow-popover: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-composer: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.2);
  --shadow-composer-focus: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.3);
  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 24px rgba(0, 0, 0, 0.3);
  --diff-del: rgba(220, 60, 61, 0.14);
  --diff-add: rgba(16, 161, 34, 0.14);
}

/* ── 基础 ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
#root { height: 100%; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; margin: 0; cursor: default; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid color-mix(in srgb, #257de0 60%, transparent); outline-offset: 1px; }
a { color: var(--text-accent); }
.icon { flex: none; display: block; }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
::selection { background: color-mix(in srgb, #257de0 25%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--alpha-2) transparent; }

/* 输入框 */
.field {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--page);
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  width: 100%;
  box-shadow: inset 0 0 0 1px var(--border-line), 0 1px 2px rgba(0, 0, 0, 0.04);
  outline: none;
}
.field::placeholder { color: var(--text-3); }
.field:focus { box-shadow: inset 0 0 0 1px var(--border-strong), 0 0 0 3px color-mix(in srgb, #257de0 18%, transparent); }
.field.lg { font-size: 15px; padding: 10px 12px; border-radius: 10px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.1s, opacity 0.1s;
}
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 40px; font-size: 15px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--fill-primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { background: var(--fill-primary-hover); }
.btn.secondary { background: var(--fill-secondary); }
.btn.secondary:hover:not(:disabled) { background: var(--fill-secondary-hover); }
.btn.ghost { color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--ghost-hover); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #c63637; }
.btn:disabled { opacity: 0.4; }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  flex: none;
  transition: background-color 0.1s, color 0.1s;
}
.icon-btn:hover:not(:disabled), .icon-btn.open { background: var(--ghost-hover); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 6px; }
.text-btn { color: var(--text-accent); font-size: 12px; padding: 0 4px; }
.text-btn:hover { text-decoration: underline; }

/* ── 框架 ─────────────────────────────────────────────────────────────── */
.frame { position: relative; display: flex; height: 100vh; height: 100dvh; overflow: hidden; background: var(--page); }
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 0.5px solid var(--seam);
  user-select: none;
  min-height: 0;
  z-index: 30;
  transition: margin-left 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.frame.collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.scrim { display: none; }
.sidebar-open { display: none; }
.frame.collapsed .sidebar-open { display: inline-flex; }

/* 侧栏:标题行 */
.titlebar { height: var(--header-h); flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 16px; }
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.wordmark { font-family: var(--font-serif); font-size: 20px; letter-spacing: -0.01em; color: var(--text); line-height: 1; }
.brand-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.sidebar-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 4px 8px 0; }
/* 分段切换 */
.pills {
  display: flex;
  height: 28px;
  padding: 1px;
  border-radius: 8px;
  background: var(--seg-track);
  margin: 0 0 10px;
  flex: none;
}
.pill {
  flex: 1 1 0;
  border-radius: 7px;
  font-size: var(--row-font);
  font-weight: 470;
  color: var(--text-3);
  transition: color 0.12s, background-color 0.2s var(--ease-out);
}
.pill:hover:not(.on) { color: var(--text); }
.pill.on { background: var(--seg-thumb); color: var(--text); box-shadow: var(--seg-thumb-shadow); }

/* 侧栏行 */
.nav-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: var(--row-h);
  padding: 0 8px;
  margin-bottom: 2px;
  border-radius: var(--radius-pill);
  font-size: var(--row-font);
  color: var(--text);
  text-align: left;
  transition: background-color 0.08s;
}
.nav-row:hover:not(:disabled) { background: var(--ghost-hover); }
.nav-row.on { background: var(--ghost-selected); }
.nav-row.on:hover { background: var(--selected-hover); }
.nav-row:disabled { opacity: 0.5; }
.nav-row .lead { width: 24px; height: 20px; flex: none; display: flex; align-items: center; justify-content: center; margin-left: -6px; color: var(--text-2); }
.nav-row:hover .lead, .nav-row.on .lead { color: var(--text); }
.row-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 12px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 12px), transparent); padding-right: 6px; }
.row-trail { flex: none; font-size: 12px; color: var(--text-3); }
.new-row { margin-bottom: 6px; }
.new-circle { width: 18px; height: 18px; border-radius: 9999px; background: var(--new-circle); display: inline-flex; align-items: center; justify-content: center; color: var(--text); transition: background-color 0.1s; }
.new-row:hover .new-circle { background: color-mix(in srgb, var(--text-3) 30%, transparent); }
.new-circle .icon { stroke-width: 2.2; }

.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 0 8px 12px; }
.group { margin-top: 12px; }
.group:first-child { margin-top: 2px; }
.group-label { display: flex; align-items: center; height: var(--row-h); margin-bottom: 2px; padding: 0 2px 0 8px; position: relative; border-radius: var(--radius-pill); }
.group-toggle { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; height: 100%; text-align: left; font-size: var(--group-font); font-weight: 500; color: var(--text-2); }
.group-label.static { font-size: var(--group-font); font-weight: 500; color: var(--text-2); }
.group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-caret { opacity: 0; transition: opacity 0.1s; color: var(--text-3); }
.group-label:hover .group-caret { opacity: 1; }
.row-ctl { width: 20px; height: 20px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); opacity: 0; transition: opacity 0.1s; }
.group-label:hover .row-ctl { opacity: 1; }
.row-ctl:hover:not(:disabled) { background: var(--ghost-hover); color: var(--text); }
.side-empty { font-size: 12px; color: var(--text-3); padding: 8px; line-height: 1.6; }

/* 状态标记 */
.status-dot { width: 7px; height: 7px; border-radius: 9999px; flex: none; background: var(--text-3); }
.status-dot.running { background: var(--clay); animation: clay-breathe 2.4s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }
@keyframes clay-breathe {
  0%, 100% { opacity: 0.4; transform: scale(0.7); filter: brightness(0.96); }
  50% { opacity: 1; transform: scale(1); filter: brightness(1.06); }
}
.row-badge { flex: none; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9999px; background: var(--clay-emph); color: #fff; font-size: 10.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }

/* 侧栏底部账户行 */
.sidebar-footer { flex: none; padding: 8px; border-top: 0.5px solid var(--seam); }
.dd.footer-dd { display: flex; width: 100%; }
.user-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px; border-radius: 8px; text-align: left; transition: background-color 0.08s; }
.user-btn:hover, .user-btn.open { background: var(--ghost-hover); }
.avatar { position: relative; width: 28px; height: 28px; border-radius: 9999px; background: var(--avatar); color: var(--page); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.conn-dot { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 9999px; border: 2px solid var(--sidebar); }
.conn-dot.ok { background: var(--success); }
.conn-dot.warn { background: var(--warning); }
.conn-dot.bad { background: var(--danger); }
.user-words { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-size: 13px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-sub { font-size: 12px; color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-caret { color: var(--text-3); }
.user-menu { width: 272px; }
.user-email { padding: 4px 8px 2px; }

/* ── 弹层 ─────────────────────────────────────────────────────────────── */
.dd { position: relative; display: inline-flex; min-width: 0; }
.pop {
  position: absolute;
  z-index: 60;
  min-width: 220px;
  max-width: min(360px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 6px;
  background: var(--popover);
  border-radius: 12px;
  box-shadow: var(--shadow-popover);
  color: var(--text);
  font-size: 13px;
  animation: pop-in 0.14s var(--ease-out);
  user-select: none;
  cursor: default;
}
.pop.up { bottom: calc(100% + 6px); }
.pop.down { top: calc(100% + 6px); }
.pop.left { left: 0; }
.pop.right { right: 0; }
@keyframes pop-in { from { opacity: 0; transform: translateY(var(--pop-from, 4px)) scale(0.98); } to { opacity: 1; transform: none; } }
.pop.down { --pop-from: -4px; }
.pop-section { padding: 8px 8px 4px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.pop-title { padding: 6px 8px 2px; font-size: 14px; font-weight: 600; }
.pop-desc { padding: 0 8px; font-size: 12px; color: var(--text-2); line-height: 1.5; }
.pop-desc.tiny { font-size: 11.5px; color: var(--text-3); }
.pop-note { padding: 8px 8px 4px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.pop-sep { height: 0.5px; background: var(--border-line); margin: 6px -6px; }
.pop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  transition: background-color 0.06s;
}
.pop-item:hover:not(:disabled) { background: var(--ghost-hover); }
.pop-item:disabled { opacity: 0.45; }
.pop-item.danger { color: var(--text-danger); }
.pop-item .icon { color: var(--text-2); }
.pop-item.danger .icon { color: currentColor; }
.pi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pi-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item.two-line .pi-title { font-weight: 500; }
.pi-desc { font-size: 12px; color: var(--text-3); line-height: 1.4; overflow-wrap: anywhere; }
.pop-item .pi-check { color: var(--text); margin-left: auto; }
.pop-scroll { max-height: 280px; overflow-y: auto; }
.pop-search { margin: 2px 0 4px; }
.rot90 { transform: rotate(90deg); }

/* 分段控件 */
.seg-control { display: flex; padding: 2px; margin: 2px 2px 4px; border-radius: 8px; background: var(--seg-track); }
.seg-control .seg { flex: 1 1 0; height: 28px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap; transition: background-color 0.15s, color 0.15s; }
.seg-control .seg:hover:not(.on) { color: var(--text); }
.seg-control .seg.on { background: var(--seg-thumb); color: var(--text); box-shadow: var(--seg-thumb-shadow); font-weight: 500; }
.serif-sample { font-family: var(--font-serif); }
.effort-block { padding-bottom: 2px; }
.effort-ends { display: flex; justify-content: space-between; padding: 0 10px 4px; font-size: 11px; color: var(--text-3); }

/* 开关 */
.switch { appearance: none; -webkit-appearance: none; width: 30px; height: 18px; border-radius: 9999px; background: var(--border-strong); position: relative; flex: none; margin: 0; transition: background-color 0.15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 9999px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.15s var(--ease-out); }
.switch:checked { background: var(--fill-primary); }
.switch:checked::after { transform: translateX(12px); background: var(--page); }

/* 用量表 */
.meter { display: block; height: 6px; margin: 6px 8px; border-radius: 9999px; background: var(--alpha-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--fill-primary); }
.meter i.warn { background: var(--warning); }
.meter i.bad { background: var(--danger); }
.usage-card { width: 300px; }
.usage-row { padding: 6px 0 2px; }
.usage-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 8px; font-size: 13px; }
.usage-line .pop-desc { padding: 0; }

/* 上下文弹层 */
.ctx-pop { width: 300px; }
.model-menu { width: 320px; }
.mode-menu { width: 300px; }
.ctx-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 8px 0; font-size: 13px; }
.ctx-status { font-size: 12px; padding: 1px 8px; border-radius: 9999px; background: var(--bg-success); color: var(--text-success); }
.ctx-status.warn { background: var(--bg-warning); color: var(--text-warning); }
.ctx-status.bad { background: var(--bg-danger); color: var(--text-danger); }
.ctx-status.none { background: var(--alpha-1); color: var(--text-3); }
.ctx-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 4px 8px 2px; }
.ctx-cat { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); gap: 6px; }
.ctx-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-val { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── 主区域 ───────────────────────────────────────────────────────────── */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.pane-header { height: var(--header-h); flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px; position: relative; z-index: 5; }
.hdr-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; padding-left: 4px; }
.hdr-name { font-size: 14px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.hdr-path { font-size: 12px; color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; flex: 1 1 0; direction: rtl; text-align: left; }
.hdr-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.hdr-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); padding: 0 8px; height: 24px; border-radius: 9999px; background: var(--alpha-1); }
.hdr-status.waiting { background: var(--bg-warning); color: var(--text-warning); }
.hdr-status.error { background: var(--bg-danger); color: var(--text-danger); }

.top-banner { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 32px; padding: 6px 12px; font-size: 12.5px; color: var(--text-2); background: var(--alpha-1); border-bottom: 0.5px solid var(--border-line); }
.top-banner.warning { background: var(--bg-warning); color: var(--text-warning); }

.chat-column { width: 100%; max-width: var(--column); margin: 0 auto; padding: 0 12px; }
.transcript { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; scrollbar-gutter: stable both-edges; }
.transcript .chat-column { padding-top: 8px; }
.transcript-end { height: 24px; }

/* 消息 */
.msg-user { display: flex; flex-direction: column; align-items: flex-end; margin: 16px 0 4px; }
.msg-user:first-child { margin-top: 8px; }
.msg-user .bubble {
  max-width: min(85%, 36rem);
  padding: 7px 13px;
  border-radius: 16px;
  background: var(--user-bubble);
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-user.sending .bubble { opacity: 0.6; }
.msg-user.failed .bubble { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 45%, transparent); }
.msg-status { font-size: 12px; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 2px; }
.msg-user.failed .msg-status { color: var(--text-danger); }
.msg-actions { display: flex; align-items: center; gap: 2px; min-height: 22px; opacity: 0; transition: opacity 0.12s; }
.msg-user:hover .msg-actions, .msg-assistant:hover .msg-actions { opacity: 1; }
.msg-time { font-size: 12px; color: var(--text-3); padding: 0 6px; }
.msg-assistant { margin: 2px 0 0; padding-left: 4px; }
.msg-assistant .msg-actions { margin-left: -6px; }
.msg-assistant .msg-actions .icon-btn { color: var(--text-3); }

/* 正文排版(Claude 的回复用 --font-response:衬线西文 + 系统中文) */
.md { font-family: var(--font-response); font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
:root[data-font="sans"] .md { line-height: 1.55; }
.md.plain { white-space: pre-wrap; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.55em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-response); font-weight: 600; line-height: 1.3; margin: 1.3em 0 0.5em; }
.md h1 { font-size: 1.4em; }
.md h2 { font-size: 1.22em; }
.md h3 { font-size: 1.08em; }
.md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 0.75em; padding-left: 1.5em; }
.md li { margin: 0.2em 0; }
.md li > p { margin: 0.2em 0; }
.md blockquote { margin: 0 0 0.75em; padding: 0 0 0 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md hr { border: none; border-top: 0.5px solid var(--border-line); margin: 1.5em 0; }
.md a { color: var(--text-accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: currentColor; }
.md strong { font-weight: 600; }
.md code { font-family: var(--font-mono); font-size: 0.86em; background: var(--alpha-1); border: 0.5px solid var(--border-line); border-radius: 5px; padding: 0.1em 0.35em; }
.md pre code { background: none; border: none; padding: 0; font-size: inherit; border-radius: 0; }
.md table { border-collapse: collapse; margin: 0 0 0.9em; font-family: var(--font-ui); font-size: 13.5px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border-bottom: 0.5px solid var(--border-line); padding: 6px 12px 6px 0; text-align: left; vertical-align: top; }
.md th { font-weight: 600; color: var(--text-2); border-bottom-color: var(--border-strong); }
.md img { max-width: 100%; border-radius: 8px; }
.code-wrap { margin: 0 0 0.9em; border-radius: 10px; background: var(--code-bg); box-shadow: inset 0 0 0 0.5px var(--border-line); overflow: hidden; font-family: var(--font-ui); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 6px 0 12px; font-size: 12px; color: var(--text-3); background: var(--code-head); }
.code-copy { font-size: 12px; color: var(--text-2); padding: 3px 8px; border-radius: 6px; }
.code-copy:hover { background: var(--ghost-hover); color: var(--text); }
.code-wrap pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; }

/* 工具调用 / 思考(紧凑行,可展开) */
.step { margin: 1px 0; }
.step-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 2px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  list-style: none;
  cursor: default;
  user-select: none;
  transition: background-color 0.08s, color 0.08s;
}
.step-row::-webkit-details-marker { display: none; }
summary.step-row:hover { background: var(--ghost-hover); color: var(--text); }
.step-icon { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); }
.step-name { flex: none; font-weight: 500; color: var(--text); }
.step-sum { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-3); font-size: 13px; }
.step-flag { flex: none; font-size: 11.5px; color: var(--text-danger); background: var(--bg-danger); border-radius: 9999px; padding: 0 7px; }
.step-caret { color: var(--text-3); opacity: 0; transition: transform 0.15s var(--ease-out), opacity 0.1s; }
summary.step-row:hover .step-caret { opacity: 1; }
.step[open] > .step-row .step-caret { transform: rotate(90deg); opacity: 1; }
.step.error .step-icon { color: var(--text-danger); }
.step-body { margin: 2px 0 8px 26px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.step-row.static { cursor: default; }
.thinking .step-name { font-weight: 450; color: var(--text-2); }
.thinking-text { white-space: pre-wrap; color: var(--text-2); font-size: 13.5px; line-height: 1.6; padding-left: 12px; border-left: 2px solid var(--border-line); }
.perm-result { flex: none; font-size: 12px; color: var(--text-3); }
.perm-done.allow .perm-result, .perm-done.allow-always .perm-result { color: var(--text-success); }
.perm-done.deny .perm-result { color: var(--text-danger); }

pre.code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--code-bg);
  box-shadow: inset 0 0 0 0.5px var(--border-line);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow: auto;
  color: var(--text);
}
pre.code.result { color: var(--text-2); }
pre.code.err { color: var(--text-danger); }
.diff { display: flex; flex-direction: column; gap: 0; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 0.5px var(--border-line); }
.diff pre.code { border-radius: 0; box-shadow: none; }
pre.code.del { background: var(--diff-del); }
pre.code.add { background: var(--diff-add); }
.kv { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.sub { display: flex; flex-direction: column; gap: 3px; padding-left: 10px; border-left: 2px solid var(--border-line); }
.sub-text { white-space: pre-wrap; color: var(--text-2); }
.sub-tool { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; }
.sub-tool b { color: var(--text-2); font-weight: 500; }
.todos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.todo { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; }
.todo-box { width: 15px; height: 15px; margin-top: 2px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px var(--border-strong); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.todo.completed { color: var(--text-3); text-decoration: line-through; }
.todo.completed .todo-box { background: var(--fill-primary); color: var(--on-primary); box-shadow: none; }
.todo.in_progress { font-weight: 500; }
.todo.in_progress .todo-box { box-shadow: inset 0 0 0 1.5px var(--clay); }

/* 轮次用量、提示 */
.turn-usage { margin: 0 0 2px; }
.turn-usage-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); padding: 2px 6px; margin-left: -6px; border-radius: 6px; }
.turn-usage-btn:hover { background: var(--ghost-hover); color: var(--text-2); }
.turn-usage.err .turn-usage-btn { color: var(--text-danger); }
.turn-detail { margin: 4px 0 6px; padding: 8px 12px; border-radius: 8px; background: var(--alpha-1); font-size: 12px; color: var(--text-2); line-height: 1.7; }
.warn-text { color: var(--text-warning); }
.notice-line { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 12px; color: var(--text-3); text-align: center; }
.notice-line::before, .notice-line::after { content: ""; flex: 1; height: 0.5px; background: var(--border-line); }
.banner { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; background: var(--alpha-1); color: var(--text-2); }
.banner .icon { margin-top: 2px; }
.banner.warning { background: var(--bg-warning); color: var(--text-warning); }
.banner.danger { background: var(--bg-danger); color: var(--text-danger); }
.load-more { display: block; margin: 4px auto 12px; font-size: 12px; color: var(--text-2); padding: 4px 12px; border-radius: 9999px; background: var(--alpha-1); }
.load-more:hover { background: var(--fill-secondary-hover); color: var(--text); }
.empty-chat { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 18vh 0 0; color: var(--text-2); font-size: 14px; }
.empty-chat .spark { color: var(--clay); margin-bottom: 6px; }
.empty-chat .muted { font-size: 12px; font-family: var(--font-mono); }

/* 正在工作 / 实时输出 */
.working { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; font-size: 13.5px; color: var(--text-2); }
.working .spark { color: var(--clay); }
.spin-spark { animation: spark-spin 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite; }
@keyframes spark-spin { 0% { transform: rotate(0) scale(0.92); } 50% { transform: rotate(90deg) scale(1.06); } 100% { transform: rotate(180deg) scale(0.92); } }
.working-time { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.live-thinking { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; font-size: 13px; color: var(--text-3); white-space: pre-wrap; max-height: 4.8em; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, transparent, #000 1.6em); mask-image: linear-gradient(180deg, transparent, #000 1.6em); }
.live-thinking .icon { margin-top: 3px; }
.spinner { width: 13px; height: 13px; border-radius: 9999px; border: 1.6px solid var(--alpha-2); border-top-color: var(--text-2); animation: spin 0.8s linear infinite; display: inline-block; }
.spinner.sm { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 输入框 ───────────────────────────────────────────────────────────── */
.composer-dock { flex: none; position: relative; padding: 0 0 10px; }
.composer-dock::before { content: ""; position: absolute; left: 0; right: 12px; bottom: 100%; height: 24px; background: linear-gradient(transparent, var(--page)); pointer-events: none; }
.composer-box {
  position: relative;
  background: var(--surface-3);
  border-radius: 20px;
  padding: 8px 8px 6px;
  box-shadow: var(--shadow-composer), inset 0 0 0 1px var(--composer-ring);
  transition: box-shadow 0.15s;
  cursor: text;
}
.composer-box:focus-within { box-shadow: var(--shadow-composer-focus), inset 0 0 0 1px var(--border-strong); }
.composer-input {
  display: block;
  width: 100%;
  min-height: 40px;
  max-height: 384px;
  resize: none;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 20px;
  padding: 6px 6px 0 8px;
  overflow-y: auto;
}
.composer-input::placeholder { color: var(--text-3); }
.composer-chin { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; min-height: 32px; cursor: default; }
.chin-left, .chin-right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.chin-right { flex: none; gap: 4px; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 450;
  color: var(--text-2);
  white-space: nowrap;
  min-width: 0;
  transition: background-color 0.08s, color 0.08s;
}
.ghost-btn:hover, .ghost-btn.open { background: var(--ghost-hover); color: var(--text); }
.ghost-btn .caret { color: var(--text-3); }
.ghost-btn.icon-only { padding: 0; width: 32px; justify-content: center; }
.ghost-btn.danger { color: var(--text-danger); }
.model-btn .model-name { color: var(--text); }
.model-effort { color: var(--text-3); }
.fast-mark { color: var(--clay); }
.folder-btn .folder-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.mode-btn span { overflow: hidden; text-overflow: ellipsis; }
.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--clay-emph);
  color: #fff;
  transition: background-color 0.1s, opacity 0.1s;
}
.send-btn .icon { stroke-width: 2; }
.send-btn:hover:not(:disabled) { background: var(--clay); }
.send-btn:disabled { opacity: 0.35; }
.send-btn.stop { background: var(--fill-primary); color: var(--on-primary); }
.send-btn.stop:hover { background: var(--fill-primary-hover); }
.stop-sq { width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
.ring-btn { gap: 4px; }
.ring-btn.icon-only:has(.ring-text) { width: auto; padding: 0 8px 0 7px; }
.ring-text { color: var(--text-3); }
.ring-bg { fill: none; stroke: var(--border-line); stroke-width: 2.6; }
.ring-fg { fill: none; stroke: var(--text-2); stroke-width: 2.6; stroke-linecap: butt; transition: stroke-dasharray 0.4s var(--ease-out); }
.ring-fg.warn { stroke: var(--warning); }
.ring-fg.bad { stroke: var(--danger); }
.ring-text { font-size: 12px; font-variant-numeric: tabular-nums; }
.ring-text.warn { color: var(--text-warning); }
.ring-text.bad { color: var(--text-danger); }

.composer-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 4px; padding: 4px 4px 0; min-height: 22px; }
.foot-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 7px; border-radius: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
button.foot-chip:hover { background: var(--ghost-hover); color: var(--text-2); }
.foot-chip.path { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.foot-chip.cache.warn { color: var(--text-warning); }
.usage-chip .sep { width: 0.5px; height: 12px; background: var(--border-strong); margin: 0 2px; }
.seg-usage.warn { color: var(--text-warning); }
.seg-usage.bad, .usage-chip.bad .seg-usage.bad { color: var(--text-danger); }

/* 输入框上方的确认卡片 */
.dock { margin-bottom: 10px; animation: dock-in 0.2s var(--ease-out); }
@keyframes dock-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dock > .dock-title { padding: 0 4px 8px; }
.dock-card { background: var(--surface-3); border-radius: 16px; padding: 14px; box-shadow: var(--shadow-composer), inset 0 0 0 1px var(--composer-ring); display: flex; flex-direction: column; gap: 10px; }
.dock-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.dock-title .icon { color: var(--clay); }
.dock-body { max-height: 32vh; overflow: auto; }
.dock-body.plan { font-size: 14px; padding: 2px 4px; }
.dock-body pre.code { max-height: none; }
.dock-reason { font-size: 12.5px; color: var(--text-2); }
.dock-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.dock-deny { display: flex; flex-direction: column; gap: 8px; }
.dock-more { font-size: 12px; color: var(--text-3); padding: 6px 4px 0; }
.ask { gap: 14px; }
.ask-q { display: flex; flex-direction: column; gap: 6px; }
.ask-header { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.02em; }
.ask-title { font-size: 14px; font-weight: 500; }
.ask-opts { display: flex; flex-direction: column; gap: 4px; }
.ask-opt { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--border-line); transition: background-color 0.08s, box-shadow 0.08s; }
.ask-opt:hover { background: var(--ghost-hover); }
.ask-opt.on { box-shadow: inset 0 0 0 1.5px var(--fill-primary); background: var(--alpha-1); }
.ask-mark { width: 20px; height: 20px; flex: none; border-radius: 9999px; background: var(--alpha-1); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-2); margin-top: 1px; }
.ask-mark.square { border-radius: 5px; }
.ask-opt.on .ask-mark { background: var(--fill-primary); color: var(--on-primary); }
.ask-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ask-label { font-size: 13.5px; font-weight: 500; }
.ask-desc { font-size: 12.5px; color: var(--text-2); }

/* ── 新建会话页 ───────────────────────────────────────────────────────── */
.new-page { flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px; }
.new-inner { max-width: 42rem; margin: 0 auto; padding: calc(16vh - 24px) 0 48px; }
.greeting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0 0 28px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.875rem, 1.2rem + 2vw, 2.375rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
}
.greeting-spark { color: var(--clay); flex: none; }
.new-page .composer-box { padding: 12px 12px 10px; }
.new-page .composer-input { min-height: 60px; }
.new-hint { text-align: center; font-size: 12px; color: var(--text-3); margin: 12px 0 0; overflow-wrap: anywhere; }
.new-hint b { font-weight: 500; color: var(--text-2); }
.folder-menu { width: 340px; }
.browser { display: flex; flex-direction: column; gap: 6px; }
.browser-roots { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 2px; }
.root-chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--alpha-1); color: var(--text-2); }
.root-chip:hover { background: var(--fill-secondary-hover); color: var(--text); }
.browser-cur { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); padding: 2px 8px; overflow-wrap: anywhere; }
.browser-list { max-height: 260px; overflow-y: auto; }

.history { margin-top: 40px; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 8px 8px; font-size: 13px; font-weight: 500; color: var(--text-2); border-bottom: 0.5px solid var(--border-line); margin-bottom: 4px; }
.history-head .muted { font-size: 12px; font-weight: 400; }
.history-note { font-size: 12.5px; color: var(--text-3); padding: 10px 8px; }
.history-list { display: flex; flex-direction: column; }
.history-item { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 8px; text-align: left; transition: background-color 0.08s; }
.history-item:hover:not(:disabled) { background: var(--ghost-hover); }
.history-item:disabled { opacity: 0.6; }
.hi-title { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hi-meta { flex: none; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.hi-branch { display: inline-flex; align-items: center; gap: 3px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-open { color: var(--text-2); background: var(--alpha-1); border-radius: 9999px; padding: 0 7px; }

/* ── 提示条 ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--popover);
  color: var(--text);
  box-shadow: var(--shadow-popover);
  font-size: 13px;
  animation: pop-in 0.18s var(--ease-out);
}
.toast.error .icon { color: var(--danger); }
.toast.info .icon { color: var(--success); }

/* ── 配对页 ───────────────────────────────────────────────────────────── */
.pair-page { min-height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 10vh 16px 48px; }
.pair-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; }
.pair-brand .spark { color: var(--clay); }
.pair-brand .wordmark { font-size: 24px; }
.pair-title { font-family: var(--font-serif); font-weight: 400; font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.25rem); letter-spacing: -0.01em; margin: 0 0 24px; text-align: center; }
.pair-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; padding: 24px; border-radius: 24px; background: var(--surface-3); box-shadow: var(--shadow-card); }
.pair-text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.pair-label { font-size: 13px; color: var(--text-2); }
.code-big { font-family: var(--font-mono); font-size: 30px; letter-spacing: 0.2em; text-align: center; padding: 12px; border-radius: 12px; background: var(--alpha-1); }

/* ── 署名(多人协作时看是谁发的) ─────────────────────────────────────── */
.byline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin: 0 4px 4px 0; }
.by-avatar { width: 18px; height: 18px; border-radius: 9999px; background: var(--alpha-2); color: var(--text-2); font-size: 10.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.by-account { padding: 0 6px; border-radius: 9999px; background: var(--alpha-1); }

/* ── 消息里的附件 ───────────────────────────────────────────────────── */
.msg-attachments { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-bottom: 6px; max-width: min(85%, 36rem); }
.att-images { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.att-image { width: 132px; height: 132px; border-radius: 12px; overflow: hidden; background: var(--alpha-1); box-shadow: inset 0 0 0 0.5px var(--border-line); cursor: zoom-in; padding: 0; display: block; }
.att-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-image.pending, .att-loading { display: block; width: 100%; height: 100%; background: var(--alpha-2); animation: shimmer 1.2s ease-in-out infinite; }
.att-image.pending { width: 132px; height: 132px; border-radius: 12px; }
@keyframes shimmer { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.att-file { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 12px; border-radius: 12px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-line); font-size: 13px; }
.att-file .icon { color: var(--text-3); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.att-size { color: var(--text-3); font-size: 12px; flex: none; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; animation: fade-in 0.15s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }

/* ── 输入框里的附件 ─────────────────────────────────────────────────── */
.draft-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 4px 6px; }
.draft-item { position: relative; border-radius: 10px; background: var(--alpha-1); box-shadow: inset 0 0 0 0.5px var(--border-line); overflow: hidden; }
.draft-item.image { width: 60px; height: 60px; }
.draft-item.image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.draft-item.err { box-shadow: inset 0 0 0 1.5px var(--danger); }
.draft-file { display: flex; flex-direction: column; justify-content: center; gap: 1px; width: 168px; height: 60px; padding: 6px 26px 6px 10px; font-size: 12px; }
.draft-file .icon { color: var(--text-3); }
.draft-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.draft-size { color: var(--text-3); font-size: 11px; }
.draft-remove { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 9999px; background: rgba(0, 0, 0, 0.6); color: #fff; display: inline-flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.1s; }
.draft-item:hover .draft-remove { opacity: 1; }
.draft-progress { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 3px; border-radius: 9999px; background: rgba(0, 0, 0, 0.25); overflow: hidden; }
.draft-progress i { display: block; height: 100%; background: var(--clay); }
.composer-box.dragging { box-shadow: var(--shadow-composer-focus), inset 0 0 0 1.5px var(--clay); }
.drop-hint { position: absolute; inset: 0; border-radius: inherit; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--surface-3) 88%, transparent); color: var(--text-2); font-size: 13px; pointer-events: none; }
.attach-btn .icon { stroke-width: 1.8; }
.spinner.light { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }

.drop-overlay { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 24px; background: color-mix(in srgb, var(--page) 72%, transparent); backdrop-filter: blur(2px); pointer-events: none; animation: fade-in 0.12s; }
.drop-card { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 420px; padding: 28px 32px; border-radius: 18px; border: 2px dashed color-mix(in srgb, var(--clay) 70%, transparent); background: var(--popover); box-shadow: var(--shadow-popover); text-align: center; }
.drop-card .icon { color: var(--clay); }
.drop-title { font-size: 16px; font-weight: 600; }
.drop-sub { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }

/* ── 斜杠命令、顺便问 ───────────────────────────────────────────────── */
.slash-hint { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); z-index: 20; padding: 4px; background: var(--popover); border-radius: 12px; box-shadow: var(--shadow-popover); animation: pop-in 0.12s var(--ease-out); }
.slash-item { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 6px 10px; border-radius: 8px; text-align: left; }
.slash-item:hover { background: var(--ghost-hover); }
.slash-cmd { font-family: var(--font-mono); font-size: 13px; color: var(--text); flex: none; }
.slash-desc { font-size: 12.5px; color: var(--text-3); }
.btw-mode { display: inline-flex; align-items: center; gap: 6px; margin: 0 4px 4px; padding: 2px 8px; border-radius: 9999px; background: color-mix(in srgb, var(--clay) 12%, transparent); color: var(--clay-emph); font-size: 12px; }
.btw-mode .icon { color: var(--clay); }
.btw-card { margin: 8px 0; padding: 8px 12px; border-radius: 12px; background: var(--alpha-1); box-shadow: inset 2px 0 0 var(--clay); }
.btw-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.btw-head .icon { color: var(--clay); }
.btw-note { margin-left: auto; font-size: 11.5px; }
.btw-q { font-size: 13.5px; font-weight: 500; margin-bottom: 4px; white-space: pre-wrap; }
.btw-card .md { font-size: 14px; }
.btw-err { font-size: 13px; color: var(--text-danger); }
.btw-card.pending .btw-q { margin-bottom: 0; }

/* ── 分叉 ───────────────────────────────────────────────────────────── */
.turn-usage-line { display: flex; align-items: center; gap: 2px; }
.turn-fork { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); padding: 2px 6px; border-radius: 6px; opacity: 0; transition: opacity 0.12s; }
.turn-usage:hover .turn-fork, .turn-fork:focus-visible { opacity: 1; }
.turn-fork:hover { background: var(--ghost-hover); color: var(--text); }
.hdr-badge { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); padding: 1px 7px; border-radius: 9999px; background: var(--alpha-1); }
.hdr-fork { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); padding: 1px 6px; border-radius: 6px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-fork:hover:not(:disabled) { background: var(--ghost-hover); color: var(--text); }

/* ── 管理员批准 ─────────────────────────────────────────────────────── */
.dock-card.waiting-admin { background: var(--alpha-1); box-shadow: inset 0 0 0 1px var(--border-line); }
.dock-card.waiting-admin .dock-title .icon { color: var(--text-3); }
.dock-card.admin { box-shadow: var(--shadow-composer), inset 0 0 0 1.5px color-mix(in srgb, var(--clay) 55%, transparent); }
.dock .banner { margin: 0; }

/* ── 弹窗(账号管理) ─────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; z-index: 120; background: rgba(0, 0, 0, 0.35); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; overflow-y: auto; animation: fade-in 0.15s; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 640px; background: var(--popover); border-radius: 16px; box-shadow: var(--shadow-popover); animation: pop-in 0.18s var(--ease-out); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 16px 8px 20px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-sub { font-size: 12.5px; color: var(--text-2); margin-top: 4px; line-height: 1.55; }
.modal-body { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-body > .btn { align-self: flex-start; }
.acct-card { border-radius: 12px; box-shadow: inset 0 0 0 1px var(--border-line); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.acct-card.admins { background: var(--alpha-1); box-shadow: none; }
.acct-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.acct-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.acct-role { font-size: 11px; font-weight: 500; color: var(--text-2); padding: 0 7px; border-radius: 9999px; background: var(--alpha-1); }
.acct-role.admin { color: var(--clay-emph); background: color-mix(in srgb, var(--clay) 14%, transparent); }
.acct-role-seg { margin: 0; }
.acct-root { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.acct-actions { display: flex; gap: 4px; flex: none; align-items: center; }
.acct-actions.end { justify-content: flex-end; margin-top: 4px; }
.danger-text { color: var(--text-danger) !important; }
.acct-devices { display: flex; flex-direction: column; }
.acct-device { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; border-top: 0.5px solid var(--border-line); }
.acct-device:first-child { border-top: none; }
.acct-device .dot { width: 7px; height: 7px; border-radius: 9999px; background: var(--border-strong); flex: none; }
.acct-device .dot.on { background: var(--success); }
.acct-device-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-tag { margin-left: 6px; font-size: 11px; color: var(--text-3); padding: 0 6px; border-radius: 9999px; background: var(--alpha-1); }
.acct-device-meta { font-size: 12px; color: var(--text-3); flex: none; }
.text-btn.danger { color: var(--text-danger); }
.acct-empty { font-size: 12.5px; color: var(--text-3); padding: 4px 0; }
.acct-form { display: flex; flex-direction: column; gap: 6px; }
.acct-form label { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.acct-form label .muted { margin-left: 6px; font-size: 12px; }
.acct-form.inline { flex-direction: row; align-items: center; gap: 6px; }
.acct-form.inline .field { flex: 1; min-width: 0; }
.acct-recent { display: flex; flex-wrap: wrap; gap: 4px; }
.root-chip.on { background: var(--fill-primary); color: var(--on-primary); }
.acct-cred { border-radius: 12px; padding: 12px; background: var(--bg-success); display: flex; flex-direction: column; gap: 8px; }
.acct-cred-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-success); }
.acct-cred pre.code { background: var(--surface-3); }
.acct-hint { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.acct-hint code { font-family: var(--font-mono); font-size: 11.5px; background: var(--alpha-1); padding: 1px 5px; border-radius: 4px; }

/* ── 登录页 ─────────────────────────────────────────────────────────── */
.pair-form { display: flex; flex-direction: column; gap: 6px; }
.pair-form .pair-label { margin-top: 4px; }
.pair-form .pair-label .muted { margin-left: 6px; font-size: 12px; }
.pair-form .btn { margin-top: 8px; }
.pair-progress { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.pair-text.small { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.pair-text code { font-family: var(--font-mono); font-size: 11.5px; background: var(--alpha-1); padding: 1px 5px; border-radius: 4px; }


/* ── 触屏 / 窄屏 ──────────────────────────────────────────────────────── */
@media (pointer: coarse) {
  :root { --row-h: 34px; --row-font: 14px; --group-font: 13px; --radius-pill: 8px; }
  .msg-actions { opacity: 1; }
  .step-caret, .group-caret, .row-ctl { opacity: 1; }
  .ghost-btn, .icon-btn, .send-btn { min-height: 36px; }
  .send-btn { width: 36px; }
  .composer-input { font-size: 16px; }
  .draft-remove, .turn-fork { opacity: 1; }
}
@media (max-width: 700px) {
  .att-image, .att-image.pending { width: 104px; height: 104px; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(var(--sidebar-w), 86vw); transform: translateX(-100%); margin-left: 0 !important; box-shadow: none; }
  .frame.drawer-open .sidebar { transform: none; box-shadow: var(--shadow-popover); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.3); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  .frame.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .sidebar-open, .frame.collapsed .sidebar-open { display: inline-flex; }
  .pane-header { padding: 0 6px; }
  .hdr-path { display: none; }
  .chat-column { padding: 0 10px; }
  .transcript { scrollbar-gutter: auto; }
  .msg-user .bubble { max-width: 88%; }
  .composer-dock { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer-box { border-radius: 18px; padding: 8px 8px 6px; }
  .folder-btn .folder-name { max-width: 34vw; }
  .mode-btn span { display: none; }
  .model-btn .model-effort { display: none; }
  .new-inner { padding-top: 8vh; }
  .greeting { margin-bottom: 20px; }
  .pop { max-width: calc(100vw - 20px); }
  .folder-menu, .usage-card, .ctx-pop { width: min(340px, calc(100vw - 20px)); }
  .composer-foot .foot-chip.path { display: none; }
}
