/* 爱发电私信工作台 × AzumaStudio 控制台视觉（mimo-ui · Warm Paper × Black Ink × AzkiDeck 语义色）
 *
 * 令牌与 azvf/packages/console/src/web/styles.css 保持一致：暖白纸面、暖灰发丝线、纯黑墨水、
 * 6px 圆角、静止零阴影、单一签名缓动；状态色只用于徽标、状态点等小面积元素。
 * 工作台是数据密集界面：分区节奏压到 12–16px，私信页铺满视口。
 */
:root {
  color-scheme: light dark;
  --bg: #fcfaf8; --bg-card: #faf7f3; --bg-section: #f0ebe5; --surface-hover: #f7f3ef;
  --surface-sunken: #f3ede8; --surface-card: #fff;
  --border: #f0ebe5; --border-strong: #e8e1d9; --border-hover: #ddd4c9;
  --text-primary: #000; --text-h1: #1a1a1a; --text-secondary: #666; --text-muted: #8c8c8c; --stat-ink: #181e25;
  --success: #3f7657; --success-bg: rgba(63,118,87,.08); --success-line: rgba(63,118,87,.28);
  --danger: #a54842; --danger-bg: rgba(165,72,66,.06); --danger-line: rgba(165,72,66,.3);
  --warning-ink: #805a17; --warning-bg: #fff6ed; --warning-line: #ffdab7;
  --radius-card: 6px; --radius-sm: 4px; --radius-tooltip: 12px; --radius-pill: 999px;
  --ease-signature: cubic-bezier(.16,1,.3,1); --ease-standard: cubic-bezier(.4,0,.2,1);
  --dur-micro: .2s; --dur-card: .3s; --dur-lift: .6s;
  --shadow-btn-hover: 0 4px 12px rgba(0,0,0,.2);
  --shadow-tooltip: 0 4px 24px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --font-ui: "PingFang SC", -apple-system, BlinkMacSystemFont, "MiSans", "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-stat: Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --control-h: 36px; --control-h-sm: 30px;
  --gap: 16px; --panel-pad: 20px; --page-pad: 28px; --sidebar-w: 216px; --content-max: 1680px;
  --overlay: rgba(26,26,26,.28);
  --select-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='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23666' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --bubble-out: #f0ebe5;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c0c0c; --bg-card: #141414; --bg-section: #1f1f1f; --surface-hover: #1c1c1c; --surface-sunken: #111;
    --surface-card: #171717; --border: #262626; --border-strong: #333; --border-hover: #474747;
    --text-primary: #f2f2f2; --text-h1: #fff; --text-secondary: #a6a6a6; --text-muted: #858585; --stat-ink: #fff;
    --success: #82be97; --success-bg: rgba(130,190,151,.12); --success-line: rgba(130,190,151,.32);
    --danger: #e88980; --danger-bg: rgba(232,137,128,.1); --danger-line: rgba(232,137,128,.34);
    --warning-ink: #f0c887; --warning-bg: rgba(240,200,135,.08); --warning-line: rgba(240,200,135,.28);
    --shadow-btn-hover: 0 4px 12px rgba(255,255,255,.12);
    --shadow-tooltip: 0 4px 24px rgba(0,0,0,.5), 0 1px 4px rgba(0,0,0,.3);
    --overlay: rgba(0,0,0,.6);
    --select-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='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23a6a6a6' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --bubble-out: #262626;
  }
}
@media (max-width: 1179px) { :root { --page-pad: 20px; } }
@media (max-width: 639px) { :root { --gap: 12px; --panel-pad: 16px; --page-pad: 16px; } }
@media (pointer: coarse) { :root { --control-h: 44px; --control-h-sm: 36px; } }

/* ═══ 基础 ═══ */
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; color: var(--text-primary); background: var(--bg); font: 14px/1.6 var(--font-ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--text-h1); letter-spacing: -.01em; font-weight: 500; }
h1 { font-size: 24px; line-height: 32px; font-weight: 400; }
h2 { font-size: 16px; line-height: 24px; }
h3 { font-size: 14px; line-height: 22px; }
h4 { font-size: 13px; line-height: 20px; color: var(--text-secondary); }
p { margin: 0; }
a { color: var(--text-primary); text-underline-offset: 3px; }
a:hover { opacity: .7; }
code { font-family: var(--font-mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ═══ 按钮：主按钮黑底，其余描边 ═══ */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 14px; flex-shrink: 0;
  border: 1px solid var(--text-primary); border-radius: var(--radius-card);
  color: var(--bg); background: var(--text-primary);
  font-size: 13px; line-height: 20px; white-space: nowrap; cursor: pointer;
  transition: transform var(--dur-micro) var(--ease-signature), box-shadow var(--dur-micro) var(--ease-signature),
              background var(--dur-micro) var(--ease-standard), border-color var(--dur-micro) var(--ease-standard), color var(--dur-micro) var(--ease-standard);
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-btn-hover); }
button:active:not(:disabled) { transform: none; box-shadow: none; }
button:disabled { cursor: not-allowed; opacity: .38; }
.button-quiet { color: var(--text-primary); background: var(--surface-card); border-color: var(--border-strong); }
.button-quiet:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-hover); box-shadow: none; }
.button-danger { color: var(--danger); background: var(--surface-card); border-color: var(--danger-line); }
.button-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); box-shadow: none; }
.button-sm { height: var(--control-h-sm); padding: 0 10px; font-size: 12px; }
.link-button { height: auto; padding: 0; border: 0; border-radius: 0; color: var(--text-secondary); background: none; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover:not(:disabled) { color: var(--text-primary); transform: none; box-shadow: none; }

/* ═══ 输入 ═══ */
input, select, textarea {
  width: 100%; min-width: 0; height: var(--control-h); padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-card);
  color: var(--text-primary); background: var(--surface-card); font-size: 13px; line-height: 20px;
  transition: border-color var(--dur-micro) var(--ease-standard);
}
input:hover, select:hover, textarea:hover { border-color: var(--border-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-primary); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[readonly], textarea[readonly] { color: var(--text-secondary); background: var(--bg-card); border-style: dashed; }
textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
select { padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer; background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 10px center; }
input[type="checkbox"], input[type="radio"] { flex: 0 0 auto; width: 15px; height: 15px; margin: 0; padding: 0; accent-color: var(--text-primary); cursor: pointer; }
input[type="file"] { padding: 3px; line-height: calc(var(--control-h) - 8px); font-size: 12px; color: var(--text-secondary); }
label, .field { display: grid; gap: 4px; align-content: start; min-width: 0; color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-primary); font-size: 13px; line-height: 20px; cursor: pointer; }
details > summary { cursor: pointer; width: fit-content; color: var(--text-secondary); font-size: 12px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸'; display: inline-block; width: 12px; transition: transform var(--dur-micro) var(--ease-standard); }
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { color: var(--text-primary); }

/* ═══ 外壳：宽屏左侧导航 + 内容；窄屏折叠为顶部条 ═══ */
.console-app { display: grid; grid-template-columns: minmax(0,1fr); min-height: 100dvh; }
.console-sidebar {
  position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: minmax(0,1fr) auto;
  grid-template-areas: "brand status" "nav nav"; align-items: center; gap: 0 12px;
  padding: 10px var(--page-pad) 0; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.sidebar-brand { grid-area: brand; min-width: 0; }
.sidebar-brand h1 { font-size: 15px; line-height: 22px; font-weight: 500; white-space: nowrap; }
.eyebrow { margin: 0; color: var(--text-muted); font-size: 11px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase; }
.console-sidenav { grid-area: nav; display: flex; gap: 2px; margin: 6px calc(var(--page-pad) * -1) 0; padding: 0 var(--page-pad); overflow-x: auto; scrollbar-width: none; }
.console-sidenav::-webkit-scrollbar { display: none; }
.sidenav-group { display: contents; }
.sidenav-label { display: none; }
.console-sidenav button {
  flex: 0 0 auto; height: 38px; padding: 0 10px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--text-secondary); background: transparent; font-size: 13px;
}
.console-sidenav button:hover:not(:disabled) { color: var(--text-primary); transform: none; box-shadow: none; }
.console-sidenav button.is-active { color: var(--text-primary); border-bottom-color: var(--text-primary); font-weight: 500; }
.nav-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--bg-section); color: var(--text-secondary); font: 500 11px/18px var(--font-stat); text-align: center; font-variant-numeric: tabular-nums; }
.nav-count.is-alert { color: var(--danger); background: var(--danger-bg); }
.nav-count:empty { display: none; }
.sidebar-status { grid-area: status; display: grid; gap: 2px; justify-items: end; font-size: 12px; color: var(--text-secondary); }
.status-line { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-hover); flex: 0 0 auto; }
.status-dot.is-on { background: var(--success); }
.status-dot.is-warn { background: var(--warning-ink); }
@media (max-width: 639px) { .sidebar-status .status-line + .status-line { display: none; } }

@media (min-width: 1180px) {
  .console-app { grid-template-columns: var(--sidebar-w) minmax(0,1fr); }
  .console-sidebar {
    height: 100dvh; display: flex; flex-direction: column; align-items: stretch; gap: 0;
    padding: 18px 10px 14px; border-bottom: 0; border-right: 1px solid var(--border); background: var(--bg-card);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .sidebar-brand { padding: 0 10px 16px; }
  .console-sidenav { flex: 1 1 auto; flex-direction: column; gap: 0; margin: 0; padding: 0; overflow-y: auto; }
  .sidenav-group { display: grid; gap: 1px; }
  .sidenav-group + .sidenav-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
  .sidenav-label { display: block; padding: 0 10px 4px; color: var(--text-muted); font-size: 11px; line-height: 16px; }
  .console-sidenav button { justify-content: space-between; width: 100%; height: 34px; padding: 0 8px 0 10px; border-bottom: 0; border-left: 2px solid transparent; border-radius: var(--radius-sm); }
  .console-sidenav button:hover:not(:disabled) { background: var(--surface-hover); }
  .console-sidenav button.is-active { background: var(--surface-card); border-left-color: var(--text-primary); }
  .sidebar-status { justify-items: start; margin-top: 10px; padding: 12px 10px 0; border-top: 1px solid var(--border); }
}

/* ═══ 内容区 ═══ */
.console-main { min-width: 0; }
.console-container { display: flex; flex-direction: column; gap: var(--gap); width: 100%; max-width: calc(var(--content-max) + var(--page-pad) * 2); margin: 0 auto; padding: 20px var(--page-pad) 40px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; }
.page-header > div:first-child { display: grid; gap: 2px; min-width: 0; }
.page-header p { color: var(--text-secondary); font-size: 13px; line-height: 20px; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.page { display: none; flex-direction: column; gap: var(--gap); min-width: 0; }
.page.is-active { display: flex; animation: view-enter var(--dur-lift) var(--ease-signature) backwards; }
@keyframes view-enter { from { opacity: 0; transform: translateY(8px); } }

/* 私信页铺满视口：去掉页头和内边距，聊天区就是整页 */
body.is-chat .page-header { display: none; }
body.is-chat .console-container { max-width: none; padding: 0; }
body.is-chat .console-sidebar { border-bottom-color: var(--border); }

.panel { position: relative; min-width: 0; padding: var(--panel-pad); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.panel-head > div:not(.row):not(.segmented) { display: grid; gap: 2px; min-width: 0; }
.panel > * + .stack, .stack { display: grid; gap: 12px; }
.muted, .hint { color: var(--text-muted); font-size: 12px; line-height: 18px; }
.meta { color: var(--text-muted); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.danger-text { color: var(--danger); }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--gap); align-items: start; }
.cols-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: var(--gap); align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 12px; align-items: start; }
.form-grid .span-all { grid-column: 1 / -1; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row > input, .row > select { width: auto; }
@media (max-width: 1023px) { .cols-2, .cols-main { grid-template-columns: minmax(0,1fr); } }

/* 指标块 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--border); }
.stat { display: grid; gap: 2px; padding: 14px 16px; border: 0; border-radius: 0; height: auto; text-align: left; color: var(--text-primary); background: var(--surface-card); justify-content: stretch; white-space: normal; }
button.stat:hover:not(:disabled) { background: var(--surface-hover); transform: none; box-shadow: none; }
.stat span { color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.stat b { color: var(--stat-ink); font: 500 24px/30px var(--font-stat); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat small { color: var(--text-muted); font-size: 11px; line-height: 16px; }
.stat.is-alert b { color: var(--danger); }

/* 徽标 */
.pill { display: inline-flex; align-items: center; gap: 4px; width: fit-content; min-height: 20px; padding: 0 8px; border-radius: var(--radius-pill); color: var(--text-secondary); background: var(--bg-section); font-size: 11px; line-height: 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.ok, .pill.answered, .pill.approved, .pill.sent, .pill.cleared { color: var(--success); background: var(--success-bg); }
.pill.warn, .pill.open, .pill.pending_review, .pill.reviewing, .pill.pending, .pill.sending { color: var(--warning-ink); background: var(--warning-bg); }
.pill.danger { color: var(--danger); background: var(--danger-bg); }
#agentTasks .quote .row { margin-top: 6px; }
.pill.bad, .pill.rejected, .pill.blocked, .pill.deferred, .pill.send_unknown, .pill.confirmed { color: var(--danger); background: var(--danger-bg); }

/* 列表与条目：发丝线分隔，不堆卡片 */
.list { display: grid; }
.list > .item + .item { border-top: 1px solid var(--border); }
.item { display: grid; gap: 8px; padding: 14px 0; min-width: 0; }
.list > .item:first-child { padding-top: 0; }
.list > .item:last-child { padding-bottom: 0; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-width: 0; }
.item-head > b, .item-head > .title { min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.item-head > .row { flex: 0 0 auto; }
.quote { padding: 8px 12px; border-left: 2px solid var(--border-strong); background: var(--bg-card); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-secondary); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.quote.is-danger { border-left-color: var(--danger-line); color: var(--danger); background: var(--danger-bg); }
.quote.is-ok { border-left-color: var(--success-line); }
.empty { padding: 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius-card); color: var(--text-muted); background: var(--bg-card); font-size: 13px; text-align: center; }
.compact-rows { display: grid; }
.compact-rows > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13px; }
.compact-rows > div:first-child { border-top: 0; padding-top: 0; }
.compact-rows > div > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-rows > div > span:last-child { flex: 0 0 auto; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
button.row-link { display: flex; width: 100%; height: auto; padding: 7px 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; color: var(--text-primary); background: none; justify-content: space-between; font-size: 13px; white-space: normal; text-align: left; }
button.row-link:first-child { border-top: 0; padding-top: 0; }
button.row-link:hover:not(:disabled) { transform: none; box-shadow: none; opacity: .7; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.data th { padding: 0 8px 6px; color: var(--text-muted); font-weight: 400; text-align: right; white-space: nowrap; }
table.data td { padding: 6px 8px; border-top: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { padding-left: 0; text-align: left; }
table.data th:last-child, table.data td:last-child { padding-right: 0; }

/* 分段切换 */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-card); background: var(--bg-card); }
.segmented button { height: calc(var(--control-h-sm) - 4px); padding: 0 10px; border: 0; border-radius: var(--radius-sm); color: var(--text-secondary); background: transparent; font-size: 12px; }
.segmented button:hover:not(:disabled) { color: var(--text-primary); transform: none; box-shadow: none; }
.segmented button.is-active { color: var(--text-primary); background: var(--surface-card); box-shadow: 0 0 0 1px var(--border-strong); }
.tab-row { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tab-row button { flex: 0 0 auto; height: 36px; margin-bottom: -1px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--text-secondary); background: transparent; }
.tab-row button:hover:not(:disabled) { color: var(--text-primary); transform: none; box-shadow: none; }
.tab-row button.is-active { color: var(--text-primary); border-bottom-color: var(--text-primary); font-weight: 500; }
.tab-panel { display: none; }
.tab-panel.is-active { display: grid; gap: var(--gap); }

.callout { padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-card); color: var(--text-secondary); background: var(--bg-card); font-size: 12px; line-height: 20px; }
.callout.is-warn { border-color: var(--warning-line); color: var(--warning-ink); background: var(--warning-bg); }
.progress-track { height: 4px; overflow: hidden; border-radius: var(--radius-pill); background: var(--bg-section); }
.progress-fill { height: 100%; background: var(--text-primary); transition: width var(--dur-lift) var(--ease-signature); }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: min(420px, calc(100vw - 40px)); padding: 10px 16px; border-radius: var(--radius-card); color: var(--bg); background: var(--text-primary); box-shadow: var(--shadow-tooltip); font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity var(--dur-card) var(--ease-standard), transform var(--dur-card) var(--ease-signature); }
.toast.is-visible { opacity: 1; transform: none; }
.toast.is-error { color: #fff; background: var(--danger); }

/* ═══ 私信 ═══ */
.chat-layout { display: grid; grid-template-columns: 300px minmax(0,1fr) 280px; height: 100dvh; min-height: 480px; background: var(--surface-card); }
.chat-sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); background: var(--bg-card); }
.chat-sidebar-head { display: grid; gap: 8px; padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.chat-sidebar-head .row { flex-wrap: nowrap; }
.chat-sidebar-head h2 { flex: 1; font-size: 15px; }
.chat-sidebar-head .segmented { flex: 0 0 auto; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; }
.chat-entry { display: flex; gap: 10px; align-items: flex-start; width: 100%; height: auto; padding: 10px 14px; border: 0; border-left: 2px solid transparent; border-radius: 0; color: var(--text-primary); background: transparent; text-align: left; white-space: normal; }
.chat-entry:hover:not(:disabled) { background: var(--surface-hover); transform: none; box-shadow: none; }
.chat-entry.is-active { background: var(--surface-card); border-left-color: var(--text-primary); }
.chat-avatar { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--text-primary); background: var(--bg-section); font: 500 13px/1 var(--font-ui); }
.chat-entry-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.chat-entry-top, .chat-preview { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.chat-entry-top b { min-width: 0; overflow: hidden; font-weight: 500; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.chat-entry time { flex: none; color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chat-preview > span:first-child { min-width: 0; overflow: hidden; color: var(--text-secondary); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.chat-count { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); color: var(--bg); background: var(--text-primary); font: 500 11px/18px var(--font-stat); text-align: center; }
.chat-sidebar-foot { padding: 8px 14px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; line-height: 16px; }
.chat-more { display: flex; margin: 8px auto; height: var(--control-h-sm); font-size: 12px; }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 20px; border-bottom: 1px solid var(--border); }
.chat-header > div { display: grid; min-width: 0; }
.chat-header b { overflow: hidden; font-size: 15px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.chat-history { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; background: var(--bg); }
.chat-day { margin: 14px 0 6px; color: var(--text-muted); font-size: 11px; text-align: center; }
.chat-message { display: flex; gap: 8px; align-items: flex-end; margin: 6px 0; }
.chat-message.outgoing { flex-direction: row-reverse; }
.chat-message-body { display: grid; gap: 2px; max-width: min(72%, 640px); }
.chat-message.outgoing .chat-message-body { justify-items: end; }
.chat-bubble { padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-card); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 21px; }
.chat-message.outgoing .chat-bubble { border-color: transparent; background: var(--bubble-out); }
.chat-message.is-ai .chat-bubble { border-color: var(--border); border-left: 3px solid var(--text-primary); }
.chat-message.is-pending .chat-bubble { border-style: dashed; opacity: .85; }
.chat-message.is-system .chat-bubble { color: var(--text-secondary); background: transparent; border-style: dashed; font-size: 12px; }
.chat-message .meta { display: flex; gap: 8px; font-size: 11px; }
.chat-compose { display: grid; gap: 8px; padding: 10px 20px 14px; border-top: 1px solid var(--border); }
.chat-compose textarea { min-height: 64px; max-height: 180px; }
.chat-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-send-status { padding: 8px 20px; border-top: 1px solid var(--border); background: var(--bg-card); font-size: 12px; }
.chat-send-status .text { max-height: 60px; overflow: auto; color: var(--text-secondary); }

.chat-info { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; overflow-y: auto; padding: 16px; border-left: 1px solid var(--border); background: var(--bg-card); }
.chat-info section { display: grid; gap: 8px; }
.chat-order { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-card); font-size: 12px; }
.chat-order b { font-weight: 500; font-size: 13px; overflow-wrap: anywhere; }
.chat-actions { display: grid; gap: 6px; }
.chat-actions button { width: 100%; }

@media (max-width: 1439px) { .chat-layout { grid-template-columns: 280px minmax(0,1fr); } .chat-info { display: none; } .chat-layout.show-info .chat-info { display: flex; position: fixed; right: 0; top: 0; bottom: 0; z-index: 30; width: 300px; box-shadow: var(--shadow-tooltip); } }
@media (max-width: 1179px) { .chat-layout { height: calc(100dvh - 92px); } }
@media (max-width: 767px) {
  .chat-layout { grid-template-columns: minmax(0,1fr); height: auto; }
  .chat-sidebar { height: 280px; border-right: 0; border-bottom: 1px solid var(--border); }
  .chat-main { height: 76dvh; }
  .chat-message-body { max-width: 86%; }
}
@media (min-width: 1440px) { .chat-info-toggle { display: none; } }

/* ═══ 待办 ═══ */
.question-card { display: grid; gap: 8px; }
.question-card textarea { min-height: 56px; }
.question-more { display: grid; gap: 8px; padding-top: 8px; }
.question-more .row > input { width: 140px; }
.question-more .row > select { min-width: 200px; flex: 1; }

/* ═══ 模拟 ═══ */
.sim-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; align-items: start; }
.sim-history { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--bg); }
.sim-turn { display: grid; gap: 2px; justify-items: start; max-width: 88%; }
.sim-bubble { width: fit-content; max-width: 100%; }
#frozenList .sim-history { max-height: 220px; }
.sim-turn.outgoing { justify-self: end; justify-items: end; }
.sim-bubble { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-card); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sim-turn.outgoing .sim-bubble { border-color: transparent; background: var(--bubble-out); }
.sim-bubble.is-target { border-color: var(--text-primary); }
@media (max-width: 1023px) { .sim-grid { grid-template-columns: minmax(0,1fr); } }

/* ═══ 知识流程图 ═══ */
.workflow-scroll { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-card); background-color: var(--bg); background-image: radial-gradient(var(--border-strong) 1px, transparent 1px); background-size: 18px 18px; max-height: 62vh; }
.workflow-board { position: relative; min-width: 1000px; min-height: 480px; }
.workflow-wires { position: absolute; inset: 0; pointer-events: none; overflow: visible; color: var(--text-muted); }
.workflow-node { position: absolute; display: grid; gap: 4px; width: 210px; min-height: 100px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-card); background: var(--surface-card); cursor: grab; touch-action: none; user-select: none; transition: border-color var(--dur-micro) var(--ease-standard); }
.workflow-node:hover { border-color: var(--border-hover); }
.workflow-node.selected { border-color: var(--text-primary); box-shadow: 0 0 0 1px var(--text-primary); }
.workflow-node.dragging { cursor: grabbing; z-index: 2; box-shadow: var(--shadow-tooltip); }
.workflow-node strong { font-weight: 500; font-size: 13px; line-height: 18px; }
.workflow-node .meta { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.workflow-editor { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0,1fr); gap: var(--gap); align-items: start; }
.workflow-branches { display: grid; gap: 8px; max-height: 70vh; overflow: auto; }
.workflow-branch { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-card); }
.workflow-branch > summary { display: flex; width: 100%; justify-content: space-between; align-items: baseline; gap: 12px; color: var(--text-primary); font-size: 13px; }
.workflow-branch > summary strong { flex: 1; font-weight: 500; }
.workflow-branch[open] > summary { margin-bottom: 10px; }
.workflow-branch .stack { gap: 10px; }
.workflow-edge-list { display: grid; }
.workflow-edge { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 12px; }
.workflow-topic-question { display: grid; gap: 6px; padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--border); }
.topic-section { display: grid; gap: 2px; }
.topic-section > b { color: var(--text-muted); font-size: 11px; font-weight: 400; }
.topic-source { display: grid; gap: 4px; margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-card); font-size: 12px; }
@media (max-width: 1023px) { .workflow-editor { grid-template-columns: minmax(0,1fr); } }

.whitelist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.whitelist-choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-card); color: var(--text-primary); font-size: 13px; cursor: pointer; transition: border-color var(--dur-micro) var(--ease-standard); }
.whitelist-choice:hover { border-color: var(--border-hover); }
.whitelist-choice:has(input:checked) { border-color: var(--text-primary); }

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

/* ═══ 登录 / 账户 / 管理 ═══ */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 16px; box-sizing: border-box; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { margin: 4px 0 0; font-size: 22px; }
.hint.is-danger, #authMessage.is-danger { color: var(--danger); }
.quota-bar { height: 8px; border-radius: var(--radius-pill); background: var(--bg-section); overflow: hidden; }
.quota-bar > span { display: block; height: 100%; background: var(--text-primary); }
.quota-bar.is-warn > span { background: var(--danger); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 6px; border-bottom: 1px solid var(--bg-section); text-align: left; vertical-align: top; }
.admin-table th { color: var(--text-secondary); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.prompt-editor { min-height: 260px; font-size: 13px; }
.sidebar-account { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); word-break: break-all; }
