:root {
  color-scheme: light;
  --bg: #e8e9e8;
  --panel: #fffefa;
  --panel-solid: #fffefa;
  --panel-soft: #f7f5ef;
  --line: #d8d5cc;
  --line-strong: #bcb8ae;
  --text: #202421;
  --muted: #70766f;
  --primary: #244f74;
  --primary-hover: #1c4263;
  --primary-soft: #e8f0f5;
  --success: #356b54;
  --success-soft: #edf5ef;
  --warning: #8a642d;
  --warning-soft: #f8f1e4;
  --danger: #a53e3e;
  --danger-soft: #faeeee;
  --shadow: 0 12px 30px rgba(48, 50, 45, 0.08);
  --radius: 5px;
}

html {
  background: var(--bg);
}

body.document-studio-theme {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body.document-studio-theme ::selection {
  background: rgba(36, 79, 116, 0.18);
}

body.document-studio-theme button,
body.document-studio-theme input,
body.document-studio-theme select,
body.document-studio-theme textarea {
  letter-spacing: 0;
}

body.document-studio-theme button {
  border-radius: 5px;
  box-shadow: none;
}

body.document-studio-theme button:focus-visible,
body.document-studio-theme a:focus-visible {
  outline: 2px solid rgba(36, 79, 116, 0.35);
  outline-offset: 2px;
}

body.document-studio-theme input,
body.document-studio-theme select,
body.document-studio-theme textarea {
  min-height: 40px;
  border-color: var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: none;
}

body.document-studio-theme input:hover,
body.document-studio-theme select:hover,
body.document-studio-theme textarea:hover {
  border-color: var(--line-strong);
}

body.document-studio-theme input:focus,
body.document-studio-theme select:focus,
body.document-studio-theme textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(36, 79, 116, 0.11);
}

.app-shell {
  min-height: 100vh;
  grid-template-columns: 208px minmax(0, 1fr);
  background: var(--bg);
}

.app-shell.workspace-shell {
  grid-template-columns: 208px minmax(650px, 1fr) 270px;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #f3f2ee;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
  gap: 18px;
  overflow-y: auto;
}

.workspace-shell .sidebar {
  grid-template-rows: auto auto 1fr auto;
}

.brand-button {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
}

.brand-button:hover {
  background: transparent;
}

.brand-button .brand-mark,
.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid var(--text);
  border-radius: 0;
  background: var(--text);
  color: var(--panel);
  box-shadow: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
}

.brand-text {
  min-width: 0;
  display: grid;
  gap: 1px;
  color: var(--text);
}

.brand-text strong {
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 16px;
  line-height: 1.2;
}

.brand-text em {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-project {
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sidebar-project small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.sidebar-project strong,
.sidebar-project span {
  display: block;
}

.sidebar-project strong {
  margin-top: 7px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.55;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.sidebar-project span {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-nav {
  min-height: 0;
  align-content: start;
  gap: 6px;
}

.side-nav button {
  width: 100%;
  min-height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #50564f;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  text-align: left;
}

.side-nav button:hover {
  border-color: transparent;
  background: rgba(255, 254, 250, 0.65);
  color: var(--primary);
}

.side-nav button.active {
  border: 0;
  background: var(--panel);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.side-nav button span {
  width: 20px;
  color: #858a82;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.side-nav button.active span {
  color: var(--primary);
}

.side-nav button em {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user {
  width: 30px;
  height: 30px;
  justify-self: start;
  border-radius: 50%;
  background: var(--success);
  box-shadow: none;
  font-size: 10px;
}

.main {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0 24px 64px;
  gap: 0;
}

.route-launcher .main,
.route-projects .main,
.route-admin .main,
.route-engineering .main,
.route-image .main {
  padding-right: 28px;
  padding-left: 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  min-height: 62px;
  margin: 0 -24px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  align-items: center;
}

.route-launcher .topbar,
.route-projects .topbar,
.route-admin .topbar,
.route-engineering .topbar,
.route-image .topbar {
  margin-right: -28px;
  margin-left: -28px;
  padding-right: 28px;
  padding-left: 28px;
}

.header-copy {
  min-width: 220px;
}

.header-copy h1 {
  margin: 0 0 3px;
  color: var(--text);
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
}

.header-copy p {
  max-width: 620px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  gap: 7px;
  row-gap: 7px;
}

.header-actions button,
.btn,
.stage-actions button,
.toolbar button,
.utility-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: #3f4640;
  box-shadow: none;
  font-size: 11px;
  font-weight: 700;
}

.header-actions > button:not(.secondary),
.btn:not(.secondary):not(.ghost):not(.danger),
.stage-actions button:not(.secondary):not(.ghost):not(.danger),
.toolbar button:not(.secondary):not(.ghost):not(.danger),
.settings-sticky-actions button:not(.secondary),
.info-fill-sticky-actions button:not(.secondary) {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}

.header-actions > button:not(.secondary):hover,
.btn:not(.secondary):not(.ghost):not(.danger):hover,
.stage-actions button:not(.secondary):not(.ghost):not(.danger):hover,
.toolbar button:not(.secondary):not(.ghost):not(.danger):hover {
  background: var(--primary-hover);
}

.header-actions button.secondary,
.btn.secondary,
button.secondary,
.utility-button {
  border-color: var(--line);
  background: var(--panel);
  color: #3f4640;
  box-shadow: none;
}

.route-toggle {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f1f0ec;
}

.workspace-shell .route-toggle {
  display: none;
}

.route-toggle button {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.route-toggle button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(48, 50, 45, 0.08);
}

.workspace-shell .step-strip {
  width: min(920px, 100%);
  min-height: 64px;
  margin: 24px auto 0;
  gap: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--panel);
}

.workspace-shell .step-item {
  min-width: 0;
  min-height: 63px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
}

.workspace-shell .step-item:last-child {
  border-right: 0;
}

.workspace-shell .step-item:hover {
  border-color: var(--line);
  background: var(--panel-soft);
}

.workspace-shell .step-item.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--primary);
  box-shadow: inset 0 -3px 0 var(--primary);
}

.workspace-shell .step-index {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  font-size: 9px;
}

.workspace-shell .step-item.complete .step-index,
.workspace-shell .step-item.active .step-index {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.workspace-shell .step-copy strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-shell .step-copy em {
  margin-top: 2px;
  overflow: hidden;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page {
  gap: 18px;
}

.workspace-shell .page {
  width: min(920px, 100%);
  margin: 0 auto;
  gap: 0;
}

.stage {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  box-shadow: none;
}

.workspace-shell .stage {
  border-radius: 0;
  box-shadow: var(--shadow);
}

.stage-head {
  gap: 18px;
}

.stage-head h2 {
  color: var(--text);
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 21px;
  font-weight: 700;
}

.stage-head p {
  max-width: 760px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.badge,
.pill,
.metric {
  border-color: var(--line);
  border-radius: 3px;
  background: var(--panel-soft);
  color: var(--muted);
}

.settings-stage {
  padding: 28px 38px 86px;
  gap: 0;
  background: var(--panel);
}

.settings-stage > .stage-head {
  min-height: 92px;
  margin: -28px -38px 0;
  padding: 26px 38px 20px;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.settings-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
  gap: 14px;
}

.settings-section-title {
  gap: 16px;
}

.settings-section-title strong {
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 15px;
}

.settings-section-title span {
  color: var(--muted);
  font-size: 9px;
}

.title-input-wrap {
  max-width: none;
}

.title-input-wrap input {
  min-height: 44px;
  padding: 0 76px 0 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
}

.title-input-wrap input:focus {
  border-color: var(--primary);
  background: transparent;
  box-shadow: 0 2px 0 var(--primary);
}

.title-input-wrap span {
  right: 0;
  font-size: 9px;
}

.page-slider-wrap {
  padding-top: 34px;
}

.page-slider-wrap output {
  min-width: 42px;
  padding: 5px 7px;
  border-radius: 3px;
  background: var(--primary);
  font-size: 10px;
}

.page-slider-wrap input[type="range"] {
  accent-color: var(--primary);
}

.page-ticks {
  color: var(--muted);
  font-size: 9px;
}

.select-card-grid {
  max-width: none;
  gap: 9px;
}

.select-card,
.model-card,
.choice-card,
.toggle-card,
.upload-card,
.image-source-card {
  border-color: var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: none;
}

.select-card {
  min-height: 62px;
  padding: 11px 12px;
}

.select-card:hover,
.model-card:hover,
.choice-card:hover,
.toggle-card:hover,
.upload-card:hover,
.image-source-card:hover {
  border-color: #8aa6ba;
  background: #fbfcfc;
}

.select-card:has(input:checked),
.model-card:has(input:checked),
.visual-choice-card:has(input:checked),
.layout-choice-card:has(input:checked),
.cover-choice-card:has(input:checked),
.choice-card.active,
.toggle-card.active,
.image-source-card.active {
  border-color: #8aa6ba;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(36, 79, 116, 0.12);
}

.choice-indicator {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.select-card:has(input:checked) .choice-indicator {
  border: 4px solid var(--primary);
}

.select-card-copy strong {
  font-size: 11px;
}

.select-card-copy em {
  font-size: 9px;
}

.model-card-grid {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  overflow: visible;
}

.model-card {
  min-height: 50px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.model-card:has(input:checked) {
  border-color: var(--line);
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.model-symbol {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  box-shadow: none;
  font-size: 8px;
}

.model-card:has(input:checked) .model-symbol {
  border: 5px solid var(--primary);
  background: var(--panel);
  color: transparent;
}

.visual-card-scroller {
  grid-auto-columns: 170px;
  gap: 9px;
  padding-bottom: 8px;
}

.layout-card-grid {
  grid-auto-columns: 230px;
  gap: 10px;
  padding-bottom: 8px;
}

.visual-choice-card,
.layout-choice-card,
.cover-choice-card {
  padding: 8px;
  border-color: var(--line);
  border-radius: 4px;
  background: #fff;
}

.visual-choice-card strong,
.layout-choice-card strong,
.cover-choice-card strong {
  font-size: 10px;
}

.visual-choice-card em,
.layout-choice-card em {
  min-height: 30px;
  font-size: 8px;
}

.style-preview-frame {
  height: 140px;
}

.image-preview-button {
  min-height: 26px;
  border-radius: 3px;
  font-size: 9px;
}

.preset-rule-tag,
.layout-reference-badge {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 8px;
}

.compact-settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.compact-setting {
  padding: 0;
  border: 0;
  background: transparent;
}

.pill-choice-row {
  gap: 5px;
}

.pill-choice span {
  min-height: 28px;
  padding: 0 9px;
  border-color: var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--muted);
  font-size: 9px;
}

.pill-choice:has(input:checked) span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.advanced-settings {
  margin: 0;
  padding: 18px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.advanced-settings summary {
  color: var(--primary);
  font-size: 11px;
}

.cover-card-grid {
  grid-auto-columns: 160px;
  gap: 9px;
  padding-bottom: 8px;
}

.cover-preview {
  border-radius: 0;
}

.settings-sticky-actions,
.info-fill-sticky-actions {
  min-height: 70px;
  margin-right: -38px;
  margin-left: -38px;
  padding: 14px 38px;
  border-top: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.96);
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-sticky-actions button,
.info-fill-sticky-actions button {
  min-height: 34px;
  font-size: 10px;
}

.settings-sticky-actions span {
  color: var(--muted);
  font-size: 9px;
}

.studio-inspector {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 18px;
  border-left: 1px solid var(--line);
  background: #f4f4f1;
  overflow-y: auto;
}

.studio-inspector-head span {
  color: var(--primary);
  font-size: 8px;
  font-weight: 800;
}

.studio-inspector-head h2 {
  margin: 7px 0 0;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 16px;
}

.studio-inspector-head p {
  margin: 5px 0 18px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.studio-summary-group {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.studio-summary-group small {
  color: #8b8f88;
  font-size: 8px;
  font-weight: 800;
}

.studio-summary-group strong,
.studio-summary-group span {
  display: block;
}

.studio-summary-group strong {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
}

.studio-summary-group span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.studio-summary-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.studio-summary-tags b {
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  color: #4f554f;
  font-size: 8px;
}

.studio-inspector-note {
  margin-top: 12px;
  padding: 10px;
  border-left: 3px solid #b4823e;
  background: var(--warning-soft);
  color: #75541f;
  font-size: 9px;
  line-height: 1.55;
}
