/* ============================================================
   Nexus 外壳（v4）：导航栏 + 会话/运行列表 + 对话 + 右侧上下文
   对应设计稿：docs/设计稿/前端重设计-v2/prototype.html
   styles.css 只保留消息、工具卡片、设置对话框等底层组件样式。
   ============================================================ */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --surface-hover: #f2f4f7;
  --line: #e9ecf1;
  --line-strong: #dde1e8;
  --text: #16181d;
  --text-soft: #5a616e;
  --text-faint: #8c93a0;
  --blue: #4d6bfe;
  --blue-soft: #eef1ff;
  --blue-ink: #2c48c9;
  --green: #0e9f5b;
  --green-soft: #e8f7ef;
  --amber: #b26b00;
  --amber-soft: #fdf3e2;
  --red: #d93a44;
  --red-soft: #fdecee;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 外壳网格 ---------- */
body:not(.floating-surface):not(.surface-monitor) { background: var(--surface); -webkit-font-smoothing: antialiased; }
body:not(.floating-surface):not(.surface-monitor) .activity-workspace.app-shell {
  display: grid;
  grid-template-columns: 52px 272px minmax(0, 1fr);
  grid-template-rows: 100svh;
  gap: 0;
  height: 100svh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}
body:not(.floating-surface):not(.surface-monitor)[data-view="inbox"] .activity-workspace.app-shell,
body:not(.floating-surface):not(.surface-monitor)[data-view="sources"] .activity-workspace.app-shell,
body:not(.floating-surface):not(.surface-monitor)[data-view="skills"] .activity-workspace.app-shell,
body:not(.floating-surface):not(.surface-monitor)[data-view="history"] .activity-workspace.app-shell { grid-template-columns: 52px minmax(0, 1fr); }
body[data-view="inbox"] .app-list,
body[data-view="sources"] .app-list,
body[data-view="skills"] .app-list,
body[data-view="history"] .app-list { display: none; }
.app-shell > .monitor-panel { display: none !important; }
.app-shell > #floating-surface { display: none; }
.legacy-nodes { display: none !important; }

/* 监控窗口与悬浮窗不使用外壳 */
body.surface-monitor .app-rail,
body.surface-monitor .app-list,
body.surface-monitor .app-main { display: none !important; }
body.surface-monitor .activity-workspace.app-shell > .monitor-panel { display: flex !important; height: calc(100svh - 16px); }
body.surface-monitor .activity-workspace.app-shell { display: block; padding: 8px; }

/* ---------- 一级导航 ---------- */
.app-rail {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 0 12px; border-right: 1px solid var(--line); background: var(--bg);
}
.app-rail-btn {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px;
  padding: 0; border: 0; border-radius: 9px; background: none; color: var(--text-faint); cursor: pointer;
}
.app-rail-btn:hover { background: var(--surface-hover); color: var(--text); }
.app-rail-btn.active { background: var(--surface); color: var(--blue); box-shadow: 0 0 0 1px var(--line-strong); }
.app-rail-btn svg { width: 17px; height: 17px; }
.app-rail-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--bg); }
.app-rail-dot.warn { background: var(--red); }
.app-rail-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }

/* ---------- 列表栏（会话 / 运行） ---------- */
.app-list { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--surface-soft); }
/* 主窗口使用系统标题栏，顶部不需要为窗口按钮留白。 */
.list-head { flex: none; padding: 14px 12px 8px; }
.list-seg { display: flex; padding: 2px; border-radius: 8px; background: #eceef2; }
.list-seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 26px;
  border: 0; border-radius: 6px; background: none; color: var(--text-soft); font-size: 11.5px; font-weight: 550; cursor: pointer;
}
.list-seg button.active { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgba(19, 24, 38, 0.08); }
.list-seg-count, .runs-btn-count {
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--amber);
  color: #fff; font-size: 9px; font-weight: 700; line-height: 15px; text-align: center;
}
.list-tools { display: flex; gap: 6px; margin-top: 10px; }
.list-search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text-faint);
}
.list-search:focus-within { border-color: #b9c6ff; }
.list-search svg { flex: none; width: 13px; height: 13px; }
.list-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 11.5px; }
.list-search input::-webkit-search-cancel-button { display: none; }
.list-new { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text-soft); cursor: pointer; }
.list-new:hover { color: var(--blue); border-color: #c9d3ff; }
.list-new svg { width: 14px; height: 14px; }
.list-chips { display: flex; gap: 5px; margin-top: 10px; overflow-x: auto; }
.list-chips::-webkit-scrollbar { height: 0; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); font-size: 11px; white-space: nowrap; cursor: pointer;
}
.chip.active { border-color: #c9d3ff; background: var(--blue-soft); color: var(--blue-ink); font-weight: 600; }
.chip i { width: 6px; height: 6px; border-radius: 50%; }
.list-body { flex: 1; min-height: 0; overflow: auto; padding: 2px 8px 8px; }
.list-group { padding: 10px 6px 4px; color: var(--text-faint); font-size: 10.5px; font-weight: 600; }
.list-empty { padding: 28px 12px; color: var(--text-faint); font-size: 11.5px; line-height: 1.7; text-align: center; }

.row { position: relative; display: flex; gap: 9px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.row:hover { background: var(--surface-hover); }
.row.active { background: var(--surface); box-shadow: 0 0 0 1px var(--line-strong); }
.row-av { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #e7ebf3; color: #495366; font-size: 11px; font-weight: 650; }
.row-av.ding { background: #e5efff; color: #2a62d9; }
.row-av.skill { background: #f0eefe; color: #5b46c9; }
.row-ic { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; }
.row-ic i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.row-main { flex: 1; min-width: 0; }
.row-t { display: flex; align-items: center; gap: 6px; }
.row-t b { flex: 1; min-width: 0; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row-t time { flex: none; color: var(--text-faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.row-s { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.row-s > span:first-child { flex: 1; min-width: 0; overflow: hidden; color: var(--text-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.row-unread { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.row-more { position: absolute; top: 6px; right: 6px; display: none; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 6px; background: var(--surface); color: var(--text-faint); cursor: pointer; }
.row:hover .row-more { display: grid; }
.row:hover .row-t time { visibility: hidden; }
.row-more svg { width: 13px; height: 13px; }
.fold {
  display: flex; align-items: center; gap: 6px; width: calc(100% - 12px); margin: 8px 6px 0; padding: 8px;
  border: 1px dashed var(--line-strong); border-radius: 8px; background: none; color: var(--text-faint);
  font-size: 11px; line-height: 1.5; text-align: left; cursor: pointer;
}
.fold:hover { color: var(--text-soft); }
.fold svg { flex: none; width: 12px; height: 12px; }

.list-foot { flex: none; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 10px 0 12px; border-top: 1px solid var(--line); }
.list-foot-link { min-width: 0; overflow: hidden; padding: 0; border: 0; background: none; color: var(--text-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.list-foot-link:hover { color: var(--text); }
.runs-btn {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); font-size: 11px; font-weight: 600; cursor: pointer;
}
.runs-btn:hover { color: var(--text); }
.runs-btn.active { border-color: #c9d3ff; background: var(--blue-soft); color: var(--blue-ink); }
.runs-btn svg { width: 12px; height: 12px; }

/* ---------- 状态标签 ---------- */
.tag { flex: none; display: inline-flex; align-items: center; height: 17px; padding: 0 6px; border-radius: 5px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.tag.running { background: var(--blue-soft); color: var(--blue-ink); }
.tag.waiting { background: var(--amber-soft); color: var(--amber); }
.tag.completed { background: var(--green-soft); color: var(--green); }
.tag.failed { background: var(--red-soft); color: var(--red); }
.tag.unmatched, .tag.mute { background: var(--surface-hover); color: var(--text-faint); }
.tag.src { padding: 0; background: none; color: var(--text-faint); font-weight: 500; }
.dot-running { background: var(--blue) !important; animation: shell-pulse 1.4s ease-in-out infinite; }
.dot-waiting { background: var(--amber) !important; }
.dot-failed { background: var(--red) !important; }
.dot-completed { background: var(--green) !important; }
.dot-unmatched { background: #c3c8d1 !important; }
@keyframes shell-pulse { 50% { box-shadow: 0 0 0 4px rgba(77, 107, 254, 0.18); } }

/* ---------- 主区 ---------- */
.app-main { display: flex; min-width: 0; min-height: 0; background: var(--surface); }
.app-main > .page,
.app-main > #history-drawer { display: none; }
body[data-view="session"] .app-main > #dsh-panel { display: flex; }
body:not([data-view="session"]) .app-main > #dsh-panel { display: none; }
body[data-view="inbox"] .app-main > #inbox-page,
body[data-view="sources"] .app-main > #sources-page,
body[data-view="skills"] .app-main > #skills-page { display: flex; }
body[data-view="history"] .app-main > #history-drawer { display: flex; }
.app-main > #dsh-panel {
  position: static; flex: 1; min-width: 0; min-height: 0; width: auto; height: auto;
  flex-direction: row; border: 0; border-radius: 0; box-shadow: none; background: var(--surface);
}

.chat { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-head { flex: none; display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px 0 24px; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.chat-title h2 { margin: 0; min-width: 0; overflow: hidden; font-size: 13.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { flex: none; color: var(--text-faint); font-size: 11px; }
.chat-title .status-badge:empty { display: none; }
.dsh-health { flex: none; display: inline-flex; align-items: center; gap: 5px; color: var(--text-faint); font-size: 11px; }
.dsh-health::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #c9cfda; }
.dsh-health.ok::before { background: var(--green); }
.dsh-health.error::before { background: var(--red); }
.chat-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.app-main .icon-button {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px;
  background: none; color: var(--text-faint); cursor: pointer;
}
.app-main .icon-button:hover { background: var(--surface-hover); color: var(--text); }
.app-main .icon-button[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); }
.app-main .icon-button svg { width: 15px; height: 15px; }
.ghost-button {
  height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--surface); color: var(--text-soft); font-size: 11.5px; white-space: nowrap; cursor: pointer;
}
.ghost-button:hover { border-color: #c9cfda; color: var(--text); }
.ghost-button:disabled { opacity: 0.5; cursor: default; }
.primary-button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: var(--blue);
  color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.primary-button:hover { background: #3f5cf0; }
.primary-button:disabled { background: #c8d0e0; cursor: default; }
.danger-text { color: var(--red) !important; }

.app-main .dsh-body { flex: 1; min-height: 0; display: flex; }
.app-main .dsh-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-main .dsh-meta.hidden { display: none; }
.app-main #dsh-conversation-view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app-main #dsh-conversation { flex: 1; min-height: 0; overflow: auto; padding: 20px 28px 8px; }
.app-main #dsh-conversation > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.app-main #dsh-conversation:empty::after {
  content: "选择左侧会话，或在下方输入要处理的事情";
  display: block; margin-top: 18vh; color: var(--text-faint); font-size: 12px; text-align: center;
}

/* 对话正文：头像 + 角色行 + 正文 */
.app-main .dsh-msg { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 11px; margin-bottom: 18px; }
.app-main .dsh-msg::before {
  content: "我"; grid-row: 1 / span 3; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: #e7ebf3; color: #495366; font-size: 11px; font-weight: 650;
}
.app-main .dsh-msg.assistant::before { content: "N"; background: #16181d; color: #fff; }
.app-main .dsh-msg.user { align-items: start; }
.app-main .dsh-msg-role { grid-column: 2; display: flex; align-items: baseline; gap: 7px; margin: 3px 0 4px; color: var(--text); font-size: 12px; font-weight: 650; }
.app-main .dsh-msg-tag { color: var(--text-faint); font-size: 10.5px; font-weight: 400; }
.app-main .dsh-msg-copy { margin-left: auto; font-size: 10.5px; }
.app-main .dsh-msg .message-body,
.app-main .dsh-msg.user .message-body {
  grid-column: 2; max-width: 100%; padding: 0; border: 0; background: none;
  color: #2a2e36; font-size: 12.5px; line-height: 1.75; white-space: normal;
}
.app-main .dsh-msg.user .message-body { white-space: pre-wrap; }
.app-main .dsh-msg .message-body p { margin: 0 0 6px; }
.app-main .dsh-msg .message-body p:last-child { margin-bottom: 0; }
.app-main .dsh-msg .message-body ul,
.app-main .dsh-msg .message-body ol { margin: 2px 0 6px; padding-left: 18px; }
.app-main .dsh-attachments { grid-column: 2; }
.app-main .dsh-thought,
.app-main .dsh-tool,
.app-main .dsh-subagent,
.app-main .runcard { max-width: 681px !important; margin-left: calc(39px + max(0px, (100% - 720px) / 2)) !important; margin-right: auto !important; }
.app-main .dsh-thought { margin-top: -8px; margin-bottom: 12px; }
.app-main .dsh-thought-toggle { color: var(--text-faint); font-size: 11px; }
.app-main .dsh-thought-quote { margin-top: 6px; padding: 9px 12px; border-left: 2px solid var(--line-strong); border-radius: 0 8px 8px 0; background: var(--surface-soft); color: var(--text-soft); font-size: 11.5px; }
.app-main .dsh-tool { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; }
.app-main .dsh-tool-head { min-height: 34px; font-size: 11px; }
.app-main .dsh-live { color: var(--text-faint); font-size: 11px; }

/* 对话流中的运行卡片 */
.runcard { margin: 0 auto 18px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); overflow: hidden; cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; }
.runcard:hover { border-color: #c9cfda; }
.runcard.active { border-color: #b9c6ff; box-shadow: 0 0 0 3px var(--blue-soft); }
.runcard-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px; }
.runcard-h b { min-width: 0; overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.runcard-h .meta { margin-left: auto; flex: none; color: var(--text-faint); font-size: 10.5px; }
.runcard-h svg { flex: none; width: 13px; height: 13px; color: var(--text-faint); }
.runcard-steps { display: flex; padding: 0 12px 10px; }
.runcard-step { flex: 1; display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--text-soft); font-size: 11px; }
.runcard-step span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runcard-step i { flex: none; display: grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-style: normal; font-size: 9px; font-weight: 700; }
.runcard-step.current i { background: var(--blue-soft); color: var(--blue); }
.runcard-step.failed i { background: var(--red-soft); color: var(--red); }
.runcard-step.todo { color: var(--text-faint); }
.runcard-step.todo i { background: var(--surface-hover); color: var(--text-faint); }
.runcard-step + .runcard-step::before { content: ""; flex: none; width: 14px; height: 1px; margin-right: 5px; background: var(--line-strong); }
.runcard-note { padding: 0 12px 10px; color: var(--text-soft); font-size: 11px; line-height: 1.6; }
.runcard-confirm { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid #f4e3c3; background: var(--amber-soft); color: var(--amber); font-size: 11.5px; }
.runcard-confirm > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runcard-confirm .acts { margin-left: auto; flex: none; display: flex; gap: 6px; }

/* 输入框 */
.app-main .dsh-composer { flex: none; padding: 6px 28px 16px; background: transparent; }
.app-main .dsh-composer-box { max-width: 720px; margin: 0 auto; border-radius: 12px; }
.app-main .dsh-composer-hint { font-size: 10.5px; }
.app-main .dsh-jump { bottom: 10px; }

/* ---------- 右侧上下文 ---------- */
.ctx { flex: none; width: 348px; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--surface-soft); }
body.ctx-closed .ctx { display: none; }
.ctx-head { flex: none; display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); }
.ctx-head:has(.ctx-back:not(.hidden)) { padding-left: 8px; }
.ctx-head strong { font-size: 12.5px; font-weight: 650; }
.ctx-actions { margin-left: auto; display: flex; gap: 2px; }
.ctx-body { flex: 1; min-height: 0; overflow: auto; }
.sec { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; color: var(--text-faint); font-size: 10.5px; font-weight: 650; }
.sec h4 .more { margin-left: auto; padding: 0; border: 0; background: none; color: var(--blue-ink); font-size: 10.5px; font-weight: 550; cursor: pointer; }
.kv { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 7px 10px; margin: 0; font-size: 11.5px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; min-width: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.mini { display: flex; align-items: center; gap: 8px; width: calc(100% + 18px); margin: 0 -9px; padding: 8px 9px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.mini:hover { background: var(--surface-hover); }
.mini.active { background: var(--surface); box-shadow: 0 0 0 1px var(--line-strong); }
.mini b { flex: 1; min-width: 0; overflow: hidden; color: var(--text); font-size: 11.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mini time { flex: none; color: var(--text-faint); font-size: 10.5px; }
.sec-empty { color: var(--text-faint); font-size: 11.5px; line-height: 1.7; }

.rd-sum { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.rd-title { display: flex; align-items: flex-start; gap: 8px; }
.rd-title strong { min-width: 0; font-size: 13px; font-weight: 650; line-height: 1.5; }
.rd-title .status-badge { flex: none; margin-top: 1px; }
.rd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; color: var(--text-faint); font-size: 11px; line-height: 1.6; }
.rd-meta:empty, .rd-meta .detail-token-usage:empty { display: none; }
.rd-meta .task-code { flex: none; padding: 0 5px; border-radius: 4px; background: var(--surface-hover); color: var(--text-soft); font-family: var(--mono); font-size: 10px; }
.rd-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rd-actions:empty { display: none; }
.rd-tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.rd-tab { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--text-soft); font-size: 11.5px; font-weight: 550; cursor: pointer; }
.rd-tab:hover { background: var(--surface-hover); }
.rd-tab.active { background: var(--blue-soft); color: var(--blue-ink); font-weight: 650; }
.ctx .rd-pane { padding: 14px 16px; overflow: visible; }
.ctx .conversation-view.rd-pane { display: block; }
.ctx .conversation-view.hidden { display: none; }
.ctx #conversation { padding: 0; overflow: visible; }
.ctx .message { max-width: 100%; }
.ctx .message-body { font-size: 11.5px; }
.ctx .timeline-item { padding-bottom: 14px; }
.ctx .timeline-title { font-size: 11.5px; font-weight: 600; }
.ctx .timeline-time, .ctx .timeline-detail { font-size: 10.5px; line-height: 1.6; }
.ctx .detail-original-message { padding: 0; border: 0; }
.ctx .detail-original-message > span,
.ctx .detail-result > span { display: block; margin-bottom: 6px; color: var(--text-faint); font-size: 10.5px; font-weight: 600; }
.ctx .detail-original-message > p { max-height: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; line-height: 1.7; }
.ctx .detail-result-text { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-family: var(--mono); font-size: 10.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.ctx .empty-compact { padding: 18px 0; color: var(--text-faint); font-size: 11.5px; text-align: center; }

/* ---------- 一级页面（信息源 / 能力） ---------- */
.page { flex: 1; min-width: 0; min-height: 0; flex-direction: column; }
.page-head { flex: none; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px 0 24px; border-bottom: 1px solid var(--line); }
.page-head h2 { margin: 0; font-size: 13.5px; font-weight: 650; }
.page-head .sub { color: var(--text-faint); font-size: 11px; }
.page-head .acts { margin-left: auto; display: flex; gap: 6px; }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.split-l { min-height: 0; overflow: auto; padding: 10px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.split-r { min-height: 0; overflow: auto; }
.item { display: flex; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 9px; background: none; text-align: left; cursor: pointer; }
.item:hover { background: var(--surface-hover); }
.item.active { background: var(--surface); box-shadow: 0 0 0 1px var(--line-strong); }
.item b { display: block; color: var(--text); font-size: 12px; font-weight: 650; }
.item .s { margin-top: 3px; color: var(--text-faint); font-size: 11px; }
.logo { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #eef0f4; color: #495366; font-size: 12px; font-weight: 700; }
.logo.ding { background: #e5efff; color: #2a62d9; }
.logo.warn { background: var(--amber-soft); color: var(--amber); }
.logo.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 16px; }
.logo svg { width: 15px; height: 15px; }
.add { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 6px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 9px; background: none; color: var(--text-faint); font-size: 11.5px; cursor: pointer; }
.add:hover { border-color: #c9d3ff; color: var(--blue-ink); }
.status { display: inline-flex; align-items: center; gap: 5px; color: var(--text-soft); font-size: 11px; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.status.off i { background: var(--text-faint); }
.status.warn i { background: var(--amber); }
.status.err i { background: var(--red); }
.detail { max-width: 1080px; padding: 20px 26px 32px; }
.detail-top { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.detail-top h3 { margin: 2px 0 4px; font-size: 15px; font-weight: 650; }
.detail-top p { margin: 0; color: var(--text-soft); font-size: 11.5px; line-height: 1.7; }
.detail-top .acts { margin-left: auto; flex: none; display: flex; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat { padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.stat small { display: block; color: var(--text-faint); font-size: 10.5px; }
.stat b { display: block; margin-top: 4px; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat em { font-style: normal; color: var(--text-faint); font-size: 10.5px; }
.stat em.good { color: var(--green); }
.stat em.bad { color: var(--red); }
.h5 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 650; }
.h5 .sub { color: var(--text-faint); font-size: 11px; font-weight: 400; }
.h5 .acts { margin-left: auto; display: flex; gap: 6px; }
.table { width: 100%; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 10px; border-collapse: separate; border-spacing: 0; overflow: hidden; background: var(--surface); }
.table th { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface-soft); color: var(--text-faint); font-size: 10.5px; font-weight: 600; text-align: left; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td .s { margin-top: 2px; color: var(--text-faint); font-size: 10.5px; }
.pill { display: inline-flex; align-items: center; height: 20px; margin: 2px 4px 2px 0; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text-soft); font-size: 10.5px; white-space: nowrap; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 64px; margin-bottom: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.bars i { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; background: #c9d3ff; }
.bars i.m { background: var(--blue); }
.bars-axis { display: flex; justify-content: space-between; margin-bottom: 22px; padding: 0 12px; color: var(--text-faint); font-size: 10px; }
.test { display: flex; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.test input { flex: 1; min-width: 0; height: 30px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; font-size: 12px; }
.test input:focus { border-color: #b9c6ff; }
.block { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; line-height: 1.7; }
.block small { display: block; margin-bottom: 4px; color: var(--text-faint); font-size: 10.5px; }
.empty-page { padding: 60px 20px; color: var(--text-faint); font-size: 12px; text-align: center; }

.cap-page { position: relative; flex: 1; min-height: 0; display: flex; }
.cap-wrap { flex: 1; min-width: 0; min-height: 0; overflow: auto; }
.cap-in { max-width: 1000px; margin: 0 auto; padding: 20px 26px 32px; }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin-bottom: 26px; }
.cap { display: flex; flex-direction: column; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; cursor: pointer; }
.cap:hover { border-color: var(--line-strong); box-shadow: 0 2px 8px rgba(19, 24, 38, 0.05); }
.cap.active { border-color: #b9c6ff; box-shadow: 0 0 0 3px var(--blue-soft); }
.cap-h { display: flex; align-items: center; gap: 10px; }
.cap-h .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); }
.cap-h b { display: block; font-size: 12.5px; font-weight: 650; }
.cap-h .code { color: var(--text-faint); font-family: var(--mono); font-size: 10.5px; }
.cap-h .status { margin-left: auto; }
.cap > p { flex: 1; margin: 10px 0 12px; color: var(--text-soft); font-size: 11.5px; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cap-f { display: flex; gap: 16px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--text-faint); font-size: 10.5px; }
.cap-f b { margin-right: 3px; color: var(--text); font-size: 11.5px; font-weight: 650; }
.cap-f .bad b, .cap-f .bad { color: var(--red); }
.miss { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.miss-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.miss-row:last-child { border-bottom: 0; }
.miss-cnt { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700; }
.miss-main { flex: 1; min-width: 0; }
.miss-main b { display: block; font-size: 12px; font-weight: 650; }
.miss-ex { margin-top: 3px; overflow: hidden; color: var(--text-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.miss-row .acts { flex: none; display: flex; gap: 6px; }

.sheet { flex: none; width: 380px; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--surface); box-shadow: -12px 0 32px rgba(19, 24, 38, 0.06); }
.sheet .ctx-head { padding-left: 16px; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.sheet-desc { margin: 0 0 16px; color: var(--text-soft); font-size: 11.5px; line-height: 1.7; }
.sheet-foot { flex: none; display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.sheet .skill-param-field { display: grid; gap: 5px; margin-bottom: 14px; }
.sheet .skill-param-field > span { color: var(--text-soft); font-size: 11px; font-weight: 600; }
.sheet .skill-param-field input,
.sheet .skill-param-field textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; font-size: 11.5px; }
.sheet .skill-param-help { color: var(--text-faint); font-size: 10.5px; line-height: 1.6; }
.sheet .skill-param-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.sheet .skill-param-status { flex: 1; color: var(--red); font-size: 11px; }
.sheet .skill-param-empty { color: var(--text-faint); font-size: 11.5px; }

/* 历史页沿用旧抽屉内容，只统一外框 */
.app-main > #history-drawer { flex: 1; min-width: 0; flex-direction: column; height: auto; border: 0; border-radius: 0; box-shadow: none; }
.app-main > #history-drawer .drawer-header { height: 52px; min-height: 52px; padding: 0 16px 0 24px; border-bottom: 1px solid var(--line); }
.app-main > #history-drawer .detail-back { display: none; }

/* ---------- 命令面板 ---------- */
.app-palette { position: fixed; inset: 0; z-index: 400; display: flex; justify-content: center; padding-top: 12vh; background: rgba(22, 24, 29, 0.18); }
.app-palette.hidden { display: none; }
.app-palette-panel { width: min(580px, calc(100vw - 32px)); height: max-content; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); box-shadow: 0 10px 32px rgba(19, 24, 38, 0.12), 0 1px 2px rgba(19, 24, 38, 0.06); }
.app-palette-input { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.app-palette-input svg { flex: none; width: 15px; height: 15px; color: var(--text-faint); }
.app-palette-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 13.5px; }
.app-kbd { display: inline-flex; align-items: center; height: 17px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface-soft); color: var(--text-faint); font-size: 10px; }
.app-palette-results { max-height: 380px; overflow: auto; padding: 6px; }
.app-palette-group { padding: 8px 10px 4px; color: var(--text-faint); font-size: 10.5px; font-weight: 600; }
.app-palette-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 12px; text-align: left; cursor: pointer; }
.app-palette-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-palette-item svg { flex: none; width: 14px; height: 14px; color: var(--text-faint); }
.app-palette-item.active { background: var(--blue-soft); color: var(--blue-ink); }
.app-palette-item em { margin-left: auto; flex: none; color: var(--text-faint); font-size: 10.5px; font-style: normal; }
.app-palette-empty { padding: 18px 12px; color: var(--text-faint); font-size: 11.5px; text-align: center; }
.app-palette-foot { display: flex; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); color: var(--text-faint); font-size: 10.5px; }
.app-palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 窄窗口 ---------- */
@media (max-width: 1180px) {
  .ctx { width: 300px; }
  .split { grid-template-columns: 240px minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  body:not(.ctx-closed) .chat-sub { display: none; }
  .app-main .composer-trigger-label { max-width: 120px; }
}
.sheet [data-skill-param-close] { display: none; }
.chat-title .dsh-health,
.chat-title .dsh-health.ok,
.chat-title .dsh-health.error { color: var(--text-faint); font-weight: 400; background: none; padding: 0; border: 0; }
.sheet [data-skill-param-save] { height: 28px; padding: 0 14px; border-radius: 7px; font-size: 11.5px; }
.sheet .skill-param-actions { justify-content: flex-end; }

/* ---------- 事项页（ADR-043） ---------- */
#inbox-page { flex-direction: column; min-height: 0; }
.inbox-tabs { margin-left: 6px; }
.inbox-tabs button { min-width: 52px; }
.inbox-stats { flex: none; margin: 14px 24px 14px; }
#inbox-page .split { border-top: 1px solid var(--line); }
.inbox-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.inbox-chips .chip b { margin-left: 4px; font-weight: 600; color: var(--text-faint); }
.inbox-row { flex: 1; min-width: 0; }
.inbox-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-level { flex: none; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--text-faint); }
.inbox-level.lv-immediate { background: var(--red); }
.inbox-level.lv-silent { background: var(--blue-ink); }
.inbox-level.lv-digest { background: var(--green); }
.inbox-level.lv-block { background: #c8ccd4; }
em.urgent { margin-right: 6px; padding: 0 5px; border-radius: 4px; background: var(--red-soft); color: var(--red); font-size: 10px; font-style: normal; font-weight: 700; }
.inbox-summary { margin-bottom: 12px; }
.inbox-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 22px; }
.inbox-mute { display: inline-flex; align-items: center; gap: 4px; }
.inbox-scope { height: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 11px; }
.inbox-time { margin-left: 8px; color: var(--text-faint); font-size: 10.5px; font-weight: 400; }
.inbox-text { margin-top: 4px; color: var(--text-soft); font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.inbox-full { flex: 1; }
.inbox-rule-acts { display: flex; gap: 6px; justify-content: flex-end; }
.table tr.off td { color: var(--text-faint); }
.table .s { margin-top: 2px; color: var(--text-faint); font-size: 10.5px; }
.inbox-rule-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px; }
.inbox-rule-form input, .inbox-rule-form select { height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 11.5px; }
.inbox-rule-form input[name="value"] { flex: 1; min-width: 180px; }
.inbox-note { padding: 4px 6px 10px; color: var(--text-faint); font-size: 11px; }
.inbox-digest { font-size: 12.5px; line-height: 1.8; }
.inbox-note-block { display: flex; align-items: center; gap: 10px; margin: -8px 0 22px; color: var(--text-soft); }
.inbox-note-block button { margin-left: auto; flex: none; }
.inbox-digest h1, .inbox-digest h2, .inbox-digest h3 { margin: 4px 0 8px; font-size: 13px; font-weight: 650; }
.inbox-digest p { margin: 0 0 6px; }

.inbox-rule-test { margin-bottom: 16px; }
.inbox-rule-test .h5 { display: flex; align-items: center; gap: 8px; margin-top: 0; }
.inbox-rule-test .h5 .ghost-button { margin-left: auto; }
.inbox-rule-test p { margin: 6px 0 10px; font-size: 12px; color: var(--text-soft); }
.link-button { padding: 0; border: 0; background: none; color: var(--blue); font: inherit; cursor: pointer; text-align: left; }
.link-button:hover { text-decoration: underline; }

.inbox-rule-ai { margin-bottom: 16px; }
.inbox-rule-ai .h5 { margin-top: 0; flex-wrap: wrap; }
.inbox-rule-ai-row { display: flex; gap: 6px; }
.inbox-rule-ai-row input { flex: 1; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.inbox-rule-ai-error { margin: 8px 0 0; color: var(--red); font-size: 12px; }
.inbox-rule-ai-draft { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--blue-soft); font-size: 12px; }
.inbox-rule-ai-draft p { margin: 0; }
.inbox-rule-ai-draft .s { display: block; margin-top: 2px; }

.inbox-mute { display: inline-flex; align-items: stretch; }
.inbox-mute .inbox-scope { height: 28px; padding: 0 22px 0 9px; border: 1px solid var(--line-strong); border-right: 0; border-radius: 6px 0 0 6px; background: var(--surface); color: var(--text-soft); font-size: 11.5px; }
.inbox-mute .ghost-button { border-radius: 0 6px 6px 0; }
