:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-3: #f1f5f9;
  --ink: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-dark: #cbd5e1;
  --accent: #334155;
  --accent-strong: #0f172a;
  --accent-soft: #e2e8f0;
  --tag-blue: #dbeafe;
  --tag-blue-ink: #1d4ed8;
  --tag-violet: #ede9fe;
  --tag-violet-ink: #6d28d9;
  --tag-warn: #fef3c7;
  --tag-warn-ink: #92400e;
  --warn: #d97706;
  --good: #16a34a;
  --good-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.is-hidden {
  display: none !important;
}

.topbar {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 10px 18px 6px;
  background: transparent;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 36px;
}

.brand-logo {
  display: block;
  width: auto;
  height: 28px;
  max-width: 132px;
  object-fit: contain;
}

.mark {
  display: none;
}

.brand strong,
.brand span {
  display: none;
}

.process {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.process-step,
.ghost,
.primary,
.icon-button,
.segmented button,
.source-item,
.quick-actions button {
  border: 1px solid var(--line-dark);
  background: var(--panel);
  color: var(--ink);
  min-height: 36px;
  border-radius: 10px;
}

.process-step {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
}

.process-step.is-active {
  border-color: transparent;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  font-weight: 700;
}

.top-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ghost,
.primary {
  min-height: 32px;
  padding: 0 10px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.ghost {
  background: rgba(255, 255, 255, 0.82);
}

.ghost.is-selected {
  border-color: #c4b5fd;
  color: var(--tag-violet-ink);
  background: var(--tag-violet);
  font-weight: 700;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.primary:disabled,
.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.workspace {
  display: grid;
  grid-template-columns: 390px minmax(500px, 1fr) 320px;
  grid-template-rows: minmax(0, 1fr) 270px;
  column-gap: 10px;
  row-gap: 0;
  height: calc(100vh - 64px);
  min-height: 720px;
  padding: 0 14px 14px;
}

.setup-screen {
  min-height: calc(100vh - 64px);
  padding: 18px 20px 32px;
}

.intake-panel {
  width: min(960px, calc(100vw - 40px));
  margin: 0 auto;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.intake-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.intake-head h1 {
  font-size: 28px;
}

.intake-panel .panel-section {
  padding: 18px 22px;
}

.intake-panel .segmented {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.intake-footer {
  display: grid;
  gap: 14px;
  background: var(--panel-2);
}

.generation-progress {
  display: grid;
  gap: 8px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.progress-meta strong {
  color: var(--ink);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 280ms ease;
}

.project-panel,
.outline-panel,
.assistant-panel,
.editor-panel {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.project-panel,
.outline-panel,
.assistant-panel {
  scrollbar-color: #cbd5e1 transparent;
}

.assistant-panel {
  grid-column: 3;
  grid-row: 1 / 3;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  overflow: hidden;
  border-left: 2px solid #cbd5e1;
  border-radius: 0 14px 14px 0;
}

.assistant-panel .panel-section {
  min-height: 0;
  overflow: hidden;
}

.assistant-panel .panel-section:last-child {
  border-bottom: 0;
}

.editor-panel {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  min-width: 0;
  overflow: hidden;
  border-left: 0;
  border-right: 0;
  border-bottom: 2px solid #cbd5e1;
}

.outline-panel {
  grid-column: 1;
  grid-row: 1;
  border-right: 2px solid #cbd5e1;
  border-bottom: 2px solid #cbd5e1;
  border-radius: 14px 0 0 0;
}

.editor-main {
  min-width: 0;
  overflow: hidden;
}

.editor-main {
  display: grid;
  grid-template-rows: auto 1fr;
}

.editor-operations {
  display: contents;
}

.skeleton-control-panel {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.page-control-panel {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.skeleton-control-panel,
.page-control-panel {
  min-width: 0;
  overflow: auto;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.skeleton-control-panel {
  border-top: 0;
  border-right: 2px solid #cbd5e1;
  border-radius: 0 0 0 14px;
}

.page-control-panel {
  border-top: 0;
  border-left: 0;
  border-right: 0;
}

.skeleton-control-panel .skeleton-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.page-command-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(310px, 0.95fr) minmax(380px, 1.25fr);
  gap: 10px;
  min-height: 0;
}

.page-command-column,
.page-command-custom {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  min-width: 0;
}

.page-command-custom {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.page-command-column .field,
.page-command-custom {
  margin-bottom: 0;
}

.page-command-column .field {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.page-command-column:first-child {
  grid-template-rows: auto minmax(0, 1fr);
}

.page-command-column:first-child .field {
  align-self: end;
  grid-template-rows: auto auto;
}

.page-command-custom textarea,
.page-command-column textarea {
  height: 100%;
  resize: none;
}

.panel-section {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sticky-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 254, 0.95);
  backdrop-filter: blur(10px);
}

h1,
h2,
p {
  margin: 0;
}

p {
  font-size: 12px;
}

h1 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
}

h2 {
  font-size: 14px;
  font-weight: 700;
}

.section-heading span,
.eyebrow,
small {
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

input:focus,
textarea:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.18);
}

input {
  height: 34px;
  padding: 0 10px;
}

textarea {
  min-height: 74px;
  padding: 7px 9px;
  resize: vertical;
  line-height: 1.6;
  font-size: 12px;
}

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

.segmented button {
  padding: 0 10px;
  background: var(--panel-2);
}

.segmented button.is-selected {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.icon-button {
  display: grid;
  width: 30px;
  min-height: 30px;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  background: var(--panel-2);
}

.upload-button {
  position: relative;
  overflow: hidden;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.source-list,
.agent-stack,
.quick-actions,
.check-list {
  display: grid;
  gap: 7px;
}

.source-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  background: var(--panel-2);
  border-radius: 12px;
}

.source-item.is-ready {
  border-color: #93c5fd;
  background: var(--tag-blue);
}

.source-empty {
  padding: 10px;
  border: 1px dashed var(--line-dark);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  background: var(--panel-2);
}

.storyline {
  margin: 10px 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  line-height: 1.6;
}

.storyline strong {
  display: block;
  margin-bottom: 6px;
}

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

.chapter {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.chapter-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.chapter-title {
  font-weight: 700;
}

.chapter-outline {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.page-list {
  display: grid;
}

.page-link {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 6px;
  min-height: 34px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.page-link:last-child {
  border-bottom: 0;
}

.page-link.is-active {
  background: var(--accent-soft);
}

.page-link.is-editing {
  grid-template-columns: 28px 1fr 32px;
}

.page-title-select,
.page-title-edit,
.page-title-confirm {
  min-height: 24px;
  border: 0;
  background: transparent;
  text-align: left;
}

.page-title-select {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0;
}

.page-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.page-status {
  min-width: 0;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  background: #fff;
}

.page-status.is-done {
  border-color: #86efac;
  color: #166534;
  background: var(--good-soft);
}

.page-status.is-locked {
  border-color: #c4b5fd;
  color: var(--tag-violet-ink);
  background: var(--tag-violet);
}

.page-title-edit,
.page-title-confirm {
  display: grid;
  place-items: center;
  width: 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  background: #fff;
}

.page-title-confirm {
  color: var(--accent-strong);
  font-weight: 700;
}

.page-title-input {
  width: 100%;
  height: 28px;
  min-width: 0;
  padding: 0 8px;
  border-radius: 8px;
}

.page-number {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.density {
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  background: var(--panel-2);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 254, 0.94);
}

.page-canvas {
  overflow: auto;
  padding: 0;
  background: linear-gradient(180deg, #f8fafc 0%, #fff 24%);
}

.empty-state {
  max-width: 920px;
  min-height: 420px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.proposal-page {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  padding: 0;
  background: #fff;
}

.editor-operations .field {
  gap: 3px;
  margin-bottom: 6px;
}

.editor-operations textarea {
  min-height: 44px;
  padding: 5px 7px;
  line-height: 1.45;
}

.editor-operations .command-field textarea {
  min-height: 48px;
}

.page-context {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.page-context div {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.page-context strong {
  color: var(--ink);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.content-block {
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
  line-height: 1.55;
}

.content-block.is-wide {
  grid-column: 1 / -1;
}

.content-block h4 {
  margin: 0 0 7px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.structured-lines {
  display: grid;
  gap: 8px;
}

.structured-lines div {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.structured-lines strong {
  color: var(--tag-blue-ink);
  font-size: 12px;
}

.structured-lines span {
  color: var(--ink);
}

.block-note {
  margin-top: 12px;
  color: var(--muted);
}

.layout-cards,
.table-cards {
  display: grid;
  gap: 8px;
}

.layout-card,
.table-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.layout-card {
  display: block;
}

.layout-card.is-numbered {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
}

.layout-card strong {
  color: var(--tag-blue-ink);
  font-size: 12px;
}

.table-card {
  display: grid;
  gap: 6px;
}

.table-card div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
}

.table-card strong {
  color: var(--muted);
  font-size: 11px;
}

.table-card span {
  color: var(--ink);
}

.placeholder-line {
  height: 10px;
  margin: 10px 0;
  border-radius: 999px;
  background: #e2e8f0;
}

.placeholder-line.short {
  width: 64%;
}

.placeholder-line.mid {
  width: 82%;
}

.agent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.agent-row > span:first-child {
  font-weight: 700;
}

.agent-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.agent-detail {
  display: grid;
  grid-column: 1 / -1;
  gap: 3px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.agent-detail span {
  position: relative;
  padding-left: 12px;
}

.agent-detail span::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.agent-row.is-running .agent-detail,
.agent-row.is-error .agent-detail {
  color: var(--ink);
}

.agent-row.is-running {
  border-color: #fcd34d;
  background: var(--tag-warn);
}

.agent-row.is-done {
  border-color: #86efac;
  background: var(--good-soft);
}

.agent-row.is-error {
  border-color: #fecaca;
  background: var(--bad-soft);
}

.history-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.history-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-color: #cbd5e1 transparent;
}

.history-empty {
  padding: 9px;
  border: 1px dashed var(--line-dark);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  background: var(--panel-2);
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.history-item time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.history-item p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.history-scope {
  color: var(--tag-blue-ink);
  font-size: 11px;
}

.quick-actions {
  grid-template-columns: 1fr 1fr;
}

.quick-actions button {
  min-height: 34px;
  padding: 0 9px;
  background: var(--panel-2);
  text-align: left;
  border-radius: 12px;
}

.editor-operations .quick-actions {
  gap: 5px;
  margin-bottom: 6px;
}

.editor-operations .quick-actions button {
  min-height: 26px;
  padding: 0 7px;
  border-radius: 8px;
  text-align: center;
  font-size: 11px;
}

.skeleton-control-panel .skeleton-actions,
.page-command-layout .quick-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.editor-operations .section-heading {
  margin-bottom: 6px;
}

.density-control,
.structure-actions {
  display: grid;
  gap: 6px;
}

.density-control {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.structure-actions {
  grid-template-columns: 1fr 1fr;
}

.density-control button,
.structure-actions button {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--panel-2);
}

.editor-operations .density-control,
.editor-operations .structure-actions {
  gap: 5px;
}

.editor-operations .density-control button,
.editor-operations .structure-actions button {
  min-height: 26px;
  padding: 0 6px;
  font-size: 11px;
}

.editor-operations .primary.full {
  min-height: 30px;
}

.density-control button.is-selected,
.structure-actions button.is-selected {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.structure-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.command-field {
  margin-top: 12px;
}

.full {
  width: 100%;
}

.check-list div {
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.check-list span {
  display: block;
  width: 10px;
  height: 10px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  background: #fff;
}

.check-list div.is-pass {
  color: var(--ink);
}

.check-list div.is-pass span {
  border-color: var(--good);
  background: var(--good);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
}

.toast.is-error {
  border-color: #fecaca;
  background: var(--bad-soft);
}

@media (max-width: 1280px) {
  body {
    min-width: 1040px;
  }

  .workspace {
    grid-template-columns: 340px minmax(360px, 1fr) 280px;
  }
}
