:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #25211b;
  --muted: #746f66;
  --line: #ded7ca;
  --line-strong: #c9bda9;
  --teal: #1f7a74;
  --teal-soft: #e4f2ef;
  --amber: #b36a1f;
  --amber-soft: #f6eadb;
  --red: #a74338;
  --red-soft: #f6e5e2;
  --green: #4d7f3f;
  --green-soft: #e6f0df;
  --blue: #35698a;
  --blue-soft: #e3edf3;
  --shadow: 0 18px 45px rgba(62, 53, 39, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #29241d;
  color: #f8f2e8;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7d590, #72b7ad);
  color: #1e1b17;
  font-weight: 800;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
}

.brand-meta,
.project-label,
.section-kicker,
.eyebrow,
.tile-label,
.plan-block span,
.version-table span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar .brand-meta,
.sidebar .project-label,
.sidebar .section-kicker {
  color: #bcb0a0;
}

.project-switcher {
  padding: 0 4px;
}

.project-button,
.new-project-button,
.idea-project-button,
.nav-item,
.chapter-row {
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  color: inherit;
  background: transparent;
}

.project-button {
  justify-content: space-between;
  padding: 0 12px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.new-project-button {
  justify-content: center;
  margin-top: 8px;
  color: #fffaf2;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 800;
}

.new-project-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.idea-project-button {
  justify-content: center;
  margin-top: 8px;
  color: #1f2b29;
  background: #72b7ad;
  font-weight: 800;
}

.idea-project-button:hover {
  background: #8bc8bf;
}

.main-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  gap: 10px;
  padding: 0 10px;
  color: #dfd5c8;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fffaf2;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.chapter-list {
  display: grid;
  gap: 7px;
}

.chapter-row {
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #d9cfbf;
}

.chapter-row span:first-child {
  width: 32px;
  color: #a99d8c;
}

.chapter-row.active {
  color: #fff;
  background: rgba(114, 183, 173, 0.25);
}

.chapter-row.done span:first-child {
  color: #8cc7a0;
}

.chapter-row.draft span:first-child {
  color: #f0c06c;
}

.main-shell {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  padding: 18px 26px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 243, 236, 0.86);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.page-head h2,
.panel h2 {
  margin: 0;
  line-height: 1.2;
}

.topbar h1 {
  font-size: 22px;
}

.top-actions,
.button-group,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.segment {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-button {
  background: var(--teal);
  color: white;
}

.primary-button:hover {
  background: #176b66;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.secondary-button {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover,
.secondary-button:hover {
  border-color: var(--line-strong);
  background: #fff;
}

.danger-button {
  appearance: none;
  border: 1px solid #f4c4c4;
  background: #fff5f5;
  color: #c0392b;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.danger-button:hover {
  background: #ffe9e9;
  border-color: #e88;
}
.danger-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.project-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.project-card-actions > button {
  flex: 0 0 auto;
}

.primary-button.full {
  width: 100%;
  margin-top: 12px;
}

.content-grid {
  padding: 22px 26px 32px;
}

.view-panel {
  display: none;
}

.view-panel.is-visible {
  display: block;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.center-column {
  display: grid;
  gap: 16px;
}

.quick-start-panel {
  min-height: 158px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
  align-items: stretch;
  background: linear-gradient(135deg, #fffdf8, #e3edf3);
}

.quick-copy {
  display: grid;
  align-content: center;
  gap: 8px;
}

.quick-copy h2,
.finish-panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.22;
}

.quick-copy p,
.finish-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.model-status {
  width: fit-content;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.model-status.connected {
  background: var(--green-soft);
  border-color: #b7d2aa;
  color: var(--green);
}

.model-status.offline {
  background: var(--amber-soft);
  border-color: #e3c795;
  color: var(--amber);
}

.quick-start-form {
  display: grid;
  gap: 10px;
}

.quick-start-form textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  line-height: 1.55;
  outline: none;
}

.quick-length-field {
  display: grid;
  gap: 6px;
}

.quick-length-field span {
  color: var(--muted);
  font-size: 12px;
}

.quick-length-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.quick-start-form textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.1);
}

.quick-length-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.1);
}

.quick-actions,
.finish-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.quick-current {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.quick-current span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.finish-panel {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: linear-gradient(135deg, #fffdf8, #e6f0df);
}

.finish-panel[hidden] {
  display: none;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.status-tile,
.quick-start-panel,
  .workflow-panel,
  .finish-panel,
  .panel,
  .rail-panel,
  .memory-card,
.hook-card,
.score-card,
.character-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.book-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}

.book-layout .panel:last-child {
  grid-column: 1 / -1;
}

.book-summary {
  display: grid;
  gap: 12px;
}

.book-summary h3 {
  margin: 0;
  font-size: 20px;
}

.book-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-tile,
.archive-card,
.outline-mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 12px;
}

.summary-tile span,
.archive-card span,
.outline-mini-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.summary-tile strong {
  font-size: 18px;
}

.archive-list,
.outline-mini-list {
  display: grid;
  gap: 10px;
}

.archive-card,
.outline-mini-card {
  display: grid;
  gap: 8px;
}

.archive-card h3,
.outline-mini-card h3 {
  margin: 0;
  font-size: 16px;
}

.archive-card p,
.outline-mini-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.archive-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.project-shelf-list {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.project-card {
  min-height: 118px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.7fr) 128px;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 14px;
}

.project-card.active {
  border-color: rgba(31, 122, 116, 0.45);
  background: #eef7f5;
}

.project-card-main,
.project-card-meta {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.project-card-main span,
.project-card-meta span {
  color: var(--muted);
  font-size: 12px;
}

.project-card-main h3 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.project-card-main p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.project-card .shelf-open {
  min-height: 40px;
}

.reader-modal {
  width: min(860px, 100%);
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.reader-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.reader-content {
  display: grid;
  gap: 14px;
}

.reader-scene {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 16px;
}

.reader-scene h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.reader-scene p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.reader-text {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.9;
  white-space: pre-wrap;
}

.status-tile {
  min-height: 76px;
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.status-tile strong {
  font-size: 15px;
}

.workflow-panel {
  min-height: 112px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
  gap: 16px;
  align-items: center;
  background: linear-gradient(135deg, #fffdf8, #e9f3f0);
}

.workflow-copy h2 {
  margin: 4px 0 8px;
  font-size: 20px;
}

.workflow-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.workflow-actions {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.workflow-button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.workflow-steps {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.workflow-step {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fffaf2;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  padding: 0 6px;
}

.workflow-step.done {
  background: var(--green-soft);
  border-color: #b7d2aa;
  color: var(--green);
  font-weight: 800;
}

.workflow-step.active {
  background: var(--teal-soft);
  border-color: #9ccfc7;
  color: var(--teal);
  font-weight: 800;
}

.panel {
  padding: 16px;
}

.panel-header,
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel-header p,
.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.panel-header.compact {
  align-items: center;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.plan-block {
  min-height: 92px;
  padding: 12px;
  background: #faf7ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
}

.plan-block strong {
  line-height: 1.55;
}

.scene-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.scene-card {
  min-height: 178px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fffaf1;
  border-radius: 8px;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 8px;
  color: var(--ink);
}

.scene-card:hover,
.scene-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.12);
}

.scene-card .scene-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
}

.scene-card h3 {
  margin: 0;
  font-size: 15px;
}

.scene-card p {
  margin: 0;
  line-height: 1.55;
  color: var(--muted);
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
}

.tag.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag.success {
  background: var(--green-soft);
  color: var(--green);
}

.editor-panel {
  min-height: 360px;
}

.chapter-editor {
  min-height: 268px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  line-height: 1.9;
  outline: none;
  white-space: pre-wrap;
}

.chapter-editor:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.1);
}

.right-rail {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 106px;
}

.rail-panel {
  padding: 14px;
}

.rail-title {
  font-weight: 800;
  margin-bottom: 12px;
}

.director-stack,
.patch-list,
.issue-list,
.memory-grid,
.timeline {
  display: grid;
  gap: 10px;
}

.agent-step {
  border-left: 3px solid var(--line-strong);
  padding: 8px 0 8px 12px;
  display: grid;
  gap: 3px;
}

.agent-step span {
  color: var(--muted);
  font-size: 12px;
}

.agent-step.done {
  border-left-color: var(--green);
}

.agent-step.active {
  border-left-color: var(--amber);
}

.agent-step.pending {
  border-left-color: var(--line-strong);
}

.patch-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  display: grid;
  gap: 5px;
}

.patch-item span {
  color: var(--muted);
  font-size: 12px;
}

.issue-row {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fffaf2;
  display: grid;
  gap: 5px;
}

.issue-row strong {
  color: var(--red);
}

.issue-row.warning strong {
  color: var(--amber);
}

.issue-row span {
  color: var(--muted);
  line-height: 1.45;
}

.style-report {
  display: grid;
  gap: 10px;
}

.style-report p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.style-score {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 22px;
  font-weight: 900;
}

.style-score.pending {
  width: auto;
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  background: var(--amber-soft);
  color: var(--amber);
}

.style-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.style-tags span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fffaf2;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
}

.style-platform {
  display: grid;
  gap: 4px;
  margin: 2px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.style-platform strong {
  color: var(--text);
}

.style-platform span {
  color: var(--muted);
  line-height: 1.6;
}

.style-report ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.page-head {
  margin-bottom: 16px;
}

.page-head h2 {
  font-size: 22px;
}

.segmented {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 4px;
  border-radius: 8px;
}

.segment {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--teal);
  color: white;
}

.memory-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.memory-card {
  padding: 15px;
  min-height: 150px;
  display: grid;
  gap: 8px;
}

.memory-card h3,
.hook-card h3,
.score-card h3 {
  margin: 0;
  font-size: 15px;
}

.memory-card p,
.hook-card p,
.score-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 12px;
}

.kanban-column {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.65);
  padding: 12px;
}

.kanban-column h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.hook-card {
  padding: 12px;
  margin-bottom: 10px;
}

.hook-card .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.character-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.relation-map {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 122, 116, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(31, 122, 116, 0.08) 1px, transparent 1px),
    var(--surface);
  background-size: 42px 42px;
  position: relative;
  overflow: hidden;
}

.relation-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.relation-lines line {
  stroke: #b6ab9a;
  stroke-width: 2;
}

.person-node {
  position: absolute;
  width: 128px;
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 3px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: #fffaf2;
  box-shadow: var(--shadow);
  padding: 8px;
  text-align: center;
}

.person-node strong,
.person-node span {
  overflow-wrap: anywhere;
}

.person-node strong {
  font-size: 14px;
}

.person-node span {
  color: var(--muted);
  font-size: 11px;
}

.person-node:hover,
.person-node.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(31, 122, 116, 0.12);
}

.person-node.protagonist {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.person-node.antagonist {
  background: var(--red-soft);
  border-color: var(--red);
}

.person-node.mentor {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.person-node.ally {
  background: var(--green-soft);
  border-color: var(--green);
}

.person-node.faction {
  background: var(--amber-soft);
  border-color: var(--amber);
}

.character-side {
  display: grid;
  gap: 12px;
}

.character-detail {
  padding: 16px;
  min-height: 280px;
}

.character-detail,
.relationship-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.relationship-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.relation-card {
  width: 100%;
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 10px;
  text-align: left;
}

.relation-card.active,
.relation-card:hover {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.1);
}

.relation-card span {
  color: var(--muted);
  font-size: 12px;
}

.relation-card strong {
  font-size: 14px;
}

.relation-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.detail-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.audit-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.score-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.score-card {
  padding: 14px;
}

.score-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.score-value {
  font-weight: 800;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: #ece4d7;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.meter > span.warn {
  background: var(--amber);
}

.meter > span.danger {
  background: var(--red);
}

.trace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
}

.trace-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.trace-time {
  color: var(--muted);
  font-size: 12px;
}

.trace-item h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.trace-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.version-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.version-table div {
  min-height: 44px;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.version-table div:last-child {
  border-bottom: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 24px);
  min-height: 42px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 8px;
  background: #25211b;
  color: #fffaf1;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(37, 33, 27, 0.42);
  z-index: 50;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(37, 33, 27, 0.28);
  padding: 20px;
}

.wide-modal {
  width: min(980px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f5eee2;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  background: #eee2d0;
}

.project-form {
  display: grid;
  gap: 14px;
}

.project-form label,
.model-form label {
  display: grid;
  gap: 7px;
}

.project-form label span,
.model-form label span {
  color: var(--muted);
  font-size: 13px;
}

.project-form input,
.project-form select,
.project-form textarea,
.model-form input,
.model-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.project-form input,
.project-form select,
.model-form input,
.model-form select {
  min-height: 42px;
}

.project-form textarea {
  resize: vertical;
  line-height: 1.6;
}

.project-form input:focus,
.project-form select:focus,
.project-form textarea:focus,
.model-form input:focus,
.model-form select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.idea-result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.idea-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.idea-result-header h3,
.outline-layout h3 {
  margin: 0 0 8px;
}

.idea-result-header p,
.idea-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.idea-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.idea-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 12px;
}

.idea-box.wide {
  grid-column: 1 / -1;
}

.idea-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.genre-rule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px;
}

.genre-rule-card strong {
  display: block;
  margin-bottom: 6px;
}

.genre-rule-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.choice-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  padding: 0 10px;
  font-weight: 800;
}

.choice-pill.selectable {
  border: 1px solid rgba(31, 122, 116, 0.2);
}

.choice-pill.selectable:hover,
.choice-pill.selectable.selected {
  background: var(--teal);
  color: #fffdf8;
}

.synopsis-choice-list {
  display: grid;
  gap: 10px;
}

.synopsis-choice {
  width: 100%;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 12px;
  color: var(--ink);
  text-align: left;
}

.synopsis-choice:hover,
.synopsis-choice.selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 116, 0.1);
}

.synopsis-choice span {
  color: var(--muted);
  line-height: 1.6;
}

.model-form {
  display: grid;
  gap: 16px;
}

.model-status-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  padding: 12px;
}

.model-status-card span {
  color: var(--muted);
  line-height: 1.5;
}

.model-status-card .key-source {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  width: fit-content;
}
.model-status-card .key-source-own {
  background: #d9efe8;
  color: #1f6a5a;
  border: 1px solid #2c8c7e;
}
.model-status-card .key-source-default {
  background: #fff4d6;
  color: #8a6a1f;
  border: 1px solid #d49a3a;
}
.model-status-card .key-source-none {
  background: #fbeae7;
  color: #a02d20;
  border: 1px solid #c0392b;
}
.model-status-card .key-source-hint {
  font-size: 12px;
  color: #6a7280;
  font-style: italic;
}
.model-status-card code {
  background: #f4f6f8;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #2c3e50;
}

.agent-model-list {
  display: grid;
  gap: 10px;
}

.agent-model-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 12px;
}

.agent-model-row > div,
.agent-model-row label,
.test-agent-field {
  display: grid;
  gap: 6px;
}

.agent-model-row span,
.test-agent-field span {
  color: var(--muted);
  font-size: 12px;
}

.agent-model-row input,
.test-agent-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.outline-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.outline-list,
.chapter-outline-list {
  display: grid;
  gap: 10px;
}

.outline-card,
.chapter-outline-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 12px;
}

.outline-card strong,
.chapter-outline-card strong {
  display: block;
  margin-bottom: 5px;
}

.outline-card p,
.chapter-outline-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .workspace-layout,
  .book-layout,
  .character-layout,
  .audit-layout,
  .trace-layout,
  .quick-start-panel,
  .workflow-panel,
  .finish-panel,
  .outline-layout {
    grid-template-columns: 1fr;
  }

  .project-card {
    grid-template-columns: 1fr;
  }

  .agent-model-row {
    grid-template-columns: 1fr;
  }

  .project-card .shelf-open {
    width: 100%;
  }

  .workflow-button-row {
    justify-content: stretch;
  }

  .workflow-button-row button {
    flex: 1 1 180px;
  }

  .right-rail {
    position: static;
  }

  .scene-board,
  .kanban {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .main-nav,
  .chapter-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .panel-header,
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .content-grid,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .status-strip,
  .plan-grid,
  .memory-grid,
  .score-matrix,
  .scene-board,
  .kanban,
  .workflow-steps,
  .idea-grid,
  .genre-rule-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .kanban-column {
    min-height: 0;
  }
}

/* ========================================================================
   题材成书 · 打磨循环 (W1)
   ========================================================================  */

.idea-result-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.confirm-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #b36a1f;
  background: rgba(179, 106, 31, 0.08);
  border: 1px dashed rgba(179, 106, 31, 0.35);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
}

.confirm-row input[type="checkbox"] {
  accent-color: #b36a1f;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

#adoptIdeaBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.idea-box {
  position: relative;
}

.idea-box .box-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.box-action-btn {
  appearance: none;
  border: 1.5px solid #1f7a74;
  background: #1f7a74;
  color: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 3px rgba(31, 122, 116, 0.25);
}

.box-action-btn:hover {
  background: #176560;
  border-color: #176560;
  box-shadow: 0 2px 6px rgba(31, 122, 116, 0.35);
}

.box-action-btn:active {
  transform: translateY(1px);
}

.box-action-btn[data-polish="history"] {
  background: #fff;
  color: #1f7a74;
  box-shadow: none;
}

.box-action-btn[data-polish="history"]:hover {
  background: rgba(31, 122, 116, 0.1);
}

.inline-editor {
  margin-top: 10px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid rgba(179, 106, 31, 0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inline-editor-textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid rgba(31, 122, 116, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  background: #fff;
  resize: vertical;
}

.inline-editor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.refine-dialog.modal-backdrop,
.history-drawer.modal-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
}

.refine-modal {
  width: min(520px, 90vw);
  background: #fffdf8;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  padding: 0;
  display: flex;
  flex-direction: column;
}

.history-modal {
  width: min(720px, 92vw);
  max-height: 86vh;
  background: #fffdf8;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}

.refine-modal .modal-header,
.history-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(179, 106, 31, 0.2);
}

.refine-modal .modal-header h3,
.history-modal .modal-header h3 {
  margin: 0;
  font-size: 16px;
  color: #1f3a3a;
}

.refine-modal .modal-body,
.history-modal .modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.history-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.refine-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: #5a4a36;
  line-height: 1.6;
}

.refine-instruction {
  width: 100%;
  min-height: 90px;
  border: 1px solid rgba(31, 122, 116, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.refine-modal .modal-actions,
.history-modal .modal-actions {
  padding: 12px 18px;
  border-top: 1px solid rgba(179, 106, 31, 0.2);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.rev-card {
  border: 1px solid rgba(179, 106, 31, 0.2);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
}

.rev-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.rev-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(31, 122, 116, 0.12);
  color: #1f7a74;
}

.rev-tag.ai {
  background: rgba(179, 106, 31, 0.15);
  color: #b36a1f;
}

.rev-tag.manual {
  background: rgba(60, 90, 130, 0.12);
  color: #3c5a82;
}

.rev-tag.revert {
  background: rgba(120, 60, 60, 0.12);
  color: #7a3c3c;
}

.rev-ts {
  font-size: 12px;
  color: #888;
}

.rev-revert {
  margin-left: auto;
  font-size: 12px;
  padding: 4px 10px;
}

.rev-instruction {
  font-size: 13px;
  color: #5a4a36;
  background: rgba(179, 106, 31, 0.06);
  padding: 6px 10px;
  border-radius: 6px;
  margin: 0 0 10px;
}

.rev-empty {
  color: #888;
  text-align: center;
  padding: 24px;
}

.diff-pair {
  display: grid;
  grid-template-columns: 1fr 24px 1fr;
  align-items: stretch;
  gap: 8px;
}

.diff-cell {
  background: #f6f3ec;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.diff-cell strong {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
}

.diff-after {
  background: rgba(31, 122, 116, 0.08);
}

.diff-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b36a1f;
  font-size: 18px;
}

.diff-list {
  margin: 0;
  padding-left: 18px;
}

.diff-list li {
  margin: 2px 0;
}

@media (max-width: 720px) {
  .diff-pair {
    grid-template-columns: 1fr;
  }

  .diff-arrow {
    transform: rotate(90deg);
  }

  .idea-result-actions {
    align-items: flex-start;
  }
}

#ideaGenreBox .genre-pick-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.genre-pick-label {
  font-size: 14px;
  color: #5a4a36;
}

.genre-pick-label strong {
  color: #b36a1f;
  font-size: 15px;
  padding: 2px 10px;
  background: rgba(179, 106, 31, 0.1);
  border-radius: 999px;
  margin-left: 4px;
}

.genre-pick-select {
  appearance: none;
  border: 1px solid rgba(31, 122, 116, 0.3);
  background: #fffdf8;
  color: #1f7a74;
  border-radius: 8px;
  padding: 4px 28px 4px 12px;
  font-size: 13px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%231f7a74' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 8px 6px;
}

.genre-pick-select:disabled {
  opacity: 0.5;
  cursor: wait;
}

.genre-pick-hint {
  font-size: 12px;
  color: #999;
}

/* 改判流派后的「同步候选」横幅 */
.candidate-sync-banner {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fff4d6;
  border-left: 3px solid #d49a3a;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.candidate-sync-banner .sync-text {
  flex: 1 1 240px;
  color: #6b4a18;
}

.candidate-sync-banner .sync-btn {
  white-space: nowrap;
}

.candidate-sync-banner .sync-dismiss {
  background: transparent;
  border: 0;
  color: #b08a3c;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.candidate-sync-banner .sync-dismiss:hover {
  background: rgba(180, 138, 60, 0.15);
}

/* ===== 书案编辑引导横幅 ===== */
.idea-edit-guide {
  margin: 12px 0 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 1.5px solid #d49a3a;
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.6;
  color: #6b4a16;
}

.idea-edit-guide-icon {
  font-size: 22px;
  line-height: 1.2;
  flex-shrink: 0;
}

.idea-edit-guide-text {
  flex: 1;
}

.idea-edit-guide-text strong {
  color: #b3691f;
}

.idea-edit-guide .kbd {
  display: inline-block;
  padding: 1px 8px;
  background: #1f7a74;
  color: #fff;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  margin: 0 2px;
}

/* ===== 可编辑卡片的视觉提示 ===== */
.idea-box[data-field] {
  border: 1.5px dashed rgba(31, 122, 116, 0.35);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.idea-box[data-field]:hover {
  border-color: #1f7a74;
  background: #f5fbfa;
  box-shadow: 0 2px 8px rgba(31, 122, 116, 0.12);
}

/* 点击文字内容即可手改 */
.idea-box[data-field] > p,
.idea-box[data-field] .synopsis-choice-list,
.idea-box[data-field] #ideaTitles,
.idea-box[data-field] #ideaHeroes {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  padding: 6px 8px;
  margin: -6px -8px;
  transition: background 0.15s;
}

.idea-box[data-field] > p:hover {
  background: rgba(31, 122, 116, 0.08);
}

.idea-box[data-field] > p:hover::after {
  content: " ✏ 点击修改";
  color: #1f7a74;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
  white-space: nowrap;
}

/* 流派判断卡片是 dropdown 而不是普通编辑,不要 dashed border */
#ideaGenreBox {
  border: 1px solid var(--line);
}

#ideaGenreBox:hover {
  border-color: var(--line);
  background: #fffaf2;
  box-shadow: none;
}

/* ============ Agent 流水线时间线 ============ */
.agent-timeline {
  margin: 12px 16px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border: 1px solid #d6dde6;
  border-radius: 10px;
}
.agent-tl-header {
  font-size: 12px;
  color: #475569;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: baseline;
}
.agent-timeline-track {
  display: flex;
  align-items: stretch;
  gap: 4px;
  flex-wrap: wrap;
}
.agent-tl-node {
  flex: 1 1 110px;
  min-width: 100px;
  padding: 8px 6px;
  background: #fff;
  border: 1px solid #d6dde6;
  border-radius: 7px;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  transition: all 0.2s;
  position: relative;
}
.agent-tl-node.status-running {
  border-color: #2c8c7e;
  background: #e6f7f3;
  animation: agentPulse 1.2s infinite;
}
.agent-tl-node.status-done {
  border-color: #2c8c7e;
  background: #d9efe8;
}
.agent-tl-node.status-failed {
  border-color: #c0392b;
  background: #fbeae7;
}
.agent-tl-node.status-revising {
  border-color: #d49a3a;
  background: #fff4d6;
  animation: agentPulse 1.2s infinite;
}
.agent-tl-node.status-review_required {
  border-color: #d49a3a;
  background: #fff4d6;
}
.agent-tl-emoji {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
}
.agent-tl-status {
  color: #5a6573;
  font-size: 11px;
  margin-top: 3px;
}
.agent-tl-arrow {
  color: #aab;
  font-weight: 700;
  align-self: center;
  font-size: 14px;
  padding: 0 2px;
}
@keyframes agentPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ============ 小说总编审核面板 ============ */
.editor-review-panel {
  margin: 12px 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #d6dde6;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.editor-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.editor-review-title {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
}
.editor-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.editor-badge-pass {
  background: #d9efe8;
  color: #1f6f5b;
  border: 1px solid #2c8c7e;
}
.editor-badge-fail {
  background: #fbeae7;
  color: #8c2a1f;
  border: 1px solid #c0392b;
}
.editor-badge-warn {
  background: #fff4d6;
  color: #7a5618;
  border: 1px solid #d49a3a;
}
.editor-model {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 8px;
}
.editor-title {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
}
.editor-issue-sev {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  background: #475569;
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 6px;
  letter-spacing: 0.5px;
}
.editor-issue-cat {
  font-weight: 600;
  color: #475569;
  font-size: 12px;
}
.editor-issue-fix {
  margin-top: 3px;
  color: #5a6573;
  font-style: italic;
  font-size: 12px;
}
.agent-tl-title {
  font-weight: 600;
  color: #1f2937;
}
.agent-tl-hint {
  color: #94a3b8;
  font-size: 11.5px;
  margin-left: 8px;
}
.editor-notes {
  margin: 8px 0;
  padding: 8px 10px;
  background: #f8fafc;
  border-left: 3px solid #2c8c7e;
  color: #334155;
  font-size: 13px;
  white-space: pre-wrap;
  border-radius: 4px;
}
.editor-issues {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.editor-issue {
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 5px;
  font-size: 12.5px;
  line-height: 1.5;
  border: 1px solid #e2e8f0;
}
.editor-issue.editor-issue-blocker {
  background: #fbeae7;
  border-color: #c0392b;
}
.editor-issue.editor-issue-major {
  background: #fff4d6;
  border-color: #d49a3a;
}
.editor-issue.editor-issue-minor {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.editor-issue-meta {
  font-weight: 600;
  color: #475569;
  margin-right: 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.editor-issue-text {
  color: #1f2937;
}
.editor-issue-suggestion {
  display: block;
  margin-top: 3px;
  color: #5a6573;
  font-style: italic;
  font-size: 12px;
}
.editor-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.editor-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #2c8c7e;
  background: #fff;
  color: #1f6f5b;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.2s;
}
.editor-actions button:hover {
  background: #e6f7f3;
}
.editor-actions button.danger {
  border-color: #c0392b;
  color: #8c2a1f;
}
.editor-actions button.danger:hover {
  background: #fbeae7;
}
.editor-actions button.primary {
  background: #2c8c7e;
  color: #fff;
}
.editor-actions button.primary:hover {
  background: #1f6f5b;
}

/* === 登录遮罩 + 顶栏账号徽章 === */
.auth-gate {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(20, 24, 30, 0.78);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.auth-gate[hidden] { display: none; }
.auth-gate-card {
  background: #fff; border-radius: 12px;
  padding: 32px 36px; max-width: 420px; width: calc(100% - 32px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.35);
  text-align: center;
}
.auth-gate-title { font-size: 20px; font-weight: 600; color: #1f2a36; margin-bottom: 10px; }
.auth-gate-sub { font-size: 14px; color: #5a6573; line-height: 1.6; margin-bottom: 22px; }
.auth-gate-btn {
  font-size: 15px; padding: 10px 28px; border-radius: 6px;
  background: #2c8c7e; color: #fff; border: none; cursor: pointer;
  transition: background 0.2s;
}
.auth-gate-btn:hover { background: #1f6f5b; }
.auth-gate-hint { margin-top: 16px; font-size: 12px; color: #8a94a3; }

.auth-badge {
  position: fixed; top: 12px; right: 16px; z-index: 800;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.92);
  border: 1px solid #d6dde6; border-radius: 18px;
  padding: 4px 10px 4px 12px; font-size: 12px; color: #1f2a36;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.auth-badge-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-badge-logout {
  background: transparent; border: none; color: #c0392b;
  cursor: pointer; font-size: 12px; padding: 2px 6px;
}
.auth-badge-logout:hover { text-decoration: underline; }

/* === 导出提醒横幅 === */
.export-reminder {
  position: sticky; top: 0; z-index: 700;
  margin: 0; padding: 10px 16px;
  background: linear-gradient(90deg, #fff4d6, #ffe9a8);
  border-bottom: 1px solid #d49a3a;
  color: #6e4d12; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.export-reminder[hidden] { display: none; }
.export-reminder-msg { flex: 1 1 auto; }
.export-reminder-msg strong { color: #8a3b00; }
.export-reminder-actions { display: inline-flex; gap: 8px; }
.export-reminder-actions button {
  font-size: 12px; padding: 5px 12px; border-radius: 4px;
  border: 1px solid #d49a3a; background: #fff; color: #6e4d12;
  cursor: pointer; transition: all 0.2s;
}
.export-reminder-actions button:hover { background: #fff4d6; }
.export-reminder-actions button.primary {
  background: #d49a3a; color: #fff; border-color: #d49a3a;
}
.export-reminder-actions button.primary:hover { background: #b07f24; }

.auth-gate-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.auth-gate-btn-ghost {
  font-size: 15px; padding: 10px 22px; border-radius: 6px;
  background: transparent; color: #2c8c7e; border: 1px solid #2c8c7e;
  cursor: pointer; transition: all 0.2s;
}
.auth-gate-btn-ghost:hover { background: #e6f7f3; }

.auth-gate-diag {
  margin-top: 18px; padding: 14px 16px;
  background: #f6f8fa; border: 1px solid #d6dde6; border-radius: 8px;
  text-align: left; font-size: 12px;
}
.auth-gate-diag[hidden] { display: none; }
.auth-gate-diag-row { margin-bottom: 8px; line-height: 1.6; }
.auth-gate-diag-label { color: #5a6573; font-weight: 600; margin-right: 6px; }
.auth-gate-diag-value { color: #1f2a36; font-family: ui-monospace, monospace; word-break: break-all; }
.auth-gate-diag-help {
  margin: 10px 0 12px; padding: 8px 10px;
  background: #fff4d6; border-left: 3px solid #d49a3a;
  color: #6e4d12; font-size: 11px; line-height: 1.6;
}
.auth-gate-diag-paste { margin-top: 8px; }
.auth-gate-diag-paste textarea {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; border: 1px solid #d6dde6; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 11px;
  resize: vertical; margin: 6px 0;
}

/* 去 AI 味度量卡片 (chief_editor 面板内) */
.editor-metrics {
  margin: 12px 0;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e1e7ed;
  border-radius: 8px;
}
.editor-metrics-title {
  font-size: 12.5px;
  color: #5a6573;
  margin-bottom: 8px;
  font-weight: 600;
}
.editor-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 8px;
}
.editor-metric {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #d6dde6;
  background: #fff;
  text-align: center;
}
.editor-metric.ok {
  border-color: #2c8c7e;
  background: linear-gradient(180deg, #f0fbf6, #e6f7f3);
}
.editor-metric.bad {
  border-color: #c0392b;
  background: linear-gradient(180deg, #fef3f0, #fbeae7);
}
.editor-metric-label {
  font-size: 11px;
  color: #5a6573;
  margin-bottom: 4px;
}
.editor-metric-value {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}
.editor-metric.ok .editor-metric-value { color: #1f6f5b; }
.editor-metric.bad .editor-metric-value { color: #a02720; }


/* ==== 长跑接口 progress overlay ==== */
.qj-busy-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 22, 33, 0.55);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: qjBusyFade .15s ease-out;
}
.qj-busy-overlay[hidden] { display: none; }
.qj-busy-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 36px 24px;
  min-width: 340px; max-width: 520px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.28);
  text-align: center;
  font-family: inherit;
}
.qj-busy-spinner {
  width: 44px; height: 44px;
  border: 4px solid #e2e8ef;
  border-top-color: #2c8c7e;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: qjBusySpin .9s linear infinite;
}
.qj-busy-title {
  font-size: 17px; font-weight: 600; color: #1f2937;
  margin-bottom: 4px;
}
.qj-busy-sub {
  font-size: 13px; color: #5a6573;
  margin-bottom: 14px; line-height: 1.5;
}
.qj-busy-meta {
  display: flex; justify-content: center; align-items: center;
  gap: 8px;
  font-size: 12px; color: #7a8594;
  font-variant-numeric: tabular-nums;
}
.qj-busy-meta #qjBusyElapsed {
  color: #2c8c7e; font-weight: 600; font-size: 13px;
}
.qj-busy-dot { color: #c9d1da; }
.qj-busy-warn {
  margin-top: 14px;
  padding: 8px 12px;
  background: #fff4d6;
  border: 1px solid #d49a3a;
  border-radius: 6px;
  color: #8a5a00;
  font-size: 12px;
  line-height: 1.5;
}
@keyframes qjBusySpin {
  to { transform: rotate(360deg); }
}
@keyframes qjBusyFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ==== 总编打回 → 重写按钮(主按钮加粗) ==== */
.editor-rewrite-btn {
  background: linear-gradient(180deg, #2c8c7e, #1f6e62);
  color: #fff;
  font-weight: 600;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(44,140,126,0.32);
  transition: transform .12s ease, box-shadow .12s ease;
}
.editor-rewrite-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44,140,126,0.42);
}
.editor-rewrite-btn:active {
  transform: translateY(0);
}

/* 总编审分历程 trend bar */
.editor-trend {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
  padding: 8px 10px;
  background: #f5f7fa;
  border: 1px solid #e3e7ec;
  border-radius: 6px;
  font-size: 12px;
}
.editor-trend-label { color: #5a6573; font-weight: 600; }
.editor-trend-dot {
  display: inline-flex; align-items: baseline; gap: 3px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #d6dde6;
  font-variant-numeric: tabular-nums;
}
.editor-trend-dot b { font-weight: 600; color: #2c3340; }
.editor-trend-dot i { font-style: normal; font-size: 11px; }
.editor-trend-dot.trend-up    { background: #e6f7f3; border-color: #2c8c7e; }
.editor-trend-dot.trend-up i  { color: #2c8c7e; }
.editor-trend-dot.trend-down  { background: #fbeae7; border-color: #c0392b; }
.editor-trend-dot.trend-down i{ color: #c0392b; }
.editor-trend-dot.trend-flat  { background: #fff4d6; border-color: #d49a3a; }
.editor-trend-dot.trend-flat i{ color: #d49a3a; }
.editor-trend-sep { color: #aab; }
.editor-trend-summary {
  margin-left: auto;
  color: #5a6573;
  font-style: italic;
}

/* —— 代码自修轨迹 —— */
.editor-autofix {
  margin: 10px 0;
  padding: 10px 12px;
  background: linear-gradient(180deg, #fffaf3, #fff4dc);
  border: 1px solid #e6d39a;
  border-left: 3px solid #d49a3a;
  border-radius: 8px;
}
.editor-autofix-title {
  font-size: 12px;
  color: #8a6418;
  font-weight: 600;
  margin-bottom: 6px;
}
.autofix-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.autofix-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: #3a3833;
  line-height: 1.5;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
}
.autofix-icon { font-size: 14px; }
.autofix-ts { color: #9a8a6a; font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.autofix-label { color: #6b4f12; font-weight: 600; min-width: 130px; }
.autofix-body { color: #4a4640; flex: 1; }
.autofix-detail { color: #9a7a3a; font-size: 11px; }
