:root {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--fg);
  background: var(--canvas);
  font-size: 15px;

  /* 启明 tokens — the only colour source. No raw hex below this block. */
  --canvas: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --sunken: #eff4ff;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --line-strong: #cbd5e1;

  --fg: #0f172a;
  --fg-2: #475569;
  --fg-3: #5b6b82;
  --fg-4: #94a3b8;

  /* 对话阅读列的宽度：整列居中，用户与助手消息共用同一条中轴。 */
  --thread-w: 768px;
  --thread-gutter: 24px;

  --accent: #ea580c;
  --accent-strong: #b5450a;
  --accent-soft: #fff7ed;
  --accent-line: #fed7aa;
  --accent-hover: #c2410c;

  --sky: #0284c7;
  --sky-soft: #e6f1fb;
  --sky-strong: #0369a1;
  --violet: #6d28d9;
  --violet-soft: #f1ecfd;

  --ok: #067647;
  --ok-soft: #e7f6ef;
  --warn: #b54708;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --danger-line: #f4c7c3;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 26px -20px rgba(15, 23, 42, .18);
  --shadow-raised: 0 2px 4px rgba(15, 23, 42, .05), 0 16px 34px -22px rgba(15, 23, 42, .24);
  --shadow-glow: 0 0 0 1px rgba(234, 88, 12, .22), 0 10px 26px -18px rgba(234, 88, 12, .5);

  --font-sans: "Plus Jakarta Sans", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* legacy aliases kept so the chat styles below keep working */
  --muted: var(--fg-3);
  --card: var(--surface);
  --red: var(--danger);
  --green: var(--ok);
  --bg-sidebar: var(--surface);
  --bg-chat: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 720px; background: var(--bg-chat); }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
}

/* ---------- left sidebar ---------- */
.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand-row { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.brand-mark { font-size: 24px; color: var(--accent); line-height: 1; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.brand-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sidebar-actions { padding: 12px 20px 8px; }
.primary-button { width: 100%; border: 0; border-radius: 10px; height: 40px; font-weight: 600; background: var(--accent); color: #fff; transition: background .15s; }
.primary-button:hover { background: var(--accent-hover); }
.session-search { padding: 0 20px 10px; }
.session-search input { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--card); outline: none; color: var(--fg); }
.session-search input:focus { border-color: var(--accent); }

/* ---------- main conversation card + side threads ---------- */
.agent-avatar { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff; background: linear-gradient(140deg, var(--accent), #4a6cf7 55%, var(--accent-strong)); box-shadow: 0 2px 8px rgba(234, 88, 12, .28); }
.primary-thread { display: flex; align-items: center; gap: 11px; margin: 0 14px 10px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 12px; background: linear-gradient(180deg, var(--accent-soft), #ffffff); text-align: left; transition: box-shadow .15s, transform .15s; }
.primary-thread:hover { box-shadow: 0 6px 18px rgba(234, 88, 12, .14); }
.primary-thread.selected { box-shadow: 0 0 0 2px rgba(234, 88, 12, .18), 0 6px 18px rgba(234, 88, 12, .16); }
.primary-thread-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.primary-thread-name { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--fg); }
.primary-tag { font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; }
.primary-thread-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The side list is now the only list: it takes the remaining height and scrolls. */
.side-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 6px; }
.side-item { display: flex; align-items: center; gap: 7px; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-2); text-align: left; font-size: 12.5px; }
.side-item:hover { background: rgba(234, 88, 12, .06); }
.side-item.selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-item .history-delete { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 0 2px; opacity: 0; transition: opacity .1s; }
.side-item:hover .history-delete { opacity: .6; }
.side-item .history-delete:hover { opacity: 1; color: var(--red); }
.side-origin { flex: 0 0 auto; font-size: 10px; border-radius: 6px; padding: 1px 6px; background: var(--surface-2); color: var(--fg-3); }
.side-origin.origin-chat { background: var(--violet-soft); color: var(--violet); }
.side-origin.origin-task { background: var(--sky-soft); color: var(--sky-strong); }
.side-origin.origin-event { background: var(--warn-soft); color: var(--warn); }
.side-origin.origin-heartbeat { background: var(--ok-soft); color: var(--ok); }
.side-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-heading { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.history-heading b { font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 2px 7px; font-weight: 600; }
.history-day { color: var(--muted); font-size: 11px; font-weight: 600; padding: 10px 10px 6px; }
.history-empty { color: var(--muted); font-size: 13px; padding: 14px 12px; line-height: 1.6; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 8px 10px 10px; }
.footer-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-3); text-align: left; padding: 0 12px; font-size: 14px; transition: background .1s; }
.footer-item:hover { background: rgba(234, 88, 12, .06); }
.footer-count { margin-left: auto; font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 2px 7px; font-weight: 600; }
.profile-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 10px 10px 0; border-top: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.profile-row b { display: block; font-size: 13px; }
.profile-row small { color: var(--muted); font-size: 11px; }

/* ---------- center conversation ---------- */
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-chat); }
.conversation-header { height: 60px; flex: 0 0 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 32px; background: var(--card); border-bottom: 1px solid var(--line); }
.conversation-title { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
.conversation-title-text { display: flex; flex-direction: column; min-width: 0; }
.header-avatar { width: 30px; height: 30px; font-size: 13px; }
.conversation-title h1 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-id { font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backend-badge { display: flex; align-items: center; gap: 7px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); font-size: 12px; color: var(--fg-3); white-space: nowrap; }
.backend-badge.error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--red); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.red { background: var(--red); }
.dot.blue { background: var(--accent); }
.dot.green { background: var(--green); }

/* ---------- agent presence & notifications ---------- */
.header-right { display: flex; align-items: center; gap: 10px; }
.agent-status { display: flex; align-items: center; gap: 7px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); font-size: 12px; color: var(--fg-3); white-space: nowrap; cursor: default; }
.agent-status .dot.pulse { background: var(--green); box-shadow: 0 0 0 0 rgba(6, 118, 71, .5); animation: pulse 2s infinite; }
.agent-status.offline .dot { background: var(--muted); }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(6, 118, 71, 0); } 100% { box-shadow: 0 0 0 0 rgba(6, 118, 71, 0); } }
.notification-wrap { position: relative; }
.notification-button { position: relative; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); font-size: 15px; line-height: 1; transition: all .12s; }
.notification-button:hover { border-color: var(--accent); background: var(--accent-soft); }
.notification-badge { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.notification-panel { position: absolute; top: calc(100% + 12px); right: 0; width: 340px; max-height: 420px; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 44px rgba(0, 0, 0, .14); z-index: 25; overflow: hidden; }
.notification-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notification-clear { border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.notification-clear:hover { color: var(--accent); }
.notification-list { overflow-y: auto; min-height: 0; padding: 6px; }
.notification-empty { padding: 24px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.notification-item { display: flex; gap: 10px; padding: 10px 10px; border-radius: 10px; }
.notification-item:hover { background: var(--surface-2); }
.notification-icon { flex: 0 0 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; }
.notification-item.high .notification-icon { background: var(--danger-soft); color: var(--red); }
.notification-item.dream .notification-icon { background: var(--ok-soft); color: var(--green); }
.notification-body { min-width: 0; flex: 1; }
.notification-item-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--fg); }
.notification-item-time { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--muted); }
.notification-item-text { font-size: 12px; line-height: 1.6; color: var(--fg-3); margin-top: 3px; word-break: break-word; }

/* proactive agent message inserted into the conversation stream */
.agent-push { max-width: var(--thread-w); margin: 0 0 16px; border: 1px solid var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), #ffffff); border-radius: 14px; padding: 14px 16px; box-shadow: 0 2px 10px rgba(234, 88, 12, .06); }
.agent-push-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.agent-push-head .push-tag { background: var(--accent-soft); border-radius: 6px; padding: 2px 7px; font-size: 11px; }
.agent-push-head time { margin-left: auto; color: var(--muted); font-weight: 400; }
.agent-push-body { font-size: 14px; line-height: 1.75; color: var(--fg); }
.agent-push-body p { margin: 0 0 8px; }
.agent-push-body p:last-child { margin-bottom: 0; }
.agent-push-actions { margin-top: 10px; }
.agent-push-reply { border: 1px solid var(--line); background: var(--card); color: var(--accent); border-radius: 8px; padding: 5px 12px; font-size: 12px; }
.agent-push-reply:hover { border-color: var(--accent); background: var(--accent-soft); }

/* 整列居中：所有流内元素共用一条中轴，用户气泡在列内右对齐。 */
.conversation-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px var(--thread-gutter) 10px;
  display: flex; flex-direction: column; align-items: center;
  scroll-padding-bottom: 24px;
}
.conversation-scroll > * { flex: 0 0 auto; width: 100%; max-width: var(--thread-w); }

/* welcome */
.welcome { max-width: 580px; margin: 80px auto 0; text-align: center; }
.welcome-mark { width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 26px; display: grid; place-items: center; }
.welcome h2 { font-size: 22px; margin: 0 0 10px; font-weight: 700; }
.welcome p { font-size: 14px; line-height: 1.8; color: var(--muted); margin: 0 auto 20px; max-width: 460px; }
.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--fg-2); border-radius: 18px; padding: 8px 16px; font-size: 13px; transition: all .12s; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* messages */
.message { display: flex; gap: 12px; margin: 0 auto 18px; max-width: var(--thread-w); align-items: flex-start; }
.message.user { flex-direction: row-reverse; }
.message-avatar { display: none; }
.message-body { max-width: min(768px, 100%); min-width: 0; }
.message.assistant .message-body { width: 100%; }
.message.user .message-body { display: flex; flex-direction: column; align-items: flex-end; max-width: min(600px, 76%); }
.bubble { border-radius: 14px; padding: 11px 15px; font-size: 15px; line-height: 1.7; word-break: break-word; }
.message.user .bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; white-space: pre-wrap; }
.message.assistant .bubble { background: var(--card); border: 1px solid var(--line); border-top-left-radius: 4px; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; overflow-x: auto; font-size: 13px; line-height: 1.6; }
.bubble code { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; background: var(--sunken); border-radius: 4px; padding: 1px 5px; }
.bubble pre code { background: transparent; padding: 0; }
.bubble strong { font-weight: 700; }
.bubble table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.bubble th { background: var(--surface-2); font-weight: 600; }
.bubble tr:nth-child(even) { background: var(--surface-2); }
.message-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Next-step chips under a reply — the answer always offers a way forward. */
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.suggestions.hidden { display: none; }
.suggestion-chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg-2);
  font-size: 12.5px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.suggestion-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.suggestion-chip:active { transform: scale(.98); }
.suggestion-chip::after { content: " →"; opacity: .45; }
.message-error { margin-top: 8px; border: 1px solid var(--danger-line); background: var(--danger-soft); color: var(--red); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.stream-cursor { display: inline-block; width: 7px; height: 16px; vertical-align: -3px; margin-left: 3px; background: var(--accent); animation: blink 1s steps(2) infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* thinking */
/* thinking — 收成一个胶囊，不跟正文抢高度 */
.thinking { margin-bottom: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); font-size: 12px; width: fit-content; max-width: 100%; }
.thinking summary { cursor: pointer; padding: 4px 10px 4px 8px; color: var(--fg-3); list-style: none; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: "▸"; font-size: 9px; color: var(--fg-4); margin-right: 7px; display: inline-block; transition: transform .15s; }
.thinking[open] summary::before { transform: rotate(90deg); }
.thinking[open] summary { color: var(--fg-2); font-weight: 600; }
.thinking-content { padding: 0 14px 10px; color: var(--muted); white-space: pre-wrap; line-height: 1.6; max-height: 200px; overflow: auto; }

/* tool calls */
.tool-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
/* 工具调用折成一行：收起时只占一个胶囊，正文不被挤出视野。 */
.tool-fold { margin-bottom: 10px; }
.tool-fold.hidden { display: none; }
.tool-fold > summary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 8px; cursor: pointer; list-style: none;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
  font-size: 12px; color: var(--fg-3); transition: border-color .12s, color .12s;
}
.tool-fold > summary:hover { border-color: var(--accent-line); color: var(--accent-strong); }
.tool-fold > summary::-webkit-details-marker { display: none; }
.tool-fold > summary::before { content: "▸"; font-size: 9px; color: var(--fg-4); transition: transform .15s; }
.tool-fold[open] > summary::before { transform: rotate(90deg); }
.tool-fold[open] > summary { margin-bottom: 6px; }
.tool-fold-label { font-weight: 600; color: var(--fg-2); }
.tool-fold-count { font-weight: 500; color: var(--fg-4); font-family: var(--font-mono); font-size: 10.5px; }
.tool-fold .tool-list { margin-bottom: 0; }
.tool-item { border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); font-size: 12.5px; overflow: hidden; }
.tool-item summary { display: flex; align-items: center; gap: 7px; padding: 6px 10px; cursor: pointer; color: var(--fg-2); list-style: none; flex-wrap: nowrap; overflow: hidden; }
.tool-item summary::-webkit-details-marker { display: none; }
.tool-item .tool-name { font-weight: 600; color: var(--fg); }
.tool-item .tool-subtitle { font-size: 11px; color: var(--muted); margin-left: 8px; font-family: "SFMono-Regular", Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.tool-item .tool-spacer { flex: 1; }
.tool-item .tool-state { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--line-soft); color: var(--muted); }
.tool-item.running .tool-state { background: var(--accent-soft); color: var(--accent); }
.tool-item.completed .tool-state { background: var(--ok-soft); color: var(--green); }
.tool-item.error .tool-state { background: var(--danger-soft); color: var(--red); }
.tool-detail { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--card); }
.tool-detail pre { margin: 4px 0 0; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 12px; line-height: 1.6; color: var(--fg-2); }
.tool-detail .tool-label { font-size: 11px; color: var(--muted); }
.empty-answer { color: var(--muted); font-size: 14px; }

/* ---------- composer ---------- */
.composer-wrap { flex: 0 0 auto; width: 100%; max-width: calc(var(--thread-w) + var(--thread-gutter) * 2); margin: 0 auto; padding: 6px var(--thread-gutter) 14px; }
.composer-status { min-height: 18px; font-size: 12px; color: var(--muted); padding: 0 3px 6px; }
.composer-status.error { color: var(--red); }
.composer { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 12px rgba(0, 0, 0, .04); padding: 12px 14px 8px; transition: border-color .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 2px 16px rgba(234, 88, 12, .08); }

/* slash command menu */
.skill-chip { display: inline-block; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 1px 6px; font-size: 14px; font-weight: 600; line-height: 1.4; cursor: default; user-select: none; margin: 0 1px; vertical-align: middle; }
.skill-chip + br { display: none; }
.slash-menu { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 10px); max-height: 320px; overflow-y: auto; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 12px 40px rgba(234, 88, 12, .22), 0 4px 12px rgba(0, 0, 0, .08); z-index: 20; padding: 8px; }
.slash-menu.hidden { display: none !important; }
.slash-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-radius: 8px; background: #ffffff; padding: 8px 10px; color: var(--fg); cursor: pointer; transition: background .1s; }
.slash-item:hover, .slash-item.selected { background: var(--accent-soft); }
.slash-item.selected { outline: 1px solid var(--accent); outline-offset: -1px; }
.slash-item .slash-icon { font-size: 15px; color: var(--accent); flex: 0 0 20px; text-align: center; }
.slash-item .slash-text { min-width: 0; }
.slash-item .slash-name { display: block; font-size: 13px; font-weight: 600; color: var(--fg); }
.slash-item .slash-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slash-empty { padding: 12px 10px; font-size: 13px; color: var(--muted); text-align: center; }
.slash-loading { padding: 12px 10px; font-size: 13px; color: var(--muted); text-align: center; }
.composer .prompt { width: 100%; border: 0; outline: none; background: transparent; color: var(--fg); line-height: 1.6; min-height: 44px; max-height: 180px; font-size: 15px; white-space: pre-wrap; word-break: break-word; overflow-y: auto; }
.composer .prompt:empty::before { content: attr(data-placeholder); color: var(--fg-4); pointer-events: none; }
.composer-toolbar { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.toolbar-spacer { flex: 1; }
.pill { border: 1px solid var(--line); background: var(--card); color: var(--fg-3); border-radius: 8px; height: 32px; font-size: 13px; padding: 0 12px; transition: all .12s; }
.pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.send-button { width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; transition: background .15s; }
.send-button:hover { background: var(--accent-hover); }
.send-button:disabled { background: var(--line-strong); cursor: not-allowed; }
.stop-button { border: 1px solid var(--danger-line); background: var(--danger-soft); color: var(--red); border-radius: 8px; height: 32px; font-size: 13px; padding: 0 12px; }
.composer-hint { text-align: center; font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ---------- skills modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; z-index: 30; }
.skills-modal { width: min(720px, 86vw); max-height: 82vh; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .15); overflow: hidden; }
.skills-modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.skills-modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.skills-modal-head p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.skills-modal-head .icon-button { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.skills-modal-head .icon-button:hover { background: var(--sunken); }
.skills-search { padding: 12px 22px 6px; }
.skills-search input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; outline: none; background: var(--card); font-size: 14px; }
.skills-search input:focus { border-color: var(--accent); }
.skills-scroll { padding: 8px 22px 18px; overflow-y: auto; min-height: 0; }
.skills-group { margin-top: 14px; }
.skills-group h3 { margin: 0 0 8px; font-size: 13px; color: var(--fg-2); font-weight: 600; }
.skills-group h3 span { display: inline-block; margin-left: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 2px 7px; font-size: 11px; }
.skills-hint { margin: 0 0 10px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.skills-hint code { background: var(--sunken); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.skills-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skill-row { display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 10px 12px; color: var(--fg); transition: all .12s; }
.skill-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.skill-row b { display: block; font-size: 13px; font-weight: 600; }
.skill-row small { display: block; margin-top: 4px; font-size: 12px; line-height: 1.5; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.skills-empty { grid-column: 1 / -1; font-size: 13px; color: var(--muted); padding: 12px 2px; }
.skills-modal-foot { border-top: 1px solid var(--line); padding: 10px 22px; font-size: 11px; color: var(--muted); }

/* ---------- scheduled tasks ---------- */
.task-badge { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.tasks-modal { width: min(900px, 92vw); max-height: 84vh; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .15); overflow: hidden; }
.tasks-body { display: grid; grid-template-columns: 1.15fr 1fr; overflow: hidden; min-height: 0; }
.tasks-list-wrap { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.tasks-section-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.task-list { overflow-y: auto; min-height: 0; padding: 12px 14px 18px; }
.task-empty { color: var(--muted); font-size: 13px; padding: 22px 6px; text-align: center; line-height: 1.7; }
.task-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; margin-bottom: 10px; background: var(--card); }
.task-item.disabled { opacity: .64; background: var(--surface-2); }
.task-item-head { display: flex; align-items: center; gap: 8px; }
.task-item-head b { font-size: 13px; color: var(--fg); }
.task-state { margin-left: auto; flex: 0 0 auto; font-size: 11px; border-radius: 10px; padding: 2px 8px; background: var(--ok-soft); color: var(--green); }
.task-item.disabled .task-state { background: var(--line-soft); color: var(--muted); }
.task-state.error { background: var(--danger-soft); color: var(--red); }
.task-meta { font-size: 11px; color: var(--muted); margin-top: 7px; line-height: 1.7; word-break: break-word; }
.task-meta code { background: var(--sunken); border-radius: 4px; padding: 1px 5px; }
.task-result { font-size: 11px; line-height: 1.6; color: var(--fg-3); margin-top: 7px; padding: 7px 9px; background: var(--surface-2); border-radius: 8px; max-height: 78px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.task-result.error { color: var(--red); background: var(--danger-soft); }
.task-actions { display: flex; gap: 6px; margin-top: 10px; }
.task-actions button { border: 1px solid var(--line); background: var(--card); color: var(--fg-3); border-radius: 7px; padding: 4px 10px; font-size: 11px; }
.task-actions button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.task-actions button.danger:hover { border-color: var(--red); color: var(--red); background: var(--danger-soft); }
.task-actions .spacer { flex: 1; }
.task-form { padding: 16px 20px 22px; overflow-y: auto; min-height: 0; }
.task-form h3 { margin: 0 0 14px; font-size: 14px; }
.field { display: block; margin-bottom: 11px; }
.field > span { display: block; font-size: 12px; color: var(--fg-3); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: var(--card); color: var(--fg); outline: none; }
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.task-hint { font-size: 11px; line-height: 1.7; color: var(--muted); margin: -4px 0 12px; }
.task-hint code { background: var(--sunken); border-radius: 4px; padding: 1px 5px; }
.task-check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-3); margin: 4px 0 14px; }
.task-form-note { font-size: 11px; line-height: 1.7; color: var(--muted); margin: 10px 0 0; }
.task-form-note code { background: var(--sunken); border-radius: 4px; padding: 1px 5px; }

/* ── passive event stream ───────────────────────────────────── */
.events-modal { width: min(960px, 94vw); }
.events-modal .tasks-list-wrap .task-hint { padding: 10px 18px 0; margin: 0; border-bottom: 1px solid var(--line); }
.events-side h3 { margin-bottom: 12px; }
.events-section-label { font-size: 11px; font-weight: 700; color: var(--fg-3); letter-spacing: .02em; margin: 14px 0 7px; display: flex; justify-content: space-between; }
.events-section-label span { color: var(--muted); font-weight: 500; }
.event-run-item { border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 9px; background: var(--card); }
.event-run-item.phase-started { border-left-color: var(--accent); }
.event-run-item.phase-completed { border-left-color: var(--green); }
.event-run-item.phase-failed { border-left-color: var(--red); background: var(--danger-soft); }
.event-run-item.phase-skipped { border-left-color: var(--line-strong); background: var(--surface-2); }
.event-run-head { display: flex; align-items: center; gap: 8px; }
.event-run-head b { font-size: 12.5px; color: var(--fg); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-phase { flex: 0 0 auto; font-size: 10.5px; border-radius: 9px; padding: 2px 8px; background: var(--surface-2); color: var(--fg-3); }
.event-phase.started { background: var(--accent-soft); color: var(--accent); }
.event-phase.completed { background: var(--ok-soft); color: var(--green); }
.event-phase.failed { background: var(--danger-soft); color: var(--red); }
.event-run-meta { font-size: 10.5px; color: var(--muted); margin-top: 6px; line-height: 1.65; word-break: break-word; }
.event-run-meta code { background: var(--sunken); border-radius: 4px; padding: 1px 4px; }
.event-run-detail { font-size: 11px; line-height: 1.6; color: var(--fg-3); margin-top: 6px; padding: 7px 9px; background: var(--surface-2); border-radius: 7px; max-height: 76px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.event-run-detail.error { color: var(--red); background: var(--danger-soft); }
.event-cursor-list, .event-source-list { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow-y: auto; }
.event-cursor-item, .event-source-item { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 11px; line-height: 1.6; color: var(--fg-3); background: var(--surface-2); word-break: break-all; }
.event-cursor-item b, .event-source-item b { color: var(--fg); font-size: 11.5px; }
.event-cursor-item small, .event-source-item small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.event-actions { display: flex; gap: 8px; margin-top: 16px; }
.secondary-button { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--fg-3); border-radius: 8px; padding: 7px 10px; font-size: 12px; }
.secondary-button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.secondary-button:disabled { opacity: .55; }

@media (max-width: 900px) {
  .tasks-body { grid-template-columns: 1fr; overflow-y: auto; }
  .tasks-list-wrap { border-right: 0; border-bottom: 1px solid var(--line); }
  .task-list { overflow: visible; }
}

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--fg); color: #fff; border-radius: 10px; padding: 10px 18px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); z-index: 20; max-width: 70vw; }

@media (max-width: 768px) {
  body { min-width: 0; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   启明 shell — top bar, nav rail, overview dashboard
   Everything below uses tokens only; no raw colour values.
   ══════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jakarta-400.woff2") format("woff2");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/jakarta-500.woff2") format("woff2");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/jakarta-600.woff2") format("woff2");
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url("/fonts/jakarta-700.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("/fonts/mono-500.woff2") format("woff2");
}

body { margin: 0; min-width: 0; background: var(--canvas); color: var(--fg); }
::selection { background: var(--accent-line); }

.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  flex: 0 0 64px;
  height: 64px;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, 480px) max-content;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.tb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tb-mid { display: flex; justify-content: center; min-width: 0; }
.tb-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--accent);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 2px; padding: 7px; flex: none;
}
.brand-mark i { display: block; border-radius: 1px; background: var(--surface); opacity: .92; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4), .brand-mark i:nth-child(9) { opacity: .45; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.brand-text span { font-size: 11.5px; color: var(--fg-4); }

.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-3);
  white-space: nowrap;
}
.status-chip.error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }

.search-pill {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 36px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-pill:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-pill .search-icon { font-size: 14px; color: var(--fg-4); }
.search-pill input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 13px; color: var(--fg); }
.search-pill input::placeholder { color: var(--fg-4); }
.search-pill kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}

.tb-right .agent-status { border-radius: 999px; height: 28px; }
.tb-right .notification-button { width: 32px; height: 32px; font-size: 14px; }
.tb-right .backend-badge { height: 28px; border-radius: 999px; padding: 0 10px; }
.tb-avatar { width: 30px; height: 30px; font-size: 12px; border-radius: 50%; }

/* ---------- body grid ---------- */
.app-body {
  flex: 1; min-height: 0;
  display: grid; gap: 16px;
  padding: 16px 20px 20px;
}
.app-body[data-view="overview"] { grid-template-columns: 208px minmax(0, 1fr); }
.app-body[data-view="chat"] { grid-template-columns: 268px minmax(0, 1fr); }
.view { display: contents; }
.view.hidden { display: none; }

/* ---------- nav rail ---------- */
.nav-rail {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 16px 12px 12px;
  display: flex; flex-direction: column; gap: 18px;
  min-height: 0; overflow-y: auto;
}
.rail-group h4 {
  margin: 0 0 8px; padding-left: 10px;
  font-size: 11.5px; font-weight: 500; letter-spacing: .06em;
  color: var(--fg-4); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 36px; padding: 0 10px; margin-bottom: 2px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--fg-2);
  font-size: 13.5px; text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--fg); }
.nav-item.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); font-weight: 600; }
.nav-icon { width: 16px; text-align: center; font-size: 13px; color: var(--fg-4); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--fg-3);
}
.nav-item.active .nav-count { background: var(--surface); color: var(--accent-strong); }

.link-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 10px; font-size: 12.5px; color: var(--fg-3); }
.link-row b { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; color: var(--fg-2); max-width: 106px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-foot { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--line-soft); }
.rail-foot-head { display: flex; align-items: baseline; justify-content: space-between; font-size: 12.5px; color: var(--fg-3); }
.rail-foot-head b { font-family: var(--font-mono); font-size: 13px; color: var(--fg); }
.rail-bar { height: 4px; border-radius: 999px; background: var(--line-soft); margin: 8px 0 6px; overflow: hidden; }
.rail-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.rail-foot small { font-size: 11px; color: var(--fg-4); line-height: 1.5; display: block; }

/* ---------- overview ---------- */
.overview-main {
  min-height: 0; overflow-y: auto; padding-right: 6px;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-gutter: stable;
}
.overview-main::-webkit-scrollbar, .feed::-webkit-scrollbar, .mini-list::-webkit-scrollbar { width: 6px; }
.overview-main::-webkit-scrollbar-thumb, .feed::-webkit-scrollbar-thumb, .mini-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

.lede { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 2px 2px 0; }
.lede-text { min-width: 0; }
.lede h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; }
.lede p { margin: 6px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--fg-3); }
.lede-actions { display: flex; align-items: center; gap: 8px; flex: none; padding-top: 4px; }
.env-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-2);
}
.ghost-button {
  height: 30px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; color: var(--fg-2); transition: all .12s;
}
.ghost-button:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-strong); }

/* metric row */
.metric-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric-card {
  text-align: left; display: flex; flex-direction: column; gap: 10px;
  padding: 15px 16px 13px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card); transition: box-shadow .15s, border-color .15s, transform .15s;
}
.metric-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-raised); transform: translateY(-1px); }
.metric-top { display: flex; align-items: center; gap: 8px; }
.metric-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; flex: none; }
.metric-label { font-size: 12.5px; color: var(--fg-3); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-tag {
  margin-left: auto; flex: none; font-style: normal; font-size: 11px;
  padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--fg-3);
}
.metric-tag.accent { background: var(--accent-soft); color: var(--accent-strong); }
.metric-value { font-family: var(--font-mono); font-size: 30px; font-weight: 500; letter-spacing: -.045em; line-height: 1; color: var(--fg); }
.metric-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--fg-4); }
.metric-arrow { font-size: 14px; color: var(--fg-4); }

/* panels */
.grid-main { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; align-items: start; }
.grid-bottom { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stack-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.panel {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card); overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 15px 18px 12px; border-bottom: 1px solid var(--line-soft);
}
.panel-title { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.panel-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; flex: none; }
.panel-title h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--fg); letter-spacing: -.01em; }
.panel-title p { margin: 3px 0 0; font-size: 12px; color: var(--fg-3); }
.panel-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-4); flex: none; padding-top: 2px; }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; margin-top: auto;
  border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--fg-4);
}
.ghost-link {
  border: 0; background: transparent; color: var(--fg-3);
  font-size: 12.5px; padding: 2px 6px; border-radius: 6px; flex: none;
}
.ghost-link:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* tones */
.tone-accent { background: var(--accent-soft); color: var(--accent-strong); }
.tone-sky { background: var(--sky-soft); color: var(--sky-strong); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }

/* feed */
.feed { display: flex; flex-direction: column; padding: 4px 18px 8px; }
.feed-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.feed-item:last-child { border-bottom: 0; }
.feed-icon { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; flex: none; }
.feed-body { min-width: 0; flex: 1; }
.feed-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip-mini {
  font-size: 11px; padding: 1.5px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--fg-3);
  border: 1px solid var(--line-soft);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-mini.mono { font-family: var(--font-mono); }
.chip-mini.tone-accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); }
.chip-mini.tone-violet { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
.chip-mini.tone-sky { background: var(--sky-soft); border-color: transparent; color: var(--sky-strong); }
.chip-mini.tone-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip-mini.tone-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip-mini.tone-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.feed-time { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--fg-4); flex: none; }
.feed-title {
  margin: 6px 0 0; font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.feed-desc {
  margin: 4px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--fg-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-meta { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: 11.5px; color: var(--fg-4); flex-wrap: wrap; }

.status-word { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; white-space: nowrap; }
.status-word::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.status-word.ok { color: var(--ok); }
.status-word.warn { color: var(--warn); }
.status-word.danger { color: var(--danger); }
.status-word.muted { color: var(--fg-4); }
.status-word.accent { color: var(--accent-strong); }

/* timeline */
.timeline { display: flex; flex-direction: column; gap: 8px; padding: 12px 18px 16px; }
.tl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.tl-item.active { background: var(--accent-soft); border-color: var(--accent-line); box-shadow: var(--shadow-glow); }
.tl-item.off { opacity: .62; }
.tl-time { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-2); flex: none; width: 42px; }
.tl-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tl-body b { font-size: 13px; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-body small { font-size: 11.5px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-state {
  flex: none; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--fg-3);
  font-family: var(--font-mono);
}
.tl-item.active .tl-state { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.tl-run { flex: none; border: 0; background: transparent; color: var(--accent-strong); font-size: 11.5px; padding: 2px 4px; border-radius: 6px; }
.tl-run:hover { background: var(--surface); }

/* scratchpad */
.scratch { display: flex; flex-direction: column; padding: 6px 18px 0; max-height: 170px; overflow-y: auto; }
.scratch-item { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; font-size: 13px; color: var(--fg-2); line-height: 1.5; }
.scratch-item input { margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.scratch-item span { min-width: 0; word-break: break-word; }
.scratch-item.done span { color: var(--fg-4); text-decoration: line-through; }
.scratch-item .scratch-del { margin-left: auto; border: 0; background: transparent; color: var(--fg-4); font-size: 14px; line-height: 1; opacity: 0; flex: none; }
.scratch-item:hover .scratch-del { opacity: 1; }
.scratch-form { padding: 8px 18px 14px; }
.scratch-form input {
  width: 100%; height: 34px; padding: 0 12px;
  border: 1px dashed var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--fg); font-size: 12.5px; outline: none;
  transition: border-color .15s, background .15s;
}
.scratch-form input:focus { border-style: solid; border-color: var(--accent); background: var(--surface); }
.scratch-form input::placeholder { color: var(--fg-4); }

/* mini lists (recent sessions / notes) */
.mini-list { display: flex; flex-direction: column; padding: 4px 18px 12px; }
.mini-item {
  text-align: left; padding: 9px 0; border: 0; border-bottom: 1px solid var(--line-soft);
  background: transparent; color: inherit;
}
.mini-item:last-child { border-bottom: 0; }
.mini-item b { display: block; font-size: 13px; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item small {
  display: block; margin-top: 3px; font-size: 12px; line-height: 1.55; color: var(--fg-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mini-item em { display: block; margin-top: 4px; font-style: normal; font-family: var(--font-mono); font-size: 11px; color: var(--fg-4); }
.mini-item:hover b { color: var(--accent-strong); }

/* launchpad */
.launchpad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px 18px 18px; }
.launch-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: all .12s; min-width: 0;
}
.launch-tile:hover { background: var(--accent-soft); border-color: var(--accent-line); }
.launch-icon {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; color: var(--fg-2);
}
.launch-tile:hover .launch-icon { color: var(--accent-strong); border-color: var(--accent-line); }
.launch-name { font-size: 11px; color: var(--fg-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 22px 6px; text-align: center; font-size: 12.5px; line-height: 1.7; color: var(--fg-4); }

/* ---------- chat view ---------- */
.sidebar {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  padding-bottom: 8px;
}
.sidebar-top { display: flex; flex-direction: column; gap: 8px; padding: 12px 12px 10px; }
.back-overview {
  border: 0; background: transparent; color: var(--fg-3);
  font-size: 12.5px; text-align: left; padding: 2px 6px; border-radius: 8px;
}
.back-overview:hover { background: var(--surface-2); color: var(--accent-strong); }
.sidebar .primary-button { border-radius: 10px; height: 36px; font-size: 13.5px; }
.primary-thread { border-color: var(--accent-line); background: var(--accent-soft); }
.primary-thread.selected { box-shadow: var(--shadow-glow); }
.primary-thread-name { font-size: 13.5px; }
.primary-tag { font-size: 10.5px; }
.side-list { padding: 0 10px 6px; max-height: none; flex: 0 1 auto; }
.history-heading { font-size: 11.5px; color: var(--fg-4); letter-spacing: .06em; }
.side-item { font-size: 12.5px; border-radius: 9px; }
.side-origin { font-size: 10px; }
.sidebar-footer { border-top: 1px solid var(--line-soft); }
.profile-row b { font-size: 13px; }

.conversation {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card); overflow: hidden; min-width: 0;
}
.conversation-header { height: 52px; flex: 0 0 52px; padding: 0 20px; border-bottom: 1px solid var(--line-soft); }
.conversation-title h1 { font-size: 14.5px; font-weight: 700; }
.conversation-title-text { flex-direction: row; align-items: baseline; gap: 10px; }
.session-id { font-family: var(--font-mono); font-size: 10.5px; margin-top: 0; }
.welcome { margin-top: 40px; }
.composer-wrap { padding: 4px var(--thread-gutter) 12px; }
.composer { border-radius: 14px; }
.message.assistant .bubble { border-radius: 14px; border-top-left-radius: 4px; }
.message.user .bubble { background: var(--accent); }
.bubble pre { background: var(--surface-2); }
.bubble pre code { background: transparent; }

@media (max-width: 1180px) {
  /* 窄屏先砍副标题和留白，保证右侧图标和头像不被挤出屏幕 */
  .topbar { gap: 10px; padding: 0 14px; }
  .tb-right { gap: 6px; }
  .tb-right .agent-status span { display: none; }
  .tb-right .backend-badge { max-width: 200px; padding: 0 8px; }
  .tb-right .backend-badge span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 1280px) {
  .metric-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app-body[data-view="overview"] { grid-template-columns: minmax(0, 1fr); }
  .nav-rail { display: none; }
  .tb-mid { display: none; }
  .grid-bottom { grid-template-columns: minmax(0, 1fr); }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 760px) {
  .app-body[data-view="chat"] { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .lede h1 { font-size: 24px; }
}


/* Access gate — shown when this browser is not on the host and has no key yet.
   Deliberately plain: it is the one screen that must work before anything else
   loads, so it does not depend on the dashboard grid or any JS state. */
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(3px);
}
.access-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 24px 22px;
  box-shadow: 0 24px 60px -24px rgba(15, 23, 42, .35);
}
.access-card h2 { margin: 0 0 6px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--fg-1); }
.access-hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--fg-3); }
.access-card input {
  width: 100%;
  box-sizing: border-box;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 13px;
}
.access-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.access-card button {
  width: 100%;
  margin-top: 12px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.access-card button:hover { background: var(--accent-strong); }

/* ───────────────────────── 左下角入口（dock） ─────────────────────────
   网页端只留对话：概览、技能、任务、事件、口令都收在这一颗按钮里。
   插件端用同一颗按钮，多两项——首页概览和可点击的线路状态。
   位置固定在左下角，因此会话栏底部让出 62px，避免压住用户信息行。 */

.dock {
  position: fixed; left: 16px; bottom: 16px; z-index: 28;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
}
.dock-button {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 13px 0 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-card); color: var(--fg-2); font-size: 12.5px;
  transition: border-color .15s, box-shadow .15s, color .15s;
}
.dock-button:hover, .dock-button.active {
  border-color: var(--accent-line); box-shadow: var(--shadow-glow); color: var(--fg);
}
.dock-mark {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
}
.dock-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-left: 1px; }
html[data-route="public"] .dock-dot { background: var(--accent); }
html[data-route="loopback"] .dock-text::after { content: ""; }

.dock-menu {
  width: 236px; padding: 8px; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow-raised);
}
.dock-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 8px 9px; margin-bottom: 6px; border-bottom: 1px dashed var(--line);
}
.dock-head > span { font-size: 12px; font-weight: 700; color: var(--fg); }
.dock-route {
  border: 0; background: transparent; padding: 0; cursor: default;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-4);
  max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html[data-shell="panel"] .dock-route { cursor: pointer; color: var(--fg-3); }
html[data-shell="panel"] .dock-route:hover { color: var(--accent-strong); }
.dock-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--fg-2); font-size: 13px; text-align: left;
}
.dock-item > span:first-child { width: 16px; text-align: center; color: var(--fg-4); font-size: 12px; }
.dock-item:hover { background: var(--accent-soft); color: var(--accent-strong); }
.dock-item:hover > span:first-child { color: var(--accent); }
.dock-count {
  margin-left: auto; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: var(--surface-2);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-4);
}
/* The dock is fixed to the corner, so the rail reserves that strip instead of
   letting its last row slide underneath the button. */
.sidebar { padding-bottom: 58px; }
.nav-rail { padding-bottom: 58px; }

/* 网页端（data-shell="web"）：只有对话。 */
html[data-shell="web"] #view-overview { display: none; }
html[data-shell="web"] .app-body[data-view="overview"] { grid-template-columns: 268px minmax(0, 1fr); }
html[data-shell="web"] .panel-only { display: none; }
html[data-shell="web"] #back-overview { display: none; }
html[data-shell="web"] #tasks-button,
html[data-shell="web"] #events-button { display: none !important; }
html[data-shell="web"] .nav-rail { display: none; }
/* 技能已经在左下角，侧栏里不要再留一份。 */
html[data-shell="web"] #show-plugins { display: none; }
/* 只剩身份行时，不要留两道分割线。 */
html[data-shell="web"] .sidebar-footer { border-top: 0; padding-top: 0; }

/* 会话栏折叠：dock 里的「会话列表」开关。 */
html[data-rail="hidden"] .app-body[data-view="chat"] { grid-template-columns: 0 minmax(0, 1fr); }
html[data-rail="hidden"] .sidebar { display: none; }

/* ───────────────────────── 外部态势卡片 ─────────────────────────
   每张卡片背后是一个无参采集脚本，写快照读快照。三件事必须在界面上看得见：
   ① 数据是什么时候采的；② 采失败了（而不是显示 0）；③ 数据本身过期了。 */

.source-row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px; margin: 16px 0 4px;
}
@media (max-width: 980px) { .source-row { grid-template-columns: 1fr; } }

.source-card {
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px 16px 13px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-card);
  min-height: 168px;
}
.source-card.is-down { border-color: var(--danger-line); background: var(--danger-soft); }
.source-card.is-empty { background: var(--surface-2); }

.source-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.source-label { font-size: 12px; font-weight: 600; color: var(--fg-3); letter-spacing: .02em; }
.source-refresh {
  width: 24px; height: 24px; display: grid; place-items: center;
  border: 1px solid var(--line-soft); border-radius: 8px;
  background: transparent; color: var(--fg-4); font-size: 12px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.source-refresh:hover { color: var(--accent); border-color: var(--accent-line); }
.source-refresh[disabled] { opacity: .45; cursor: default; }

.source-value { display: flex; align-items: baseline; gap: 6px; }
.source-value b {
  font-family: var(--font-mono); font-size: 26px; font-weight: 500;
  line-height: 1; color: var(--fg); font-variant-numeric: tabular-nums;
}
.source-value span { font-size: 12px; color: var(--fg-3); }
.source-hint { font-size: 11.5px; color: var(--fg-3); line-height: 1.5; }
.source-warn {
  font-size: 11px; color: var(--warn); background: var(--warn-soft);
  border-radius: 7px; padding: 5px 8px; line-height: 1.45;
}
.source-error {
  font-size: 11.5px; color: var(--danger); background: var(--danger-soft);
  border-radius: 7px; padding: 6px 8px; line-height: 1.45; word-break: break-word;
}

.source-items { list-style: none; display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; }
.source-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.source-item b {
  font-size: 12.5px; font-weight: 500; color: var(--fg-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.source-item span { font-size: 10.5px; color: var(--fg-4); font-family: var(--font-mono); }
.source-item.tone-danger b { color: var(--danger); }
.source-item.tone-warn b { color: var(--warn); }
.source-item.tone-muted b { color: var(--fg-4); }

.source-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; padding-top: 2px; font-size: 10.5px; color: var(--fg-4);
}
.source-foot a { color: var(--accent-strong); text-decoration: none; }
.source-foot a:hover { text-decoration: underline; }
