:root {
  color-scheme: light;
  --ink: #1f2423;
  --muted: #66706b;
  --line: #d9dfd8;
  --panel: #f4f6f1;
  --paper: #fffdf7;
  --paper-fiber: rgba(79, 74, 55, 0.055);
  --paper-warm: #fbf7eb;
  --ink-line: #bfc9bf;
  --ink-soft: #edf1ea;
  --ink-blue: #3a667b;
  --seal-red: #a94332;
  --surface: #ffffff;
  --accent: #2f6f63;
  --accent-dark: #214f47;
  --info: #315f7d;
  --warning: #8d6b1f;
  --danger: #9b3f2f;
  --warm: #b85b38;
  --blue: var(--info);
  --gold: var(--warning);
  --shadow: 0 10px 28px rgba(31, 35, 40, 0.08);
  --rail-width: 292px;
  --run-rail-width: 360px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef1ed;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  border-radius: 6px;
}

button:hover {
  border-color: #9ca8a3;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 111, 99, 0.28);
  outline-offset: 2px;
}

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

button:disabled,
input:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.58;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(236, 239, 233, 0.94);
}

.login-gate[hidden] {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  width: 48px;
  height: 48px;
}

.login-copy,
.login-message {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.login-form label {
  color: #42474c;
  font-size: 13px;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
  align-items: end;
}

.login-form button {
  min-height: 38px;
  padding: 0 12px;
}

.auth-strip {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid #dfe5e0;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.auth-strip button {
  min-height: 28px;
  padding: 0 8px;
}

.subscription-badge {
  flex: 0 0 auto;
  min-width: 46px;
  padding: 4px 9px;
  border: 1px solid rgba(58, 102, 123, 0.28);
  border-radius: 999px;
  background:
    radial-gradient(circle at 18% 30%, rgba(58, 102, 123, 0.16), transparent 42%),
    #f4f8f6;
  color: var(--ink-blue);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
}

.subscription-badge.active {
  border-color: rgba(169, 67, 50, 0.5);
  background:
    radial-gradient(circle at 20% 28%, rgba(169, 67, 50, 0.22), transparent 42%),
    #fff8ef;
  color: var(--seal-red);
}

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

.subscription-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 72% 18%, rgba(31, 36, 35, 0.18), transparent 18%),
    rgba(30, 37, 34, 0.42);
  backdrop-filter: blur(3px);
}

.subscription-card {
  width: min(620px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(191, 201, 191, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 36, 35, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(79, 74, 55, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 92% 8%, rgba(169, 67, 50, 0.1), transparent 26%),
    var(--paper);
  background-size: 30px 30px, 24px 24px, auto, auto;
  box-shadow: 0 24px 70px rgba(26, 34, 31, 0.24);
}

.subscription-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(191, 201, 191, 0.72);
}

.subscription-card-header h3 {
  margin: 4px 0 0;
  color: #26302d;
  font-size: 22px;
}

.subscription-status {
  margin: 16px 0;
  padding: 13px 14px;
  display: grid;
  gap: 5px;
  border: 1px solid rgba(58, 102, 123, 0.24);
  border-left: 4px solid var(--ink-blue);
  border-radius: 6px;
  background: rgba(232, 240, 242, 0.7);
  color: #34433f;
  line-height: 1.5;
}

.subscription-status strong {
  color: var(--ink);
}

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

.subscription-plan {
  min-height: 112px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-color: rgba(191, 201, 191, 0.92);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(244, 246, 241, 0.86)),
    #fff;
  text-align: left;
}

.subscription-plan.primary {
  border-color: rgba(169, 67, 50, 0.42);
  background:
    radial-gradient(circle at 88% 14%, rgba(169, 67, 50, 0.16), transparent 30%),
    #fffaf1;
}

.subscription-plan strong {
  color: #26302d;
  font-size: 15px;
}

.subscription-plan span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.subscription-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-shell,
.production-console {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
  background: #edf0eb;
}

.ink-wash-shell {
  background:
    linear-gradient(90deg, rgba(31, 36, 35, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, var(--paper-fiber) 1px, transparent 1px),
    radial-gradient(circle at 92% 8%, rgba(169, 67, 50, 0.08), transparent 28%),
    linear-gradient(135deg, #f7f4ea 0%, #eef3ee 48%, #f9f5ea 100%);
  background-size: 34px 34px, 26px 26px, auto, auto;
}

.ink-wash-shell .sidebar,
.ink-wash-shell .topbar,
.ink-wash-shell .run-rail-section,
.ink-wash-shell .editor-pane,
.ink-wash-shell .command-card,
.ink-wash-shell .request-card,
.ink-wash-shell .range-console,
.ink-wash-shell .workflow-rail,
.ink-wash-shell .quick-stat,
.ink-wash-shell .next-step-panel {
  border-color: var(--ink-line);
  background-color: rgba(255, 253, 247, 0.9);
  box-shadow: 0 10px 24px rgba(33, 47, 42, 0.055);
}

.sidebar,
.project-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: #fbfaf4;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 2px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  height: 38px;
  text-align: left;
  padding: 0 12px;
  background: transparent;
}

.nav-item.active {
  background: #e7eee9;
  border-color: #b6c9c1;
  color: var(--accent-dark);
  font-weight: 600;
}

.compact-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 12px;
}

.sidebar-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0;
}

.sidebar-section-heading::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 3px;
  background: var(--blue);
}

.panel-row,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #42474c;
  font-size: 14px;
}

.panel-title {
  color: #42474c;
  font-size: 14px;
  font-weight: 600;
}

.book-library,
.progress-summary {
  display: grid;
  gap: 8px;
}

.book-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid #e2e4df;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.book-item.active {
  border-color: #b6c9c1;
  background: #eef5f1;
}

.book-title {
  font-weight: 600;
  color: var(--accent-dark);
}

.book-title-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  text-align: left;
  font-weight: 600;
}

.book-path {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-actions {
  display: grid;
  gap: 6px;
}

.book-artifact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 5px;
}

.book-artifact-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

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

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

.progress-stat {
  border: 1px solid #e2e4df;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
}

.progress-stat strong {
  display: block;
  color: var(--accent-dark);
  font-size: 16px;
}

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

.panel-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.side-artifacts {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.chapter-group {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #e2e4df;
  border-radius: 6px;
  background: #fff;
}

.chapter-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.chapter-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chapter-badge {
  border-radius: 4px;
  background: #edf0ec;
  color: #55605b;
  padding: 2px 5px;
  font-size: 11px;
}

.chapter-badge.done {
  background: #e0eee8;
  color: var(--accent-dark);
}

.chapter-files {
  display: grid;
  gap: 4px;
}

.side-artifact {
  min-height: 32px;
  padding: 7px 9px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.wide-button {
  min-height: 34px;
  width: 100%;
}

.panel-row input {
  width: 74px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.workspace,
.center-workspace {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar,
.console-topline {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: #f7f8f5;
  border-bottom: 1px solid var(--line);
}

.console-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) var(--run-rail-width);
  gap: 16px;
  padding: 16px 20px 22px;
}

.center-workbench,
.run-rail {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 14px;
}

.topbar h2 {
  font-size: 25px;
  margin-top: 4px;
}

.editor-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.actions button,
.command-zone button,
#clearLogBtn {
  min-height: 36px;
  padding: 0 12px;
}

.workspace-dashboard {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
}

.next-step-panel {
  margin: 0;
  min-height: 112px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #b9cec5;
  border-radius: 8px;
  background: #edf6f1;
  box-shadow: none;
}

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

.quick-stat {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid #d9dfd9;
  border-radius: 8px;
  background: #fff;
}

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

.quick-stat strong {
  color: var(--accent-dark);
  font-size: 18px;
}

.workflow-rail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #d8dfda;
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.workflow-rail-title h3 {
  margin-top: 3px;
  font-size: 16px;
}

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

.workflow-step {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #dce2dd;
  border-radius: 6px;
  background: #f7f8f5;
  color: #59625e;
  font-size: 13px;
  font-weight: 600;
}

.workflow-step.done {
  border-color: #b7cbbf;
  background: #e8f1ec;
  color: var(--accent-dark);
}

.workflow-step.active {
  border-color: var(--blue);
  background: #edf4f8;
  color: var(--blue);
}

.main-work-area {
  display: grid;
  gap: 12px;
}

.next-step-panel h3 {
  margin-top: 4px;
  font-size: 19px;
}

.next-step-panel p:last-child {
  margin-top: 5px;
  color: #46524d;
  font-size: 14px;
  line-height: 1.45;
}

.next-step-panel button {
  min-width: 118px;
}

.command-zone {
  display: grid;
  gap: 12px;
  padding: 12px 24px 0;
}

.toolbelt {
  padding: 0;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1fr);
  align-items: stretch;
}

.toolbelt .section-heading {
  grid-column: 1 / -1;
}

.toolbelt .range-console {
  grid-column: 1 / -1;
}

.toolbelt .section-heading,
.toolbelt .request-card,
.toolbelt .range-console {
  min-height: 100%;
}

.section-heading h3 {
  margin-top: 3px;
  font-size: 17px;
}

.request-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.request-card label {
  color: #42474c;
  font-size: 13px;
  font-weight: 600;
}

.request-card input {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

.range-console {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  background: #fbfcf9;
}

.range-console h3 {
  margin-top: 3px;
  font-size: 17px;
}

.range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 150px)) auto;
  gap: 10px;
  align-items: end;
}

.range-grid label {
  display: grid;
  gap: 6px;
  color: #42474c;
  font-size: 13px;
  font-weight: 600;
}

.range-grid input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.range-preview {
  padding: 10px 12px;
  border: 1px solid #e1e6e2;
  border-radius: 6px;
  background: #ffffff;
  color: #46524d;
  font-size: 13px;
  line-height: 1.5;
}

.range-insight {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #d9e2df;
  border-radius: 6px;
  background: #eef5f1;
  color: #3f4d49;
  font-size: 13px;
  line-height: 1.45;
}

.range-insight strong {
  color: var(--accent-dark);
}

.toolbelt .command-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.command-card {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
}

.command-card.featured {
  border-color: #aac2b8;
  background: #f4faf7;
}

.command-card h3 {
  margin-top: 6px;
  font-size: 16px;
}

.command-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.command-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  border-radius: 5px;
  background: #edf0ec;
  color: #4d5652;
  font-size: 12px;
  font-weight: 700;
}

.command-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.command-zone button.primary,
.next-step-panel button.primary,
.confirm-card button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.primary-action-band {
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(191, 201, 191, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(169, 67, 50, 0.055), transparent 32%),
    linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(246, 242, 231, 0.88));
}

.primary-action-band .next-step-panel {
  min-height: 96px;
  padding: 14px 16px;
  border-color: rgba(169, 67, 50, 0.22);
  border-left: 4px solid var(--seal-red);
  background: rgba(255, 253, 247, 0.82);
}

.primary-action-band .next-step-panel h3 {
  font-size: 18px;
}

.primary-action-band .next-step-panel .primary {
  min-width: 104px;
  border-color: var(--seal-red);
  background: linear-gradient(180deg, #b84e3d, var(--seal-red));
  box-shadow: inset 0 -1px 0 rgba(67, 24, 18, 0.24);
}

.primary-action-band .quick-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.primary-action-band .quick-stat {
  min-height: 46px;
  padding: 8px 9px;
  border-color: rgba(191, 201, 191, 0.8);
  background: rgba(255, 255, 255, 0.58);
}

.ink-flow-strip {
  min-height: 44px;
  padding: 8px 10px;
  grid-template-columns: 128px minmax(0, 1fr);
  border-color: rgba(191, 201, 191, 0.7);
  background:
    linear-gradient(90deg, rgba(31, 36, 35, 0.035), transparent),
    rgba(255, 253, 247, 0.58);
}

.ink-flow-strip .workflow-rail-title h3 {
  font-size: 14px;
}

.ink-flow-strip .workflow-step {
  min-height: 28px;
  border-radius: 5px;
  background: rgba(247, 248, 245, 0.72);
  font-size: 12px;
}

.paper-editor-surface {
  order: 1;
  min-height: 640px;
  padding: 10px;
  border: 1px solid rgba(191, 201, 191, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(31, 36, 35, 0.028) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 253, 247, 0.9), rgba(249, 245, 234, 0.94));
  background-size: 32px 32px, auto;
}

.paper-editor-surface .editor-pane {
  min-height: 620px;
  border-color: rgba(137, 148, 139, 0.72);
  background:
    linear-gradient(90deg, rgba(79, 74, 55, 0.032) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px, auto;
  box-shadow:
    inset 0 1px 20px rgba(57, 68, 63, 0.045),
    0 12px 26px rgba(33, 47, 42, 0.06);
}

.paper-editor-surface textarea {
  min-height: 640px;
  padding: 26px 28px;
  background: transparent;
}

.writing-parameter-band {
  order: 2;
  display: grid;
  grid-template-columns: 178px minmax(220px, 0.7fr) minmax(360px, 1.3fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(191, 201, 191, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.82), rgba(244, 240, 229, 0.76)),
    var(--paper-warm);
}

.writing-parameter-band .section-heading {
  grid-column: auto;
  align-self: center;
  padding: 0 8px 0 0;
  border-right: 1px solid rgba(191, 201, 191, 0.74);
}

.writing-parameter-band .section-heading h3 {
  font-size: 15px;
  line-height: 1.35;
}

.writing-parameter-band .request-card,
.writing-parameter-band .range-console {
  min-height: 0;
  padding: 10px;
  border-color: rgba(191, 201, 191, 0.78);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
}

.writing-parameter-band .range-console {
  grid-column: auto;
  gap: 8px;
}

.writing-parameter-band .range-console h3 {
  font-size: 15px;
}

.writing-parameter-band .range-grid {
  grid-template-columns: repeat(2, minmax(76px, 110px)) minmax(96px, auto);
  gap: 8px;
}

.writing-parameter-band .range-preview,
.writing-parameter-band .range-insight {
  padding: 8px 10px;
  font-size: 12px;
}

.command-shelf {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.toolbelt .command-shelf {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.command-shelf .command-card {
  min-height: 0;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border-color: rgba(191, 201, 191, 0.8);
  background: rgba(255, 253, 247, 0.72);
}

.command-shelf .command-card.featured {
  border-color: rgba(169, 67, 50, 0.26);
  background: rgba(255, 248, 239, 0.82);
}

.command-shelf .command-card h3 {
  display: inline;
  margin-left: 7px;
  font-size: 14px;
}

.command-shelf .command-card p {
  display: none;
}

.command-shelf .command-actions {
  justify-content: flex-start;
  gap: 6px;
}

.command-shelf .command-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.command-group-label {
  width: 24px;
  height: 20px;
  border-radius: 4px;
  background: rgba(58, 102, 123, 0.1);
  color: var(--ink-blue);
}

.command-card.featured .command-group-label {
  background: rgba(169, 67, 50, 0.12);
  color: var(--seal-red);
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 33, 36, 0.36);
}

.confirm-dialog[hidden] {
  display: none;
}

.confirm-card {
  width: min(560px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #c8d3cf;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.confirm-card h3 {
  font-size: 20px;
}

.confirm-body {
  display: grid;
  gap: 8px;
  color: #42474c;
  font-size: 14px;
}

.confirm-body div,
.confirm-warning {
  padding: 9px 10px;
  border-radius: 6px;
  background: #f3f5f0;
}

.confirm-warning {
  color: #6b4f17;
  background: #fff6dc;
  line-height: 1.5;
}

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

.run-status {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #c7d8d0;
  border-radius: 8px;
  padding: 12px 14px;
  background: #eaf3ef;
  color: var(--accent-dark);
  font-size: 14px;
}

.run-status-copy {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 7px;
}

.run-status[hidden] {
  display: none;
}

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

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

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #b8cbc3;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.content-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) var(--run-rail-width);
  gap: 16px;
  padding: 16px 20px 22px;
}

.editor-pane,
.output-pane {
  min-height: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor-pane {
  min-height: 560px;
  overflow: hidden;
}

.editor-stack {
  min-height: 560px;
  display: grid;
}

.run-rail {
  position: sticky;
  top: 94px;
  max-height: calc(100vh - 116px);
  overflow: auto;
  padding-right: 2px;
}

.run-rail-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 620px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 22px;
  background: transparent;
  color: #24272a;
  line-height: 1.7;
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  font-size: 15px;
}

.workspace-meta {
  display: grid;
  gap: 8px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid #e2e4df;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.meta-row span:first-child {
  color: var(--muted);
}

.meta-row strong {
  color: var(--ink);
}

.output-pane {
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  gap: 12px;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.output-header h3,
.file-list h3 {
  font-size: 15px;
}

.log-section pre,
.run-rail #logOutput {
  max-height: 280px;
  min-height: 180px;
}

pre {
  margin: 0;
  min-height: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f5f5f0;
  font-size: 13px;
  line-height: 1.5;
}

.file-list {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.chapter-workbench {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d7dfda;
  border-radius: 8px;
  background: #fbfcf9;
}

.chapter-workbench h3 {
  margin-top: 3px;
  font-size: 16px;
}

.chapter-stage-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.chapter-stage {
  min-width: 0;
  min-height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink-line);
  border-radius: 6px;
  background: var(--ink-soft);
  color: #5d6862;
  font-size: 11px;
  font-weight: 700;
}

.chapter-stage.done {
  border-color: rgba(58, 102, 123, 0.44);
  background: #e8f0f2;
  color: var(--ink-blue);
}

.chapter-stage.done:last-child {
  border-color: rgba(169, 67, 50, 0.42);
  color: var(--seal-red);
}

.chapter-workbench-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chapter-status-chip {
  padding: 4px 7px;
  border-radius: 5px;
  background: #edf0ec;
  color: #59625e;
  font-size: 12px;
}

.chapter-status-chip.done {
  background: #e0eee8;
  color: var(--accent-dark);
  font-weight: 600;
}

.chapter-workbench-files,
.chapter-workbench-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chapter-workbench-files button,
.chapter-workbench-actions button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

.chapter-workbench-actions button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ink-artifact-workbench {
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(251, 247, 235, 0.92)),
    var(--paper-warm);
}

.ink-artifact-workbench h3 {
  padding-left: 10px;
  border-left: 3px solid var(--seal-red);
  color: #2f3835;
  font-size: 16px;
}

.artifact-workbench-groups {
  display: grid;
  gap: 8px;
}

.artifact-group {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid rgba(191, 201, 191, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.artifact-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #39443f;
  font-size: 12px;
  font-weight: 700;
}

.artifact-group-title strong {
  min-width: 24px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(169, 67, 50, 0.1);
  color: var(--seal-red);
  text-align: center;
  font-size: 11px;
}

.artifact-group-items {
  display: grid;
  gap: 5px;
}

.artifact-item {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-color: rgba(191, 201, 191, 0.88);
  background: rgba(255, 253, 247, 0.9);
  color: #2f3835;
  text-align: left;
  font-size: 12px;
}

.artifact-item:hover {
  border-color: rgba(58, 102, 123, 0.52);
  background: #f5f8f5;
}

.artifact-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-item small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

#artifactList {
  display: grid;
  gap: 6px;
  min-width: 0;
  max-height: 220px;
  overflow: auto;
}

.artifact-section #artifactList {
  display: none;
}

.empty-artifact-state {
  padding: 12px;
  border: 1px dashed #cdd8d2;
  border-radius: 6px;
  background: #fbfcf9;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.artifact {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e4df;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.artifact span:first-child {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1240px) {
  .console-body,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .primary-action-band,
  .writing-parameter-band {
    grid-template-columns: 1fr;
  }

  .primary-action-band .quick-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .writing-parameter-band .section-heading {
    border-right: 0;
    padding-right: 0;
  }

  .writing-parameter-band .range-console {
    grid-column: 1;
  }

  .toolbelt .command-shelf {
    grid-template-columns: 1fr;
  }

  .run-rail {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  .actions {
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
  }

  .auth-strip {
    max-width: 100%;
  }

  .auth-strip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .subscription-card {
    padding: 16px;
  }

  .subscription-card-header,
  .subscription-options {
    grid-template-columns: 1fr;
  }

  .subscription-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell,
  .production-console {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .project-rail {
    position: static;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .console-body,
  .workspace-dashboard,
  .toolbelt,
  .range-grid,
  .command-card,
  .command-strip,
  .command-cards,
  .content-grid {
    grid-template-columns: 1fr;
  }

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

  .next-step-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .workflow-rail,
  .workflow-steps {
    grid-template-columns: 1fr;
  }

  .paper-editor-surface {
    order: 2;
    min-height: 560px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .paper-editor-surface .editor-pane {
    min-height: 560px;
  }

  .paper-editor-surface textarea {
    min-height: 620px;
    padding: 22px;
  }

  .writing-parameter-band {
    order: 1;
  }

  .writing-parameter-band .section-heading {
    border-right: 0;
    padding-right: 0;
  }

  .command-actions {
    justify-content: flex-start;
  }

  .output-pane {
    min-height: 420px;
  }
}
