/* 控制台的样式。设计语言和 App 外壳是同一套（apps/flutter/lib/src/ui/shell/tokens.dart）：
   靠底色深浅分层，不靠边框和投影；一套圆角；动效只用一条曲线。
   页面的 CSP 只许本站资源（console.rs），所以不引外部字体，小图标用 CSS 画或 data: 地址。 */
:root {
  /* 底色从浅到深：页面、侧栏、卡片；再往下是输入框和按钮。 */
  --app: #fdfdfd;
  --panel: #f6f6f5;
  --card: #f1f1f0;
  --inset: #e9e9e8;
  --control: #e4e4e3;
  --control-hover: #d9d9d8;
  --raised: #e6e6e5;
  --hover: rgba(28, 28, 28, 0.05);
  /* 分隔线只在必须分开的地方用。 */
  --edge: rgba(28, 28, 28, 0.08);
  --hairline: rgba(28, 28, 28, 0.18);

  --ink: #1c1c1c;
  --ink-2: rgba(28, 28, 28, 0.68);
  --ink-3: rgba(28, 28, 28, 0.56);
  --accent: #126fd4;
  --accent-ink: #0b69cc;
  --accent-soft: rgba(18, 111, 212, 0.1);
  /* 主按钮用墨色；人写的消息也是墨色气泡。 */
  --solid: #1c1c1c;
  --solid-hover: #333332;
  --solid-ink: #fcfcfc;
  --bubble: #1c1c1c;
  --bubble-ink: #fcfcfc;
  --ok: #007a44;
  --ok-soft: rgba(0, 122, 68, 0.1);
  --danger: #cd2834;
  --danger-soft: rgba(205, 40, 52, 0.08);
  --on-danger: #ffffff;
  --warn: #9c5b00;
  --warn-soft: rgba(196, 122, 0, 0.12);
  --scrim: rgba(28, 28, 28, 0.32);
  --shadow-float: 0 4px 12px -1px rgba(28, 28, 28, 0.08), 0 2px 4px -2px rgba(28, 28, 28, 0.06);
  --shadow-pop: 0 18px 48px -16px rgba(28, 28, 28, 0.28), 0 2px 6px -2px rgba(28, 28, 28, 0.08);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%231c1c1c' stroke-opacity='.62' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* 圆角：一套，从小到大。 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-pill: 999px;
  /* 动效：一条曲线（快出慢停）。 */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 120ms;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  /* 对话栏最宽 860px，窗口再宽就居中。 */
  --col-pad: max(16px, calc((100% - 860px) / 2));
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --app: #121212;
    --panel: #0e0e0e;
    --card: #1d1d1d;
    --inset: #262626;
    --control: #2a2a2a;
    --control-hover: #343434;
    --raised: #232323;
    --hover: rgba(245, 245, 245, 0.06);
    --edge: rgba(245, 245, 245, 0.08);
    --hairline: rgba(245, 245, 245, 0.2);
    --ink: #f5f5f5;
    --ink-2: rgba(245, 245, 245, 0.68);
    --ink-3: rgba(245, 245, 245, 0.54);
    --accent: #3d8ef0;
    --accent-ink: #5aa2ff;
    --accent-soft: rgba(77, 155, 255, 0.16);
    --solid: #f5f5f5;
    --solid-hover: #dcdcdc;
    --solid-ink: #121212;
    --bubble: #3b3b3b;
    --bubble-ink: #f5f5f5;
    --ok: #00ba69;
    --ok-soft: rgba(0, 186, 105, 0.14);
    --danger: #ff6463;
    --danger-soft: rgba(255, 100, 99, 0.14);
    --on-danger: #1a0707;
    --warn: #e28600;
    --warn-soft: rgba(226, 134, 0, 0.16);
    --scrim: rgba(0, 0, 0, 0.56);
    --shadow-float: 0 4px 14px -2px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 18px 48px -16px rgba(0, 0, 0, 0.7);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23f5f5f5' stroke-opacity='.62' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--app);
  color: var(--ink);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { display: flex; flex-direction: column; height: 100%; }
h2, h3 { letter-spacing: -0.005em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* 按钮：胶囊形，默认是一块浅底，主按钮是墨色。 */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 0; background: var(--control); border-radius: var(--r-pill);
  padding: 5px 14px; min-height: 32px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease);
}
button:hover:not(:disabled) { background: var(--control-hover); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--solid); color: var(--solid-ink); }
button.primary:hover:not(:disabled) { background: var(--solid-hover); }
button.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--hairline); }
button.ghost:hover:not(:disabled) { background: var(--hover); }
button.link {
  background: none; color: var(--accent-ink); padding: 0 4px; min-height: 0; border-radius: var(--r-sm);
  font-weight: inherit; white-space: normal;
}
button.link:hover:not(:disabled) { background: none; text-decoration: underline; text-underline-offset: 2px; }
button.link:active:not(:disabled) { transform: none; }
button.danger { color: var(--danger); }
button.small { min-height: 26px; padding: 2px 10px; }
.small { font-size: 12px; }
.muted { color: var(--ink-2); font-weight: normal; }
.mono { font-family: var(--mono); font-size: 12px; }
.error { color: var(--danger); margin: 0; min-height: 1em; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 输入框：填色、没有边框，聚焦时描一圈强调色。卡片里的输入框用页面的底色，像凹进去一块。 */
input:not([type='checkbox']):not([type='radio']), select, textarea {
  border: 0; border-radius: var(--r-md); background-color: var(--inset); padding: 7px 12px; min-width: 0;
  outline: 0; box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
input:not([type='checkbox']):not([type='radio']):focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 0; box-shadow: inset 0 0 0 1.5px var(--accent);
}
.card input:not([type='checkbox']):not([type='radio']), .card select, .card textarea {
  background-color: var(--app); box-shadow: inset 0 0 0 1px var(--edge);
}
.card input:not([type='checkbox']):not([type='radio']):focus-visible, .card select:focus-visible, .card textarea:focus-visible {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
::placeholder { color: var(--ink-3); opacity: 1; }
input[type='search'] { -webkit-appearance: none; appearance: none; }
input[type='checkbox'] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
select {
  -webkit-appearance: none; appearance: none; padding-right: 30px; cursor: pointer;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 10px center;
}
textarea { line-height: 1.55; }

/* 顶栏 */
header.top {
  display: flex; align-items: center; gap: 6px 14px; padding: 8px 16px; min-height: 52px; flex-wrap: wrap;
  background: var(--app); border-bottom: 1px solid var(--edge);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: -0.01em; }
.brand::before {
  content: ''; width: 22px; height: 22px; border-radius: var(--r-sm); flex-shrink: 0;
  background: url('icon.svg') center / cover;
}
nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
nav a {
  display: inline-flex; align-items: center; color: var(--ink-2); text-decoration: none; white-space: nowrap;
  padding: 5px 11px; border-radius: var(--r-pill);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
nav a.active { color: var(--ink); background: var(--raised); font-weight: 500; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px;
  background: var(--danger); color: var(--on-danger); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}
/* 连接状态：一个小圆点加两三个字。 */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); padding: 0 4px; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status.open::before { background: var(--ok); }
.status.closed { color: var(--danger); }
.status.closed::before { background: var(--danger); }
.status.connecting::before { background: var(--warn); animation: breathe 1s ease-in-out infinite alternate; }
@keyframes breathe { from { opacity: 1; } to { opacity: 0.35; } }

main { flex: 1; min-height: 0; display: flex; }
main > section { flex: 1; min-width: 0; }

/* 各页：居中的一栏卡片。 */
.router, .tasks, .approvals, .inbox, .memory, .devices {
  padding: 24px 20px 48px; display: flex; flex-direction: column; gap: 14px;
  max-width: 960px; margin: 0 auto; width: 100%; overflow: auto;
}
.card { background: var(--card); border-radius: var(--r-xl); padding: 18px 20px; }
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; line-height: 1.45; }
.card p { margin: 0 0 10px; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.placeholder { max-width: 640px; margin: 72px auto; padding: 0 20px; }
.placeholder h2 { font-size: 20px; margin: 0 0 8px; }

/* 表格：只留行与行之间的细线。 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--edge); vertical-align: top; }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; padding-top: 4px; padding-bottom: 8px; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
td .muted { font-size: 12px; }
td select { border-radius: var(--r-pill); padding: 4px 28px 4px 12px; font-size: 13px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * { margin-left: 8px; }
table + p { margin-top: 12px; }

/* 待办、审批 */
.approvals h2, .inbox h2 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 14px 2px -4px; }
.approvals h2:first-child, .inbox h2:first-child { margin-top: 0; }
.inbox-empty { margin: 0 2px 4px; color: var(--ink-2); }
.done-list { list-style: none; margin: 0; padding: 0; }
.done-list li { padding: 10px 0; border-top: 1px solid var(--edge); }
.done-list li:first-child { border-top: 0; padding-top: 0; }
.done-list li:last-child { padding-bottom: 0; }
.done-list summary, .reports details summary { cursor: pointer; }
.approval h3 { font-size: 16px; }
.approval.resolved { opacity: 0.72; }
.options { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 12px; }
.options button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; white-space: normal;
  max-width: 300px; padding: 10px 14px; border-radius: var(--r-lg); font-weight: 400;
  background: var(--app); box-shadow: inset 0 0 0 1px var(--edge);
}
.options button:hover:not(:disabled) { background: var(--app); box-shadow: inset 0 0 0 1px var(--hairline); }
.options button strong { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.options button .muted { font-size: 12px; }
.options button.recommended { box-shadow: inset 0 0 0 1.5px var(--accent); }
.options button.chosen { box-shadow: inset 0 0 0 1.5px var(--ok); opacity: 1; }
.options button.chosen strong::before { content: '✓'; color: var(--ok); }
.options button:disabled:not(.chosen) { opacity: 0.6; }
.tag {
  font-size: 11px; font-weight: 500; line-height: 18px; padding: 0 7px; border-radius: var(--r-pill);
  color: var(--accent-ink); background: var(--accent-soft); white-space: nowrap;
}

/* 任务 */
.tasks .card > input, .tasks .card > textarea { display: block; width: 100%; margin-bottom: 8px; }
.tasks .row select { flex: 1; min-width: 160px; }
.task-result { margin-top: 6px; font-size: 13px; }

/* 岗位与员工 */
.roles { padding: 24px 20px 48px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-content: start; overflow: auto; }
.roles .spend { grid-column: 1 / -1; margin: 0 2px 2px; }
.roles .card h3 { font-size: 16px; margin-bottom: 6px; }
.roles .card h3 .mono { margin-left: 4px; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; font-variant-numeric: tabular-nums; }
.card dt { color: var(--ink-3); }
.card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.roles dd.over { color: var(--danger); }
.agents { display: flex; gap: 8px; flex-wrap: wrap; }

/* 路由规则 */
.router .row input { flex: 1; }
.decision { margin: 12px 0 0; padding: 8px 12px; border-radius: var(--r-md); background: var(--ok-soft); }
.decision.ask { color: var(--danger); background: var(--danger-soft); }
.rules { padding-left: 22px; margin: 4px 0 14px; display: flex; flex-direction: column; gap: 12px; }
.rules li::marker { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rules .mono { color: var(--ink-2); }
.drafts .draft { border-top: 1px solid var(--edge); padding: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.drafts .draft:last-child { padding-bottom: 0; }
.drafts .draft .row { margin-top: 6px; }
.rule-editor { display: flex; flex-direction: column; gap: 12px; }
.rule-editor > p, .rule-editor > h3 { margin: 0; }
.rule-form { background: var(--app); box-shadow: inset 0 0 0 1px var(--edge); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.rule-form input:not([type='checkbox']), .rule-form select { background-color: var(--card); box-shadow: none; }
.rule-form .row input { flex: 1; }
.rule-form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.rule-form .grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-3); }
.rule-form .grid input { font-size: 14px; color: var(--ink); }

/* 记忆 */
.memory textarea { display: block; width: 100%; resize: vertical; font-family: var(--mono); font-size: 13px; }
.memory .card .row { margin-top: 10px; }
.notice { margin: 0; padding: 9px 14px; border-radius: var(--r-md); background: var(--warn-soft); }
.memory-text { white-space: pre-wrap; word-break: break-word; margin: 4px 0; }

/* 对话：左边列表，右边一栏消息。 */
.chat { display: flex; min-height: 0; }
.chat aside { width: 288px; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.chat aside input { margin: 12px 12px 8px; }
.list { overflow: auto; flex: 1; padding: 0 8px 12px; }
.list-head { padding: 4px 8px 8px; color: var(--ink-3); font-size: 12px; display: flex; justify-content: space-between; }
.item {
  display: block; width: 100%; min-height: 0; text-align: left; font-weight: 400; white-space: normal;
  border-radius: var(--r-md); padding: 8px 10px; margin-bottom: 2px; background: transparent;
}
.item:hover:not(:disabled) { background: var(--hover); }
.item:active:not(:disabled) { transform: none; }
.item.active, .item.active:hover:not(:disabled) { background: var(--raised); }
.item.new { font-weight: 500; margin-bottom: 8px; box-shadow: inset 0 0 0 1px var(--edge); background: var(--app); }
.item.new:hover:not(:disabled) { background: var(--app); box-shadow: inset 0 0 0 1px var(--hairline); }
.item.new.active { background: var(--raised); box-shadow: none; }
.item .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.thread-memory { padding: 6px var(--col-pad); font-size: 12px; color: var(--ink-3); border-bottom: 1px solid var(--edge); }
.messages { flex: 1; overflow: auto; padding: 20px var(--col-pad) 16px; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto; color: var(--ink-3); }
/* 员工的消息是一块浅底，人写的是墨色气泡，系统的话居中、不抢眼。 */
.msg { max-width: min(720px, 100%); padding: 10px 14px; border-radius: var(--r-xl); line-height: 1.65; }
.msg.agent { background: var(--card); border-bottom-left-radius: var(--r-sm); }
.msg.human {
  align-self: flex-end; max-width: min(560px, 88%); border-bottom-right-radius: var(--r-sm);
  background: var(--bubble); color: var(--bubble-ink);
}
.msg.human ::selection { background: rgba(128, 128, 128, 0.5); }
.msg.human .muted, .msg.human .who { color: inherit; opacity: 0.72; }
.msg.human button.ghost { box-shadow: inset 0 0 0 1px currentColor; opacity: 0.85; }
.msg.human button.danger { color: inherit; }
.msg.system { align-self: center; max-width: min(560px, 100%); padding: 6px 14px; background: var(--panel); color: var(--ink-2); font-size: 13px; border-radius: var(--r-lg); }
.msg.draft .who .muted { animation: breathe 0.9s ease-in-out infinite alternate; }
.msg .who { font-size: 12px; font-weight: 600; margin-bottom: 2px; color: var(--ink-2); }
.msg .who .muted { font-weight: 400; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.msg.human .who .muted { color: inherit; opacity: 1; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attachment { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.attachment-name { word-break: break-all; }
.attachment.deleted { opacity: 0.6; }
.attachment-preview { flex-basis: 100%; }
.attachment-preview img { display: block; max-width: min(320px, 100%); max-height: 240px; border-radius: var(--r-md); }
/* 工具调用收成一行小胶囊，点开看输入输出。 */
.tool { max-width: min(720px, 100%); font-size: 12px; color: var(--ink-2); }
.tool + .tool { margin-top: -6px; }
.tool summary {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; list-style: none;
  padding: 3px 12px 3px 10px; border-radius: var(--r-pill); background: var(--panel);
  transition: background var(--fast) var(--ease);
}
.tool summary::-webkit-details-marker { display: none; }
.tool summary::before {
  content: ''; width: 5px; height: 5px; margin-top: -1px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); opacity: 0.7; transition: transform var(--fast) var(--ease);
}
.tool[open] summary::before { transform: rotate(45deg); margin-top: -3px; }
.tool summary:hover { background: var(--card); }
.tool.failed summary { color: var(--danger); background: var(--danger-soft); }
.tool.summary .text { white-space: pre-wrap; padding: 8px 2px 0; color: var(--ink); font-size: 13px; }
.tool pre {
  margin: 6px 0 0; background: var(--panel); border-radius: var(--r-md); padding: 10px 12px;
  overflow: auto; max-height: 320px; white-space: pre-wrap; word-break: break-all;
  font: 12px/1.55 var(--mono); color: var(--ink);
}
.turn-note { font-size: 12px; color: var(--ink-3); align-self: center; text-align: center; font-variant-numeric: tabular-nums; }
/* 输入区是浮着的一块：上面写字，下面一行选员工和发送。 */
.composer {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'input input' 'agent send'; gap: 6px 8px; align-items: center;
  margin: 0 var(--col-pad) 16px; padding: 10px 10px 10px 14px; border-radius: var(--r-2xl);
  background: var(--app); box-shadow: 0 0 0 1px var(--edge), var(--shadow-float);
  transition: box-shadow var(--fast) var(--ease);
}
.composer:focus-within { box-shadow: 0 0 0 1.5px var(--hairline), var(--shadow-float); }
.composer textarea, .composer textarea:focus-visible {
  grid-area: input; width: 100%; resize: none; padding: 4px 2px; border-radius: var(--r-sm);
  background: transparent; box-shadow: none; max-height: 40vh;
}
.composer select { grid-area: agent; justify-self: start; max-width: 100%; border-radius: var(--r-pill); padding: 5px 30px 5px 12px; font-size: 13px; background-color: var(--card); }
.composer button { grid-area: send; }

/* 宽屏不显示：窄屏底部导航栏的短名字、对话页的返回栏。 */
nav a .short, .thread-head { display: none; }
/* 窗口不够宽、又还没到手机布局时，顶栏只留图标，免得导航换行。 */
@media (min-width: 721px) and (max-width: 1040px) {
  .brand span { display: none; }
}

/* 窄屏（手机）：导航移到底部，对话页列表和对话分两屏，输入框字号 16px 免得 iOS 聚焦时放大。 */
@media (max-width: 720px) {
  #app { height: 100dvh; padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  header.top { gap: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; gap: 0; flex-wrap: nowrap;
    height: calc(56px + env(safe-area-inset-bottom)); padding: 0 2px env(safe-area-inset-bottom);
    background: var(--app); border-top: 1px solid var(--edge);
  }
  nav a, nav a:hover, nav a.active {
    flex: 1; justify-content: center; border-radius: 0; padding: 0; font-size: 13px; position: relative; background: none;
  }
  nav a .long { display: none; }
  nav a .short { display: inline; padding: 4px 9px; border-radius: var(--r-pill); transition: background var(--fast) var(--ease); }
  nav a.active { color: var(--ink); font-weight: 600; }
  nav a.active .short { background: var(--raised); }
  nav a .badge { position: absolute; top: 5px; left: calc(50% + 9px); margin: 0; }

  input:not([type='checkbox']):not([type='radio']), select, textarea,
  td select, .composer select, .memory textarea { font-size: 16px; }

  .chat { flex-direction: column; }
  .chat aside { width: auto; flex: 1; }
  .chat.pane-list .thread, .chat.pane-thread aside { display: none; }
  /* 竖排时对话区要能缩：不然消息一长，输入框就被挤到底部导航栏下面。 */
  .chat .thread, .chat aside { min-height: 0; }
  .item { padding: 11px 12px; }
  .thread-head {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    border-bottom: 1px solid var(--edge); font-weight: 600;
  }
  .thread-head button.link { padding: 4px 0; font-weight: normal; }
  .thread-memory { padding: 6px 12px; }
  .messages { padding: 12px; }
  .msg { max-width: 100%; }
  .msg.human { max-width: 88%; }
  .composer { margin: 0 8px 8px; padding: 8px 8px 8px 12px; }
  .composer textarea { min-height: 44px; }

  .roles, .tasks, .approvals, .inbox, .router, .memory, .devices { padding: 14px 12px 28px; gap: 12px; }
  .roles { grid-template-columns: 1fr; }
  .card { padding: 14px; border-radius: var(--r-lg); }
  .options { flex-direction: column; }
  .options button { max-width: none; width: 100%; min-height: 44px; }
  .card-head button { flex-shrink: 0; }
  table:not(.md-table) thead { display: none; }
  table:not(.md-table) tr { display: block; border-bottom: 1px solid var(--edge); padding: 8px 0; }
  table:not(.md-table) tr:last-child { border-bottom: 0; }
  table:not(.md-table) td { display: block; border: 0; padding: 2px 0; }
  td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 4.5em; color: var(--ink-3); font-size: 12px; }
  td.actions { text-align: left; }
  td.actions > * { margin: 0 12px 0 0; }
}

/* 员工回复的 Markdown（backlog F-3）。表格太宽时在气泡里横向滚动，不撑破页面。 */
.msg .text.md-text { white-space: normal; }
.md { min-width: 0; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md .table-wrap { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 16px 0 6px; line-height: 1.4; font-weight: 600; }
.md h1 { font-size: 19px; }
.md h2 { font-size: 16px; }
.md h3, .md h4, .md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 2px 0; }
.md li::marker { color: var(--ink-3); }
.md li.task { list-style: none; margin-left: -20px; }
.md li.task input { margin: 0 6px 0 0; vertical-align: -2px; }
.md code { font-family: var(--mono); font-size: 0.88em; background: var(--hover); border-radius: 5px; padding: 1px 5px; }
.md pre { background: var(--app); border-radius: var(--r-md); padding: 10px 12px; overflow-x: auto; box-shadow: inset 0 0 0 1px var(--edge); }
.md pre code { padding: 0; background: none; white-space: pre; font-size: 12px; line-height: 1.55; }
.md blockquote { border-left: 3px solid var(--hairline); padding-left: 12px; color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--edge); margin: 14px 0; }
.md .table-wrap { max-width: 100%; overflow-x: auto; }
.md table.md-table { width: auto; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.md table.md-table th, .md table.md-table td { border: 0; border-bottom: 1px solid var(--edge); padding: 6px 14px 6px 0; white-space: nowrap; }
.md table.md-table th { color: var(--ink-2); font-weight: 500; font-size: 12px; border-bottom-color: var(--hairline); }
.md table.md-table th:last-child, .md table.md-table td:last-child { padding-right: 0; }
.md table.md-table tr:last-child td { border-bottom: 0; }
.md .align-right { text-align: right; }
.md .align-center { text-align: center; }

/* 员工写的报告（backlog F-4）。 */
button.report-link { padding: 0; font: inherit; text-align: left; overflow-wrap: anywhere; }
.reports { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--edge); }
.report-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.reports details summary { margin-top: 6px; }
body.report-open { overflow: hidden; }
.overlay {
  position: fixed; inset: 0; z-index: 20; background: var(--scrim);
  display: flex; align-items: center; justify-content: center; padding: 28px;
  animation: fade 160ms var(--ease);
}
.report-view {
  background: var(--app); color: var(--ink); border-radius: var(--r-xl); box-shadow: var(--shadow-pop);
  width: 100%; max-width: 860px; max-height: 100%; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  animation: rise 240ms var(--ease);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
.report-view header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px 14px 24px; border-bottom: 1px solid var(--edge);
}
.report-title { min-width: 0; overflow-wrap: anywhere; }
.report-view header button { flex-shrink: 0; }
.report-body { overflow: auto; padding: 20px 24px 28px; min-height: 0; flex: 1; line-height: 1.7; }
.report-body .notice { margin: 0 0 12px; }
.report-body .md pre { background: var(--panel); box-shadow: none; }

/* 报告在手机上占满整屏。要放在上面几条后面才盖得住。 */
@media (max-width: 720px) {
  .overlay { padding: 0; }
  .report-view { max-width: none; height: 100%; border-radius: 0; box-shadow: none; }
  .report-view header { padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px; }
  .report-body { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
  .report-list li { padding: 4px 0; }
}

/* 设备（backlog F-7）。 */
.devices .row input:not([type='checkbox']) { flex: 1; min-width: 180px; }
.devices .notify .row { gap: 6px 16px; margin: 10px 0; }
.devices .online { color: var(--ok); }
.devices .online::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.pair-code {
  display: inline-block; font: 600 34px/1.2 var(--mono); letter-spacing: 8px; margin: 4px 0 10px;
  padding: 10px 10px 10px 18px; border-radius: var(--r-lg); background: var(--app); box-shadow: inset 0 0 0 1px var(--edge);
}
canvas.qr { display: block; width: 216px; max-width: 100%; height: auto; image-rendering: pixelated; margin: 8px 0; border-radius: var(--r-md); }

/* 桌面 App 的“连接主机”（backlog F-11） */
.connect label { display: block; margin: 12px 0; color: var(--ink-2); font-size: 13px; }
.connect input { display: block; width: 100%; margin-top: 4px; font-size: 14px; color: var(--ink); padding: 9px 12px; }
.connect .row { gap: 12px; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
