/* 晨笺 —— 中性纸面 + 墨色文字 + 一个松墨绿强调色；工具收在安静的侧栏里。 */
:root {
  --ink: #17181a;
  --ink-soft: #3c3f3e;
  --paper: #ffffff;
  --studio: #f2f2f2;
  --rule: #e4e4df;
  --rule-strong: #cfd0cb;
  --accent: #1d5c4b;
  --accent-tint: #e8efec;
  --muted: #5f635f;
  --positive: #1f6b4f;
  --danger: #a8342a;
  --font-ui: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--studio);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  padding: 8px 12px;
  min-height: 36px;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
button:hover:not(:disabled) { background: #f5f5f2; border-color: #b9bab5; }
button:disabled {
  background: #ececea;
  border-color: #dededa;
  color: #63676a;
  cursor: not-allowed;
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.primary {
  background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600;
}
.primary:hover:not(:disabled) { background: #2c2e30; border-color: #2c2e30; }
.primary:disabled { background: #ececea; border-color: #dededa; color: #63676a; }
.danger { color: var(--danger); border-color: #d9b3ad; }
.danger:hover:not(:disabled) { background: #f7ebe9; border-color: #c99c95; }
.link-btn {
  border: 0; background: none; padding: 0; min-height: 0;
  color: var(--accent); text-decoration: underline; font-size: 12px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 0 max(24px, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: grid; place-items: center; color: var(--ink); flex-shrink: 0; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.brand-divider { width: 1px; height: 18px; background: var(--rule); }
.brand-context { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.version-badge {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}
.app-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.app-status.ready { color: var(--positive); }
.app-status.error { color: var(--danger); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn { width: 34px; min-height: 34px; padding: 0; font-size: 16px; }
.icon-btn-text { padding: 0 11px; min-height: 34px; font-size: 12.5px; }
.mode-btn {
  padding: 0 11px; min-height: 34px; font-size: 12.5px;
  background: transparent; border-color: transparent; color: var(--muted);
}
.mode-btn.active { background: #e9e9e5; border-color: var(--rule); color: var(--ink); font-weight: 600; }
.nav-toggle, .nav-toggle-label { display: none; }

/* ---------- 快速制作：工作台首屏 ---------- */
.quick-stage {
  display: none;
  padding: 24px clamp(20px, 4vw, 40px) 40px;
  max-width: 1160px;
  margin: 0 auto;
}
.quick-stage.active { display: block; }
.stage-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px; margin-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}
.stage-title h1,
.stage-title h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.stage-lead { margin: 6px 0 0; font-size: 14px; color: var(--muted); max-width: 60ch; }
/* 定时那一行：她不用懂 cron，只要看到「每天 08:00」和有没有挑好 */
.stage-schedule { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.stage-schedule select {
  font: inherit;
  padding: 2px 4px;
  border: 1px solid var(--line, #d8d2c4);
  border-radius: 6px;
  background: transparent;
  color: inherit;
}
.schedule-switch { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.schedule-hint { color: var(--muted); }
.stage-actions { display: flex; gap: 8px; flex-shrink: 0; }
.stage-actions button { min-height: 38px; }
.generate-btn span { font-size: 11px; margin-left: 6px; font-variant-numeric: tabular-nums; }

/* 版面选择条：自动 + 各版面芯片，右侧一句话说清会怎么排 */
.layout-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  margin: -6px 0 20px;
}
.layout-bar-label {
  font-size: 12px; color: var(--muted); letter-spacing: .04em;
  padding-right: 2px;
}
.layout-bar-options { display: flex; flex-wrap: wrap; gap: 6px; }
.layout-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 11px; min-height: 0;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  background: var(--paper); color: var(--ink-soft);
  font-size: 13px; line-height: 1.2;
}
.layout-chip span { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.layout-chip:hover:not(.is-active) { border-color: var(--accent); color: var(--accent); }
.layout-chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.layout-chip.is-active span { color: #cdd2ce; }
.layout-chip.is-tight:not(.is-active) { border-style: dashed; color: var(--muted); }
.layout-bar-hint { font-size: 12px; color: var(--muted); }
.stage-grid { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 20px; align-items: stretch; }

.panel-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px;
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-foot { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

.canvas-card { display: flex; flex-direction: column; }
.canvas-slot {
  flex: 1;
  aspect-ratio: 3 / 4;
  background: #f6f6f6;
  border: 1px dashed #b9bab3;
  border-radius: 2px;
  display: grid; place-items: center;
  padding: 20px;
  text-align: center;
  overflow: hidden;
}
/* 真实画布的缩小克隆接管之后的框：纸面本身就是内容 */
.canvas-slot.has-preview {
  display: block;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--paper);
}
.preview-svg { display: block; width: 100%; height: auto; }
.slot-hint { font-size: 12px; line-height: 1.7; color: #5f635f; max-width: 20ch; }

.candidates { display: flex; flex-direction: column; gap: 12px; }
.quick-status { font-size: 12px; color: var(--muted); }
.quick-search { display: flex; }
.quick-search input {
  min-width: 0; flex: 1; padding: 8px 11px;
  border: 1px solid var(--rule-strong); border-right: 0;
  border-radius: 6px 0 0 6px; background: var(--paper);
}
.quick-search button { border-radius: 0 6px 6px 0; }

.quick-news-list {
  flex: 1;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px; align-content: start;
}
/* 空状态那一格撑满卡片，避免卡片下方留一条空白带。 */
.quick-news-list:has(.news-empty) { align-content: stretch; }
.quick-news-card {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  padding: 14px; position: relative;
}
.quick-news-card.selected { outline: 1px solid var(--accent); outline-offset: -1px; }
.quick-news-card h3 { margin: 0 34px 8px 0; font-size: 15px; font-weight: 600; line-height: 1.5; }
.quick-check { position: absolute; right: 12px; top: 14px; width: 18px; height: 18px; accent-color: var(--accent); }
.quick-meta { display: flex; gap: 10px; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.quick-summary { margin: 0 0 8px; font-size: 13px; line-height: 1.65; color: var(--ink-soft); }
/* 改写句就是图上那句正文，所以给它正文的待遇：字更黑、带一点纸面底色，和「概述」区分开 */
.quick-brief {
  margin: 0 0 8px; padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: 0 6px 6px 0;
}
.quick-brief-text { margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink); }
.quick-brief-why { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.quick-brief-pager {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 6px; font-size: 11px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.quick-brief-pager button {
  min-height: 22px; width: 22px; padding: 0;
  line-height: 1; font-size: 13px;
}
.quick-points { margin: 0; font-size: 12px; color: var(--accent); }
.quick-card-actions { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quick-card-actions details { flex: 1; font-size: 13px; }
.quick-card-actions summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.quick-card-actions button { min-height: 32px; font-size: 12px; }

/* ---------- 候选列表的两级目录：渠道（一级）→ 当日/昨日（二级） ----------
   七家平铺时找一家要从头扫到尾；折起来一屏七行，展开哪家就是哪家的两天。 */
.fold { border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.fold-source { grid-column: 1 / -1; overflow: hidden; }
.fold-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 11px 14px; cursor: pointer; user-select: none; list-style: none;
}
.fold-head::-webkit-details-marker { display: none; }
.fold-head::before {
  content: '▸'; flex: none; align-self: center;
  font-size: 11px; color: var(--muted); display: inline-block; transition: transform .12s ease;
}
.fold[open] > .fold-head::before { transform: rotate(90deg); }
.fold-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.fold-name em { margin-left: 6px; font-size: 11px; font-style: normal; font-weight: 400; color: var(--muted); }
.fold-meta { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fold-days { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
.fold-day { margin-left: 10px; background: color-mix(in srgb, var(--ink) 2%, transparent); }
.fold-head-day { padding: 8px 12px; }
.fold-head-day .fold-name { font-size: 13px; font-weight: 500; }
.fold-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 10px; padding: 0 12px 12px;
}

.news-empty {
  border: 1px dashed var(--rule-strong);
  border-radius: 8px;
  padding: 28px 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.quick-news-list .news-empty {
  grid-column: 1 / -1;
  height: 100%; min-height: 220px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  gap: 14px;
  padding: 24px;
  text-align: left;
}
.quick-news-list .news-empty > span { max-width: 46ch; }
.quick-news-list .news-empty button { min-height: 34px; font-size: 13px; margin-top: 4px; }
.first-run-note {
  margin: 0; width: 100%; padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 12px; line-height: 1.7; color: var(--muted);
}

/* 首屏的第一件事：三步走，真实顺序用 ol */
.first-run { margin: 0; padding-left: 20px; width: 100%; }
.first-run li { padding: 12px 0 12px 2px; border-top: 1px solid var(--rule); }
.first-run li:first-child { border-top: 0; }
.first-run li:last-child { padding-bottom: 4px; }
.first-run strong { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.first-run span { display: block; font-size: 12.5px; line-height: 1.65; color: var(--muted); margin-top: 3px; }

/* ---------- 工作区 ---------- */
.workspace { display: grid; grid-template-columns: minmax(320px, 1fr) 374px; min-height: calc(100vh - 56px); }
.workspace[hidden] { display: none; }
.canvas-zone { padding: 24px 28px 32px; display: flex; flex-direction: column; align-items: center; background: var(--studio); }
.canvas-head {
  width: min(100%, 650px);
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 14px;
}
.canvas-title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.canvas-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.canvas-wrap {
  width: min(100%, 650px); aspect-ratio: 3 / 4;
  background: #fff; outline: 1px solid var(--rule-strong);
}
#poster { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
.canvas-hint { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.selection-layer .box { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 10 7; pointer-events: none; }
.selection-layer .handle { fill: #fff; stroke: var(--accent); stroke-width: 3; pointer-events: all; }
.selection-layer .handle[data-handle="n"], .selection-layer .handle[data-handle="s"] { cursor: ns-resize; }
.selection-layer .handle[data-handle="e"], .selection-layer .handle[data-handle="w"] { cursor: ew-resize; }
.selection-layer .handle[data-handle="nw"], .selection-layer .handle[data-handle="se"] { cursor: nwse-resize; }
.selection-layer .handle[data-handle="ne"], .selection-layer .handle[data-handle="sw"] { cursor: nesw-resize; }
.guides-layer .guide { stroke: #2f8f74; stroke-width: 2; stroke-dasharray: 8 6; opacity: .9; }
.safe-area .edge { fill: none; stroke: #2f8f74; stroke-width: 2; stroke-dasharray: 14 10; opacity: .55; }

/* ---------- 侧栏 ---------- */
.inspector { background: var(--paper); border-left: 1px solid var(--rule); }
.tabs {
  position: sticky; top: 56px; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--rule); background: var(--paper);
}
.tab { border: 0; border-radius: 0; background: transparent; padding: 14px 4px; min-height: 0; font-size: 13px; color: var(--muted); }
.tab:hover { background: #f5f5f2; }
.tab.active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--accent); }
.panel { display: none; padding: 20px 18px; }
.panel.active { display: block; }
.panel-heading { font-size: 13px; margin: 22px 0 12px; padding-top: 16px; border-top: 1px solid var(--rule); color: var(--ink); }

/* 没有选中元素时：只留一句引导，不摆一排禁用控件 */
.panel-empty {
  margin: 0 0 2px;
  padding: 13px 14px;
  border-radius: 6px;
  background: #f6f6f3;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.panel-empty[hidden] { display: none; }

/* 二级目录：一组参数一个折叠标题，展开才出控件 */
.sect { border-top: 1px solid var(--rule); }
.sect[hidden], .sel-block[hidden] { display: none; }
.sect > summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 13px 0;
  font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; list-style: none;
}
.sect > summary::-webkit-details-marker { display: none; }
.sect > summary::after {
  content: ""; flex: 0 0 auto;
  width: 7px; height: 7px; margin-right: 4px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
}
.sect[open] > summary::after { transform: rotate(225deg) translate(-1px, -1px); }
.sect > summary:hover { color: var(--accent); }
.sect > summary:hover::after { border-color: var(--accent); }
.sect > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sect-body { padding: 0 0 16px; }
.sect-body > :last-child { margin-bottom: 0; }
.sect-hint { margin: 12px 0 10px; font-size: 12px; line-height: 1.65; color: var(--muted); }
.sect-sub { margin: 16px 0 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.row-3 button { padding: 7px 4px; min-height: 32px; font-size: 12px; }
.sel-block .segmented { margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 7px; margin: 0 0 16px; }
.field > span { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.row > button { width: 100%; }
textarea, select, input[type="search"], input[type="text"] {
  width: 100%; padding: 9px 10px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--paper);
}
textarea { resize: vertical; line-height: 1.6; }
input[type="color"] { width: 100%; height: 36px; padding: 3px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--paper); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
output { font-variant-numeric: tabular-nums; color: var(--ink); }
.note { margin: 6px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted); }
.inline-tools { margin: 0 0 16px; padding: 11px; background: #f5f5f2; border-left: 3px solid var(--accent); }
.inline-tools > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.inline-tools > div { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.inline-tools button { padding: 6px 3px; min-height: 30px; font-size: 12px; }
.insert-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.insert-grid button { padding: 8px 6px; min-height: 34px; font-size: 13px; }
.template-button { width: 100%; background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.template-button:hover:not(:disabled) { background: #2c2e30; border-color: #2c2e30; }
.template-button + .template-button { margin-top: 8px; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 4px; }
.preset-grid button { padding: 7px 4px; min-height: 32px; font-size: 12px; }
.preset-grid button.active, .layer-item.active, .page-item.active { border-color: var(--accent); }
.layer-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.layer-actions button { padding: 7px 4px; min-height: 32px; font-size: 12.5px; }
.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer-item { display: flex; gap: 8px; align-items: center; text-align: left; padding: 8px 10px; min-height: 34px; font-size: 13px; }
.layer-item.active { background: var(--accent-tint); }
.layer-kind { flex-shrink: 0; font-size: 11px; color: var(--muted); border: 1px solid var(--rule); border-radius: 3px; padding: 0 4px; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.page-item { text-align: left; padding: 8px 10px; min-height: 34px; font-size: 13px; }
.check-field { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 13px; }
.check-field input { width: 16px; height: 16px; accent-color: var(--accent); }
.mark-controls { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 4px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented button.active { background: var(--accent-tint); border-color: var(--accent); font-weight: 600; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.theme-grid button { padding: 9px 4px; min-height: 34px; font-size: 12px; }
.theme-grid button.active { outline: 2px solid var(--accent); outline-offset: -2px; }
.theme-paper { background: #f4f0e7; } .theme-news { background: #e8e9e6; } .theme-mint { background: #dfece3; }
.theme-rose { background: #f1dddc; } .theme-white { background: #fff; } .theme-lemon { background: #fff3c9; }
.theme-sky { background: #dce8ef; } .theme-lavender { background: #e8e0ef; }
.theme-charcoal { background: #282a29; color: #fff; } .theme-coral { background: #f4d1ca; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
.sticker-btn { aspect-ratio: 1; display: grid; place-items: center; padding: 6px; min-height: 0; }
.sticker-btn svg { width: 100%; height: 100%; }

/* ---------- 时政卡 ---------- */
.news-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.news-head > div { display: flex; flex-direction: column; gap: 4px; }
.news-head small { font-size: 11px; color: var(--muted); line-height: 1.5; }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-bottom: 14px; }
.search-form .field { margin: 0; }
.search-form > button { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 渠道告警：连续抓不到就明着说，不假装正常 */
.news-health {
  margin-bottom: 12px; padding: 9px 12px;
  border: 1px solid #e6c373; border-left-width: 3px; border-radius: 4px;
  background: #fdf6e3; color: #7a5a12;
  font-size: 11.5px; line-height: 1.6;
}
.news-health[hidden] { display: none; }
.news-health p { margin: 0; }
.news-health p + p { margin-top: 3px; }

/* ---------- 接入模型 ---------- */
.news-head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
#agentSettingsBtn { white-space: nowrap; }
.agent-entry { font-size: 12px; }
.agent-entry[data-state="on"] { border-color: #6f9e6f; color: #2f6b2f; background: #eef7ee; }
.agent-entry[data-state="on"]::before { content: "●"; margin-right: 4px; font-size: 9px; vertical-align: 1px; }
.agent-entry[data-state="off"] { color: var(--muted); }

.agent-dialog {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(28, 25, 20, 0.42);
}
.agent-dialog[hidden] { display: none; }
.agent-dialog-card {
  width: min(440px, 100%); max-height: 86vh; overflow: auto;
  padding: 18px 20px 16px; border-radius: 8px;
  background: #fff; border: 1px solid #ddd6c8;
  box-shadow: 0 18px 48px rgba(28, 25, 20, 0.22);
}
.agent-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.agent-dialog-head h2 { margin: 0; font-size: 15px; }
.agent-status { margin: 0 0 12px; padding: 8px 10px; border-radius: 4px; font-size: 12px; line-height: 1.6; background: #f4f1ea; color: #5b5449; }
.agent-status[data-level="ok"] { background: #eef7ee; color: #2f6b2f; }
.agent-status[data-level="warn"] { background: #fdf6e3; color: #7a5a12; }
.agent-status[data-level="error"] { background: #fdeeee; color: #8a2f2f; }
.agent-form .field { margin-bottom: 10px; }
.agent-hint { margin: 0 0 10px; font-size: 12px; line-height: 1.6; color: #5b5449; }
.agent-hint[hidden] { display: none; }
.agent-hint[data-level="ok"] { color: #2f6b2f; }
.agent-hint[data-level="warn"] { color: #7a5a12; }
.agent-hint[data-level="error"] { color: #8a2f2f; }
.agent-usage { margin: 0 0 12px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.agent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.agent-actions .primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.agent-dialog-card .note { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.6; }
.agent-dialog-card code { background: #f4f1ea; padding: 1px 4px; border-radius: 3px; }

/* 来源筛选条：七家渠道一眼可数，取不到的置灰 */
.source-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.source-chips:empty { display: none; }
.source-chip {
  min-height: 26px; padding: 3px 10px;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  background: transparent; color: var(--ink-soft);
  font-size: 11.5px; line-height: 1.4; white-space: nowrap;
}
.source-chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.source-chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.source-chip.is-empty { opacity: .45; cursor: not-allowed; }

.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-card { border: 1px solid var(--rule); background: var(--paper); border-radius: 6px; padding: 12px; }
.news-card h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.5; }
.news-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 9px; }
.news-card details { margin: 8px 0 10px; border-top: 1px solid var(--rule); padding-top: 8px; }
.news-card summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
.exam-summary { font-size: 13px; line-height: 1.7; color: var(--ink-soft); }
.exam-summary strong { display: block; color: var(--ink); margin-top: 6px; }
.exam-summary a { font-size: 12px; color: var(--accent); }
.news-card button { width: 100%; margin-top: 8px; padding: 6px; min-height: 32px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: min(92vw, 420px);
  padding: 11px 16px; border-radius: 6px;
  background: var(--ink); color: #fff; font-size: 13px; line-height: 1.5;
  opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- AI 助手 ---------- */
.assistant-box {
  margin: 0;
  padding: 12px 14px 10px;
  border: 1px solid var(--rule);
  border-left: 3px solid #2f8f74;
  background: #f3f6f2;
}
.assistant-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; font-size: 13px;
}
.assistant-state {
  font-size: 11px; font-weight: 700; color: #2f8f74;
  border: 1px solid #a9c9bd; border-radius: 3px; padding: 1px 6px;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assistant-state.off { color: var(--muted); border-color: var(--rule); }
.assistant-box .row { margin-bottom: 0; }
.assistant-box .note { margin: 8px 0 0; }

/* ---------- 启动失败提示 ---------- */
.boot-help {
  position: fixed; inset: 0; z-index: 80;
  display: grid; align-content: center; justify-items: start;
  gap: 10px; padding: 32px clamp(20px, 8vw, 120px);
  background: var(--paper); color: var(--ink);
}
.boot-help[hidden] { display: none; }
.boot-help h2 { margin: 0; font-size: 24px; }
.boot-help p { margin: 0; max-width: 640px; line-height: 1.8; font-size: 14px; color: var(--ink-soft); }
.boot-help pre {
  margin: 4px 0; padding: 12px 16px;
  background: var(--ink); color: #f2f2ef; border-radius: 6px; font-size: 13px;
}
.boot-help code { background: #eeeeea; padding: 1px 5px; border-radius: 3px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .stage-grid { grid-template-columns: 1fr; }
  .candidates { order: 1; }
  .canvas-card { order: 2; max-width: 420px; margin: 0 auto; width: 100%; }
  .canvas-slot { max-width: 320px; width: 100%; margin: 0 auto; aspect-ratio: 3 / 4; }
  .quick-news-list .news-empty { min-height: 160px; }
}

@media (max-width: 980px) {
  .app-status { display: none; }
}

@media (max-width: 760px) {
  .topbar { height: 56px; padding: 0 16px; gap: 12px; }
  .brand-context, .brand-divider, .version-badge { display: none; }
  .brand-name { font-size: 15px; }
  .nav-toggle {
    position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
  }
  .nav-toggle:checked ~ .nav-toggle-label { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
  .nav-toggle-label {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 0 14px; margin-left: auto;
    border: 1px solid var(--rule-strong); border-radius: 6px;
    background: var(--paper); font-size: 13px; color: var(--ink);
  }
  .top-actions { display: none; }
  #navToggle:checked ~ .top-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
    position: absolute; top: 56px; left: 0; right: 0; z-index: 30;
    padding: 12px 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
  }
  #navToggle:checked ~ .top-actions > * { flex: 1 1 auto; min-height: 44px; }
  #navToggle:focus-visible ~ .nav-toggle-label { outline: 2px solid var(--accent); outline-offset: 2px; }

  .quick-stage { padding: 18px 16px 32px; }
  .stage-head { flex-direction: column; align-items: flex-start; gap: 14px; padding-bottom: 16px; margin-bottom: 16px; }
  .stage-title h1, .stage-title h2 { font-size: 20px; }
  .stage-lead { font-size: 13px; }
  .stage-actions { width: 100%; }
  .stage-actions button { flex: 1; min-height: 44px; }
  .panel-card { padding: 14px; }
  .canvas-slot { max-width: 280px; }

  .workspace { display: block; min-height: 0; }
  .canvas-zone { padding: 16px 16px 22px; }
  .canvas-head { width: min(100%, 520px); }
  .canvas-wrap { width: min(100%, 520px); }
  .inspector { border-left: 0; border-top: 1px solid var(--rule); }
  .tabs { top: 56px; }
  .panel { padding: 18px 16px max(24px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  button, .toast { transition: none; }
}
