/* 贴近旧桌面工具：灰底、分组框、少装饰 */
:root {
  --bg: #f0f0f0;
  --panel: #ffffff;
  --ink: #222;
  --muted: #666;
  --line: #c8c8c8;
  --line-dark: #9a9a9a;
  --accent: #2b579a;
  --accent-soft: #dce6f4;
  --ok: #2e7d32;
  --warn: #b26a00;
  --fail: #b71c1c;
  --chip: #e8e8e8;
  --mono: Consolas, "Sarasa Mono SC", "Microsoft YaHei Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 13px/1.45 "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
}

.top {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--line-dark);
  background: #e8e8e8;
  padding: 0 8px;
}
.brand {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.tabs {
  display: flex;
  flex: 1;
  overflow-x: auto;
}
.tabs a {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  border-right: 1px solid var(--line);
  background: #dedede;
  white-space: nowrap;
}
.tabs a:hover { background: #d2d2d2; }
.tabs a.active {
  background: var(--panel);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}
.top-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.ui-ver {
  padding: 1px 6px;
  border: 1px solid var(--line-dark);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 12px 40px;
}
/* 工作台通栏：吃满屏幕宽度，去掉左右大空白 */
main.main-wide {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 10px 12px 16px;
}
body.page-workbench {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.page-workbench .top { flex-shrink: 0; }
body.page-workbench main.main-wide {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 10px;
}
body.page-workbench .context-bar,
body.page-workbench .step-bar {
  flex-shrink: 0;
}
body.page-workbench .workbench-3 {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.context-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.context-bar .label { color: var(--muted); }
.context-bar strong { font-weight: 700; }
.job-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
  align-items: center;
  flex-shrink: 0;
}
.step-bar-with-controls {
  align-items: center;
  gap: 10px;
}
.step-bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
.step-bar-meta {
  flex: 1 1 100%;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 16px 18px;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}
.modal-body {
  color: var(--ink);
  margin-bottom: 14px;
}
.modal-body ul {
  margin: 8px 0;
  padding-left: 18px;
}
.modal-body li { margin: 4px 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.step-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.step-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 12px;
  color: var(--muted);
}
.step-chip.done { background: #e8f5e9; color: var(--ok); border-color: #a5d6a7; }
.step-chip.running {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #90b4e0;
  font-weight: 700;
  animation: step-chip-running-blink 1.2s ease-in-out infinite;
}
.step-chip.failed { background: #ffebee; color: var(--fail); border-color: #ef9a9a; }
.step-chip.pending { opacity: 0.75; }
.step-chip.warn {
  background: #fff8e1;
  color: #b26a00;
  border-color: #ffe082;
  font-weight: 700;
}
@keyframes step-chip-running-blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(36, 77, 134, 0.0); }
  50% { opacity: 0.72; box-shadow: 0 0 0 3px rgba(36, 77, 134, 0.12); }
}
@media (prefers-reduced-motion: reduce) {
  .step-chip.running { animation: none; }
}

.box {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.box > .box-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  background: #f7f7f7;
}
.box-title-actions {
  display: inline-flex;
  gap: 6px;
  font-weight: 400;
}
.box > .box-body { padding: 10px; }

.form-grid {
  display: grid;
  gap: 10px;
  max-width: 640px;
}
.form-grid-wide {
  max-width: none;
  width: 100%;
}
.form-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: center;
}
.form-row-top { align-items: start; }
.form-row label { color: var(--muted); }
.book-params {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  display: grid;
  gap: 6px;
}
.book-params[hidden] {
  display: none !important;
}
.check-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 400;
}
.check-inline input { width: auto; }
.chapter-list { margin: 0; padding-left: 18px; }
.chapter-list li { margin: 4px 0; }
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}
#user_prompt {
  min-height: 120px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
}

input[type="file"],
input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--line-dark);
  background: #fff;
  font: inherit;
}
textarea { min-height: 80px; font-family: var(--mono); }

.form-compact {
  gap: 8px;
}
.form-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.form-pair-nums {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.form-field {
  display: grid;
  gap: 3px;
}
.form-field > label {
  color: var(--muted);
  font-size: 12px;
}
.form-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}
.form-checks-wrap .check-inline {
  font-size: 13px;
}
.input-block {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  display: grid;
  gap: 6px;
  background: #fafafa;
}
.input-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line-dark);
  background: #fff;
  cursor: pointer;
  font-weight: 400;
  color: var(--text);
}
.mode-chip:has(input:checked) {
  border-color: var(--accent);
  background: #eef4ff;
}
.mode-chip input { width: auto; margin: 0; }
.input-pane.is-hidden,
.input-pane[hidden] {
  display: none !important;
}
.folder-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.folder-select {
  width: 100%;
  min-height: 120px;
  max-height: 180px;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}
#folder-detect-msg { margin: 0; }
.book-params-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
  font-weight: 700;
}
.book-params-head .muted { font-weight: 400; font-size: 12px; }
.actions-compact { margin-top: 4px; }
.recipe-note {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.recipe-note > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}
.recipe-note[open] > summary { margin-bottom: 6px; }
.recipe-note .list { font-size: 12px; }
@media (max-width: 900px) {
  .form-pair,
  .form-pair-nums { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .form-pair,
  .form-pair-nums { grid-template-columns: 1fr; }
}

.btn {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line-dark);
  background: #f5f5f5;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: #ebebeb; }
.btn.primary {
  background: var(--accent);
  border-color: #1f3f70;
  color: #fff;
}
.btn.primary:hover { background: #244d86; }
.btn.danger { color: var(--fail); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.prompt-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.prompt-section-label {
  font-weight: 700;
  min-width: 5em;
}
.prompt-collapsed-summary {
  flex: 1 1 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-section.is-collapsed .prompt-section-body {
  display: none !important;
}
.prompt-section:not(.is-collapsed) .prompt-collapsed-summary {
  display: none;
}
.prompt-lib-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.prompt-lib-bar select {
  min-width: 220px;
  flex: 1 1 220px;
}
.prompt-lib-combo {
  position: relative;
  min-width: 240px;
  flex: 1 1 260px;
}
.prompt-lib-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font: inherit;
}
.prompt-lib-search:focus {
  outline: 2px solid rgba(36, 77, 134, 0.25);
  border-color: #244d86;
}
.prompt-lib-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 40;
  max-height: 280px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.prompt-lib-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  color: inherit;
}
.prompt-lib-option:hover,
.prompt-lib-option.is-active {
  background: #e8f0fe;
}
.prompt-lib-option .muted {
  display: block;
  font-size: 12px;
  color: var(--muted, #777);
  margin-top: 2px;
}
.prompt-lib-empty {
  padding: 10px;
  color: var(--muted, #777);
  font-size: 13px;
}
.prompt-lib textarea {
  width: 100%;
  min-height: 180px;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
}
table.list th,
table.list td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}
table.list th {
  background: #f7f7f7;
  font-weight: 700;
}
table.list tr:hover td { background: #fafafa; }
table.list a { color: var(--accent); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 12px;
}
.tag.ok { background: #e8f5e9; border-color: #a5d6a7; color: var(--ok); }
.tag.run { background: var(--accent-soft); border-color: #90b4e0; color: var(--accent); }
.tag.warn { background: #fff8e1; border-color: #ffe082; color: var(--warn); }
.tag.fail { background: #ffebee; border-color: #ef9a9a; color: var(--fail); }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.error {
  background: #fff5f5;
  border: 1px solid #ef9a9a;
  color: var(--fail);
  padding: 8px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
}
.monitor {
  margin: 0;
  background: #1e1e1e;
  color: #d4d4d4;
  border: 1px solid #333;
  padding: 8px 10px;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 var(--mono);
}
/* 任务进行中：闪动光标 + 轻微边框脉冲，表示还在干活 */
.monitor.is-live {
  border-color: #3d6a3d;
  box-shadow: inset 0 0 0 1px rgba(120, 200, 120, 0.12);
}
.monitor.is-live::after {
  content: "▋";
  display: inline;
  margin-left: 2px;
  color: #7dcea0;
  animation: monitor-caret 1s step-end infinite;
}
@keyframes monitor-caret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.monitor-live-dot {
  display: none;
  margin-left: 8px;
  color: #2e7d32;
  font-size: 12px;
  font-weight: 700;
}
.monitor-live-dot.on {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  animation: monitor-live-pulse 1.2s ease-in-out infinite;
}
.monitor-live-dot.on::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2e7d32;
}
@keyframes monitor-live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.inline-forms { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-forms form { display: inline-flex; gap: 6px; align-items: center; }
.review-item {
  border: 1px solid var(--line);
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fffef8;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
}
.h1 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

/* 工作台：两列兼容 / 三列（左操作 · 中日志 · 右 Hermes） */
.workbench {
  display: grid;
  grid-template-columns: minmax(320px, 42%) 1fr;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}
.workbench-3 {
  /* 左操作稍大，右 Hermes 加宽，方便对话 */
  grid-template-columns: minmax(400px, 1.25fr) minmax(320px, 1.05fr) minmax(360px, 1.15fr);
  gap: 10px;
  margin-bottom: 0;
  align-items: stretch;
}
@media (max-width: 1280px) {
  .workbench-3 {
    grid-template-columns: minmax(340px, 1.2fr) minmax(280px, 1fr) minmax(320px, 1.1fr);
  }
}
@media (max-width: 1100px) {
  .workbench-3 {
    grid-template-columns: minmax(320px, 1.15fr) 1fr;
  }
  .workbench-3 .wb-hermes {
    grid-column: 1 / -1;
    min-height: 320px;
    max-height: 42vh;
  }
}
@media (max-width: 900px) {
  .workbench,
  .workbench-3 { grid-template-columns: 1fr; }
  body.page-workbench {
    height: auto;
    max-height: none;
    overflow: auto;
  }
  body.page-workbench main.main-wide,
  body.page-workbench .workbench-3 {
    overflow: visible;
  }
  .workbench-3 .wb-hermes {
    max-height: none;
    min-height: 420px;
  }
}
.wb-left,
.wb-mid,
.wb-right,
.wb-hermes {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 整列不滚，避免输入框被卷走 */
}
.wb-left .box,
.wb-mid .box,
.wb-hermes .box { flex: 1; min-height: 0; }

.box-fill {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.box-body-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.box-body-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.monitor-tall {
  flex: 1;
  min-height: 420px;
  max-height: none;
  height: auto;
}
body.page-workbench .monitor-tall {
  min-height: 0;
  height: 100%;
}

.hermes-box { margin-top: 0; }
.hermes-body {
  min-height: 0;
  overflow: hidden; /* 本体不滚：只有对话区滚 */
  display: flex;
  flex-direction: column;
  gap: 0;
}
.hermes-body > .hint {
  flex-shrink: 0;
  margin-bottom: 6px;
}
.hermes-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.hermes-chat {
  background: #fafafa;
  border: 1px solid var(--line);
  min-height: 140px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  margin-bottom: 8px;
}
.hermes-chat-tall {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: none;
  margin-bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.hermes-msg {
  padding: 8px 10px;
  margin: 0 0 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 96%;
  font-size: 13px;
  line-height: 1.5;
}
.hermes-msg.bot {
  background: #eef3fa;
  border: 1px solid #c9d7ea;
}
.hermes-msg.user {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  margin-left: auto;
}
.hermes-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  position: relative;
  z-index: 2;
}
.hermes-form input[type="text"] {
  min-height: 36px;
  font-size: 13px;
}
.hermes-form .btn {
  min-height: 36px;
  padding: 0 14px;
}
.recipe-note {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

/* 大模型配置页（对齐旧桌面对话框） */
.llm-settings-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 10px 16px;
  max-width: 1100px;
}
.llm-settings-page .inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.llm-settings-page .inline-row input {
  flex: 1;
}
.llm-assign-table input[type="text"] {
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font: inherit;
}
.llm-assign-table td {
  vertical-align: top;
}
#wf-key-dialog {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  padding: 14px 16px;
  max-width: 480px;
  width: 92vw;
}
#wf-key-dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
}

/* —— 全站 Hermes 助手坞 —— */
.hermes-top-btn {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 12px;
}
.hermes-dock-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 24px));
  max-height: min(72vh, 640px);
  background: #fff;
  border: 1px solid var(--line-dark);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  z-index: 80;
  display: none;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
}
.hermes-dock.is-open .hermes-dock-panel {
  display: flex;
}
.hermes-dock-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.hermes-dock-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hermes-dock-chat {
  flex: 1 1 auto;
  min-height: 160px;
  max-height: 280px;
  margin-bottom: 0;
}
.hermes-dock-form {
  flex-shrink: 0;
}
.hermes-dock-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hermes-dock-audit {
  border: 1px solid var(--line);
  background: #fafafa;
  padding: 6px 8px;
  max-height: 160px;
  overflow: auto;
  font-size: 12px;
}
.hermes-audit-head {
  font-weight: 700;
  margin-bottom: 4px;
}
.hermes-audit-row {
  padding: 2px 0;
  border-bottom: 1px dotted var(--line);
}
.hermes-audit-row.st-pass { color: #1b6b2a; }
.hermes-audit-row.st-warn { color: #8a5a00; }
.hermes-audit-row.st-fail { color: #a11818; }
.hermes-audit-row.st-running { color: #1f3f70; }
body.page-workbench .hermes-dock-panel {
  /* 洗炼页已有右侧 Hermes，坞靠下避免挡住 */
  bottom: 12px;
}
