/* COS Web 界面。系统字体，无外部资源；浅色 / 深色跟随系统。 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --text: #1d2330;
  --muted: #6b7385;
  --border: #e2e5ea;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --accent-soft: #e8f0fd;
  --ok: #1f8a4c;
  --ok-soft: #e4f5ea;
  --warn: #b26a00;
  --warn-soft: #fdf1dc;
  --bad: #c9372c;
  --bad-soft: #fde8e6;
  --info: #2f6fde;
  --info-soft: #e8f0fd;
  --code-bg: #f4f5f7;
  --diff-add: #e6f6ea;
  --diff-add-text: #19632f;
  --diff-del: #fdecea;
  --diff-del-text: #a1271d;
  --diff-hunk: #eef1fb;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 1px 1px rgba(20, 30, 50, .04);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --panel: #1c2027;
    --panel-2: #232831;
    --text: #e3e6eb;
    --muted: #949cab;
    --border: #2e343e;
    --accent: #5b8ff0;
    --accent-soft: #1f2d47;
    --ok: #4cc27a;
    --ok-soft: #173023;
    --warn: #e0a440;
    --warn-soft: #352a15;
    --bad: #ef6b61;
    --bad-soft: #3a1d1b;
    --info: #6f9cf3;
    --info-soft: #1f2d47;
    --code-bg: #20252d;
    --diff-add: #15301f;
    --diff-add-text: #8be0a6;
    --diff-del: #3a1c1b;
    --diff-del-text: #f3a39c;
    --diff-hunk: #1f2740;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 24px 0 10px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); }
.bad-text, .err-text { color: var(--bad); }
.warn-text { color: var(--warn); }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 20px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 14px;
}
.nav { display: none; gap: 2px; flex: 1; }
body.authed .nav { display: flex; }
.nav a {
  position: relative; padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count {
  display: inline-block; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600;
}
.user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.me { font-weight: 600; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.live-poll, .live-reconnecting { background: var(--warn); }
.menu { display: none; background: none; border: 0; font-size: 20px; color: var(--text); cursor: pointer; padding: 4px 6px; }

.stale {
  position: sticky; top: 52px; z-index: 9; display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 6px; background: var(--warn-soft); color: var(--warn); font-size: 13px;
}

.main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.subcard { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 8px 0; background: var(--panel-2); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 a.muted { color: var(--muted); font-weight: 500; }
.page-head .btn { margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row:first-child { margin-top: 0; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.gap-lg { gap: 32px; }
.section-title { font-weight: 600; margin: 16px 0 8px; font-size: 13px; color: var(--muted); }
.section-title:first-child { margin-top: 0; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid > .card { margin-bottom: 0; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cards > .card { margin-bottom: 0; }
.card-title { font-weight: 600; font-size: 15px; color: var(--text); }
.big { font-size: 26px; font-weight: 700; line-height: 1.2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.loading::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(1.08); }
.btn-danger-ghost { color: var(--bad); border-color: var(--bad-soft); }
.btn-danger-ghost:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 22px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

.badge {
  display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; line-height: 20px; white-space: nowrap;
}
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-muted { background: var(--panel-2); color: var(--muted); }
.tag {
  display: inline-block; padding: 0 6px; margin-right: 4px; border-radius: 4px; border: 1px solid var(--border);
  font-size: 11.5px; line-height: 18px; color: var(--muted); white-space: nowrap;
}
.prio { font-weight: 600; font-size: 12px; }
.prio-0 { color: var(--bad); }
.prio-1 { color: var(--warn); }
.member { white-space: nowrap; }
.mi {
  display: inline-block; margin-right: 4px; padding: 0 4px; border-radius: 4px; background: var(--info-soft); color: var(--info);
  font-size: 10px; font-weight: 700; line-height: 15px; vertical-align: 1px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  padding: 3px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.chip:hover { text-decoration: none; color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--muted); font-size: 12.5px; background: var(--panel-2); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl.hover tbody tr:hover { background: var(--panel-2); }
.tbl tr.sub td { padding-top: 0; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }

.loading-block { display: flex; align-items: center; gap: 10px; padding: 24px 4px; color: var(--muted); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-bad { background: var(--bad-soft); color: var(--bad); }

.meter { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin: 6px 0; min-width: 80px; }
.meter-fill { height: 100%; border-radius: 3px; }
.tone-bg-ok { background: var(--ok); }
.tone-bg-warn { background: var(--warn); }
.tone-bg-bad { background: var(--bad); }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li { padding: 6px 0; border-bottom: 1px solid var(--border); }
ul.plain > li:last-child { border-bottom: 0; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 6px; }
.lbl { font-size: 13px; font-weight: 600; margin-top: 8px; }
input, textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font: inherit;
}
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.err { color: var(--bad); font-size: 13px; margin: 4px 0; }
.inline-form { display: flex; gap: 6px; flex: 1; min-width: 220px; }
.inline-form input { height: 28px; padding: 2px 8px; font-size: 12.5px; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }

.login { display: grid; place-items: center; min-height: 60vh; }
.login-card { width: 100%; max-width: 420px; padding: 28px; }
.login-card h1 { display: flex; align-items: center; gap: 10px; font-size: 22px; margin: 0 0 8px; }
.login-card button { margin-top: 12px; }

/* ---------- 待办 ---------- */
.items { display: flex; flex-direction: column; gap: 10px; }
.item { padding: 0; margin: 0; overflow: hidden; }
.item-head { display: flex; gap: 12px; padding: 14px 16px; cursor: pointer; align-items: flex-start; }
.item-head:hover { background: var(--panel-2); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.item-summary { margin-top: 4px; color: var(--text); opacity: .85; overflow-wrap: anywhere; }
.chev { color: var(--muted); }
.kind {
  flex: none; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 20px; margin-top: 1px;
  background: var(--panel-2); color: var(--muted);
}
.kind-approval { background: var(--warn-soft); color: var(--warn); }
.kind-review { background: var(--info-soft); color: var(--info); }
.kind-discussion { background: var(--ok-soft); color: var(--ok); }
.kind-blocked { background: var(--bad-soft); color: var(--bad); }
.item-body { padding: 4px 16px 12px; border-top: 1px solid var(--border); }
.item-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--panel-2); }

.comments { list-style: none; padding: 0; margin: 0 0 12px; }
.comments li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comments li .md > :last-child { margin-bottom: 0; }

/* ---------- 交付物与差异 ---------- */
.delivs { display: flex; flex-direction: column; gap: 8px; }
.deliv { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--panel); }
.deliv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deliv-title { font-weight: 600; }
.deliv-uri { margin: 2px 0 0; overflow-wrap: anywhere; color: var(--muted); }
.diff-box:not(:empty), .file-box:not(:empty) { margin-top: 10px; }
pre.stat { background: var(--code-bg); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.diff-file { border: 1px solid var(--border); border-radius: 6px; margin: 6px 0; overflow: hidden; }
.diff-file > summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; cursor: pointer;
  background: var(--panel-2); font-size: 12.5px;
}
.diff-file > summary .btn { margin-left: auto; }
.add { color: var(--ok); font-family: var(--mono); font-size: 12px; }
.del { color: var(--bad); font-family: var(--mono); font-size: 12px; }
pre.diff { margin: 0; padding: 4px 0; overflow-x: auto; line-height: 1.45; background: var(--panel); }
.dl { display: inline-block; min-width: 100%; padding: 0 10px; white-space: pre; }
.dl-add { background: var(--diff-add); color: var(--diff-add-text); }
.dl-del { background: var(--diff-del); color: var(--diff-del-text); }
.dl-hunk { background: var(--diff-hunk); color: var(--muted); }
.dl-meta, .dl-file { color: var(--muted); }
.file-view { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.file-view-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--panel-2); }
.file-view .md { padding: 4px 14px; }
.file-view pre.code { margin: 0; border-radius: 0; }

/* ---------- Markdown ---------- */
.md { overflow-wrap: anywhere; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; } .md h4, .md h5, .md h6 { font-size: 14px; }
.md p { margin: 6px 0; }
.md ul, .md ol { padding-left: 22px; margin: 6px 0; }
.md blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.md table { margin: 0; }
.md .table-wrap { margin: 8px 0; }
.md th, .md td { border-bottom: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--panel-2); }
pre.code { background: var(--code-bg); padding: 10px 12px; border-radius: 6px; overflow-x: auto; line-height: 1.45; white-space: pre; }
pre.code code { background: none; padding: 0; }

/* ---------- 项目进度 ---------- */
.stages { display: flex; list-style: none; padding: 0; margin: 10px 0 6px; gap: 0; overflow-x: auto; }
.stage { position: relative; flex: 1; min-width: 72px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); text-align: center; }
.stage::before {
  content: ""; position: absolute; top: 6px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0;
}
.stage:first-child::before { display: none; }
.stage .dot { position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2px solid var(--border); }
.stage-done .dot { background: var(--ok); border-color: var(--ok); }
.stage-done::before, .stage-current::before, .stage-blocked::before { background: var(--ok); }
.stage-current .dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stage-current, .stage-blocked { color: var(--text); font-weight: 600; }
.stage-blocked .dot { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.stage-cancelled .dot { background: var(--muted); border-color: var(--muted); }
.gate { font-size: 10px; padding: 0 4px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }

/* ---------- 资产、看板 ---------- */
.hits { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.hits .card { margin: 0; }
.snippet { margin-top: 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.budget-nums { margin: 6px 0 2px; }
.stat-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.stat .big { margin: 4px 0 6px; }
.stat-inbox .big { color: var(--accent); font-size: 34px; }
.stat-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.stat-list li { display: flex; justify-content: space-between; padding: 2px 0; }
.stat-list a { color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.timeline li:last-child { border-bottom: 0; }
.timeline li > .small:first-child { min-width: 72px; }

/* ---------- 提示、对话框 ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  padding: 10px 16px; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: 0 4px 12px rgba(0,0,0,.18);
  font-size: 13px; transition: opacity .4s, transform .4s;
}
.toast-bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
dialog.dlg {
  width: min(480px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  background: var(--panel); color: var(--text); box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog.dlg::backdrop { background: rgba(10, 14, 22, .45); }
dialog.dlg h3 { margin: 0 0 10px; overflow-wrap: anywhere; }
dialog.dlg .row { margin-top: 14px; }

/* ---------- 窄屏 ---------- */
/* ---------- 研发交付 ---------- */
.dl-note { display: inline-block; min-width: 100%; box-sizing: border-box; margin: 2px 0; padding: 4px 10px 4px 24px; white-space: pre-wrap;
  font-family: var(--font); background: var(--warn-soft); border-left: 3px solid var(--warn); }
.dl-note.stale { opacity: .65; }
.gate-list { list-style: none; padding: 0; margin: 0 0 8px; }
.gate-list li { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.gate-list li:last-child { border-bottom: 0; }
.gate-mark { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.gate-list li.ok .gate-mark { background: var(--ok-soft); color: var(--ok); }
.gate-list li.no .gate-mark { background: var(--bad-soft); color: var(--bad); }
.gate-list li.note .gate-mark { background: var(--warn-soft); color: var(--warn); }
.steps { list-style: none; padding: 0; margin: 8px 0; }
.steps li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: 0; }
pre.log { margin: 6px 0 0; padding: 8px 10px; max-height: 360px; overflow: auto; background: var(--code-bg); border-radius: 6px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.line-comments { list-style: none; padding: 0; margin: 6px 0 0; }
.line-comments li { padding: 3px 0 3px 10px; border-left: 3px solid var(--warn); margin: 3px 0; }
.env-current { margin: 6px 0 2px; font-size: 15px; }
.deploy-form input { min-width: 0; }

@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .menu { display: none; }
  body.authed .menu { display: block; }
  body.authed .nav {
    display: none; position: absolute; top: 52px; left: 0; right: 0; flex-direction: column;
    background: var(--panel); border-bottom: 1px solid var(--border); padding: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.08);
  }
  body.authed.nav-open .nav { display: flex; }
  .nav a { padding: 10px 12px; }
  .me { display: none; }
  .main { padding: 16px 12px 48px; }
  .card { padding: 14px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 6px; font-size: 12px; }
  .cards, .grid.two { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .item-head { padding: 12px; }
  .item-actions { padding: 10px 12px; }
  .item-actions .btn { flex: 1; }
  .tbl th, .tbl td { padding: 8px; }
  .inline-form { min-width: 0; width: 100%; }
}

/* ---------- 管家对话（#/chat） ---------- */
.main:has(> .view > .chat) { max-width: 920px; padding-top: 12px; padding-bottom: 12px; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 52px - 24px); height: calc(100dvh - 52px - 24px); min-height: 360px; }
.chat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; }
.chat-head .chat-inbox { margin-left: auto; }
.chat-head .chat-inbox .count { margin-left: 4px; }
.chat-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.chat-older { text-align: center; margin-bottom: 8px; }
.msg-wrap + .msg-wrap { margin-top: 12px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg-bubble { max-width: min(680px, 92%); padding: 8px 12px; border-radius: 12px; background: var(--panel-2); overflow-wrap: anywhere; }
.msg-bubble > :first-child { margin-top: 0; }
.msg-bubble > :last-child { margin-bottom: 0; }
.msg-plain { white-space: pre-wrap; }
.msg-user { align-items: flex-end; }
.msg-user .msg-bubble { background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg-butler .msg-bubble { border-bottom-left-radius: 4px; }
.msg-system { align-items: center; }
.msg-system .msg-meta { display: none; }
.msg-system .msg-bubble { background: transparent; color: var(--muted); font-size: 12.5px; padding: 2px 8px; text-align: center; }
.msg-refs { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ref-plain { color: var(--muted); }
.msg-streaming .caret { display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; background: var(--muted); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-stream:not(:empty) { margin-top: 12px; }
.chat-status { display: flex; align-items: center; gap: 8px; padding: 6px 4px 0; font-size: 12.5px; color: var(--muted); }
.chat-status .btn { margin-left: auto; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding-top: 8px; }
.chat-input textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 200px; padding: 9px 12px; line-height: 1.45;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit;
}
.chat-input textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.chat-input .btn { height: 40px; }

/* 管家卡片：确认卡（待确认为黄、高风险为红）、信息卡（蓝） */
.bcard {
  width: min(680px, 100%); margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border);
  border-left: 3px solid var(--info); border-radius: 8px; background: var(--panel);
}
.bcard-confirm { border-left-color: var(--warn); }
.bcard-danger { border-color: var(--bad); border-left-color: var(--bad); background: var(--bad-soft); }
.bcard-state-confirmed { border-left-color: var(--ok); }
.bcard-state-declined, .bcard-state-expired { border-left-color: var(--muted); opacity: .85; }
.bcard-state-failed { border-left-color: var(--bad); }
.bcard-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bcard-kind { font-size: 12px; color: var(--muted); }
.bcard-danger .bcard-kind { color: var(--bad); font-weight: 600; }
.bcard-title { overflow-wrap: anywhere; }
.bcard .md { margin-top: 4px; }
.bcard-summary { margin-top: 6px; font-size: 13px; }
.bcard-danger .bcard-summary { color: var(--bad); font-weight: 600; }
.bcard-subject { margin-top: 6px; }
.bcard-live:not(:empty) { margin-top: 6px; }
.bcard-actions { margin-top: 8px; }
.bcard-result { margin-top: 8px; padding: 4px 8px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }
pre.bcard-diff { margin: 6px 0 0; max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.bcard-status table { font-family: var(--mono); font-size: 12.5px; }

/* 右侧详情抽屉（窄屏全屏） */
.drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; z-index: 20; width: min(560px, 92vw);
  display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(10, 14, 22, .12);
}
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.drawer-title { font-weight: 600; margin-right: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px 40px; }
.drawer-body .page-head h2 { font-size: 17px; }

@media (max-width: 760px) {
  .main:has(> .view > .chat) { padding: 8px; }
  .chat { height: calc(100vh - 52px - 16px); height: calc(100dvh - 52px - 16px); }
  .chat-log { padding: 10px 8px; }
  .msg-bubble { max-width: 96%; }
  .drawer { top: 0; width: 100vw; z-index: 30; border-left: 0; }
  .bcard-actions .btn { flex: 1; }
}
