:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #667085;
  --line: #d9dee7;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --mist: #edf4f2;
  --sage: #5f7f71;
  --brick: #a9523f;
  --plum: #66445d;
  --gold: #d39a3d;
  --shadow: 0 18px 50px rgba(38, 47, 61, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 12%, rgba(211, 154, 61, 0.14), transparent 28%),
    linear-gradient(135deg, #fbfaf7 0%, #eef4f1 48%, #f7f0eb 100%);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(360px, 1fr) minmax(360px, 520px);
  min-height: 100vh;
}

.version-rail,
.workspace,
.preview-pane {
  min-width: 0;
}

.version-rail {
  border-right: 1px solid var(--line);
  padding: 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px);
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(31, 35, 40, 0.16);
  background: linear-gradient(145deg, var(--plum), var(--brick));
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(102, 68, 93, 0.22);
}

h1,
h2,
p {
  margin: 0;
}

.brand-block h1 {
  font-size: 19px;
  line-height: 1.2;
}

.brand-block p,
.preview-meta,
.empty-copy {
  color: var(--muted);
}

.brand-block p {
  margin-top: 4px;
  font-size: 13px;
}

.primary-action,
.accent-action,
.secondary-action,
.ghost-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 750;
}

.primary-action,
.accent-action {
  background: var(--ink);
  color: white;
}

.primary-action {
  width: 100%;
}

.secondary-action {
  background: var(--sage);
  color: white;
}

.ghost-action {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.rail-section {
  margin-top: 28px;
}

.rail-title,
.section-heading {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.version-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.version-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
}

.version-item.active {
  border-color: var(--brick);
  box-shadow: 0 0 0 3px rgba(169, 82, 63, 0.12);
}

.version-item strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-item span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 28px;
}

.composer,
.revision-panel,
.ai-panel,
.preview-pane {
  background: rgba(255, 255, 255, 0.84);
}

.composer,
.revision-panel,
.ai-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

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

.section-heading strong {
  color: var(--brick);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: #3d4551;
  font-size: 13px;
  font-weight: 760;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  outline: none;
  padding: 12px 13px;
}

.field textarea {
  min-height: 104px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(95, 127, 113, 0.16);
}

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

.mode-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.mode-card {
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  padding: 14px;
  text-align: left;
}

.mode-card.active {
  border-color: var(--plum);
  background: linear-gradient(180deg, rgba(102, 68, 93, 0.1), rgba(255, 254, 250, 0.96));
  box-shadow: 0 0 0 3px rgba(102, 68, 93, 0.12);
}

.mode-card span,
.mode-card strong,
.mode-card small {
  display: block;
}

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

.mode-card strong {
  margin-top: 10px;
  font-size: 18px;
}

.mode-card small {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.action-row,
.revision-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.status-line {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.status-line[data-type="success"] {
  color: var(--sage);
  font-weight: 750;
}

.status-line[data-type="error"] {
  color: var(--brick);
  font-weight: 750;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3d4551;
  font-size: 14px;
  font-weight: 650;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--brick);
}

.preview-pane {
  display: grid;
  grid-template-rows: auto auto 1fr;
  border-left: 1px solid var(--line);
  padding: 28px;
  backdrop-filter: blur(16px);
}

.cover-scene {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 18px;
  align-items: center;
  min-height: 150px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
}

.book-stack {
  position: relative;
  height: 120px;
}

.book-stack span {
  position: absolute;
  display: block;
  width: 74px;
  height: 104px;
  border: 1px solid rgba(31, 35, 40, 0.18);
  border-radius: 6px 3px 3px 6px;
  box-shadow: 0 16px 30px rgba(31, 35, 40, 0.2);
}

.book-stack span:nth-child(1) {
  left: 2px;
  top: 12px;
  background: linear-gradient(135deg, var(--plum), #c57b65);
  transform: rotate(-8deg);
}

.book-stack span:nth-child(2) {
  left: 26px;
  top: 2px;
  background: linear-gradient(135deg, #385e63, var(--gold));
  transform: rotate(5deg);
}

.book-stack span:nth-child(3) {
  left: 14px;
  top: 20px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 12px, transparent 12px),
    linear-gradient(150deg, var(--brick), #263548);
}

.preview-kicker {
  color: var(--brick);
  font-size: 12px;
  font-weight: 850;
}

.cover-scene h2 {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1.15;
}

.cover-scene p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.output-toolbar {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.toolbar-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: #3d4551;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 760;
}

.toolbar-button.active {
  border-color: var(--sage);
  background: var(--mist);
}

.output-document {
  overflow: auto;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 22px;
  line-height: 1.75;
}

.output-document h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.output-document h4 {
  margin: 18px 0 8px;
}

.output-document ul,
.output-document ol {
  padding-left: 22px;
}

.output-document li + li {
  margin-top: 8px;
}

.ai-result {
  min-height: 150px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 16px;
  line-height: 1.75;
}

.ai-result p + p {
  margin-top: 12px;
}

.manuscript-chapter {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 14px;
}

.manuscript-chapter:first-of-type {
  border-top: 0;
  margin-top: 12px;
  padding-top: 0;
}

.manuscript-chapter h4 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.manuscript-chapter p + p {
  margin-top: 12px;
}

.empty-copy {
  line-height: 1.7;
}

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

  .preview-pane {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .version-rail,
  .workspace,
  .preview-pane {
    padding: 18px;
  }

  .form-grid,
  .mode-panel,
  .cover-scene {
    grid-template-columns: 1fr;
  }

  .mode-card {
    min-height: 116px;
  }

  .action-row,
  .revision-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .accent-action,
  .secondary-action,
  .ghost-action {
    width: 100%;
  }
}
