:root {
  color: #222725;
  background: #f8f7f3;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --surface: #f8f7f3;
  --surface-strong: #fffefb;
  --text: #222725;
  --muted: #727874;
  --line: #dddeda;
  --line-strong: #c7cbc5;
  --teal: #31796c;
  --teal-dark: #235f55;
  --teal-soft: #e9f1ee;
  --amber: #9a6b24;
  --amber-soft: #fff5df;
  --danger: #9a4038;
  --danger-soft: #fff0ed;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  padding-bottom: 88px;
  background: var(--surface);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
summary,
select,
input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
}

.create-header {
  min-height: 84px;
  padding: 18px clamp(24px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 254, 251, 0.92);
}

.brand {
  color: inherit;
  display: flex;
  align-items: baseline;
  gap: 18px;
  text-decoration: none;
}

.brand strong {
  font-family: "Songti SC", "STSong", serif;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.brand span,
.column-heading span,
.action-bar span {
  color: var(--muted);
}

.advanced-link,
.text-button {
  color: var(--teal-dark);
  font-weight: 700;
}

.advanced-link {
  text-decoration: none;
}

.advanced-link:hover,
.text-button:hover {
  text-decoration: underline;
}

.create-layout {
  min-height: calc(100vh - 172px);
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(430px, 1.14fr) minmax(320px, 0.94fr);
}

.source-column,
.process-column,
.output-column {
  min-width: 0;
  padding: 36px clamp(24px, 3vw, 48px) 48px;
}

.source-column,
.process-column {
  border-right: 1px solid var(--line);
}

.column-heading {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  margin-bottom: 30px;
}

.column-heading p {
  margin: 4px 0 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.column-heading h1,
.column-heading h2 {
  margin: 0 0 5px;
  font-size: 22px;
  line-height: 1.25;
}

.column-heading span {
  display: block;
  font-size: 13px;
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field > span {
  color: #4e5551;
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--text);
  outline: none;
  background: var(--surface-strong);
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(49, 121, 108, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.75;
}

.article-format-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.template-preference-field {
  margin-top: 22px;
}

.template-preference-status {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #525955;
  font-size: 13px;
}

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

.text-button {
  margin-top: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.error-banner {
  margin: -10px 0 20px;
  padding: 13px 14px;
  border-left: 3px solid var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.55;
}

.flow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.flow-step {
  position: relative;
  padding: 0 0 24px 50px;
}

.flow-step::before {
  content: "";
  position: absolute;
  top: 30px;
  bottom: 0;
  left: 15px;
  border-left: 1px solid var(--line);
}

.flow-step:last-child::before {
  display: none;
}

.step-number {
  position: absolute;
  top: 0;
  left: 0;
  width: 31px;
  padding-top: 7px;
  border-top: 2px solid var(--line-strong);
  color: #969b97;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.flow-step.complete .step-number {
  border-color: var(--amber);
  color: var(--amber);
}

.flow-step.active .step-number {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.flow-step.error .step-number {
  border-color: var(--danger);
  color: var(--danger);
}

.step-summary {
  min-height: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.step-summary strong {
  display: block;
  font-size: 16px;
}

.step-summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.flow-step.active .step-summary strong {
  color: var(--teal-dark);
}

.flow-step.error .step-summary strong {
  color: var(--danger);
}

.step-panel {
  margin-top: 13px;
  border: 1px solid #b9cec8;
  border-radius: 7px;
  padding: 18px;
  background: var(--teal-soft);
}

.step-panel h3 {
  margin: 0 0 7px;
  font-size: 17px;
}

.step-panel > p {
  margin: 0 0 15px;
  color: #53605b;
  font-size: 13px;
  line-height: 1.65;
}

.plan-summary {
  display: grid;
  gap: 13px;
}

.summary-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid rgba(49, 121, 108, 0.16);
}

.summary-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.summary-row dt {
  color: var(--muted);
  font-size: 12px;
}

.summary-row dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.plan-editor {
  margin-top: 15px;
  border-top: 1px solid rgba(49, 121, 108, 0.18);
  padding-top: 13px;
}

.plan-editor summary,
.technical-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}

.plan-editor-fields {
  display: grid;
  gap: 12px;
  padding-top: 13px;
}

.notice {
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid #e5c98d;
  border-radius: 6px;
  color: #805c20;
  background: var(--amber-soft);
  font-size: 12px;
  line-height: 1.55;
}

.candidate-list {
  display: grid;
  gap: 9px;
}

.candidate {
  width: 100%;
  border: 1px solid rgba(49, 121, 108, 0.22);
  border-radius: 6px;
  padding: 12px 13px;
  color: inherit;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  text-align: left;
}

.candidate:hover:not(:disabled),
.candidate.selected {
  border-color: var(--teal);
  background: #fff;
}

.candidate:focus-visible {
  outline: 3px solid rgba(49, 121, 108, 0.18);
  outline-offset: 1px;
}

.candidate:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.candidate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.candidate-head strong {
  font-size: 14px;
}

.candidate-tag {
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
}

.candidate p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.recovery-actions {
  margin-top: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-button {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 10px;
  color: #555d58;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.output-column {
  background: #faf9f6;
}

.output-content {
  min-height: 600px;
}

.output-empty {
  min-height: 560px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.output-empty strong {
  margin-bottom: 8px;
  color: #555b57;
  font-family: "Songti SC", "STSong", serif;
  font-size: 23px;
  font-weight: 600;
}

.output-empty span {
  max-width: 260px;
  font-size: 13px;
  line-height: 1.7;
}

.output-progress {
  width: min(220px, 80%);
  margin-top: 24px;
  border-top: 2px solid var(--teal);
  padding-top: 10px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.output-selection {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.output-selection > span {
  color: var(--muted);
  font-size: 12px;
}

.output-selection h3 {
  margin: 8px 0;
  font-size: 19px;
}

.output-selection p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.result-summary > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.result-thumbnail-button {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: #f2f0e9;
  cursor: zoom-in;
  transition: border-color 150ms ease, transform 150ms ease;
}

.result-thumbnail-button:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
}

.result-thumbnail-button:focus-visible {
  outline: 3px solid rgba(49, 121, 108, 0.28);
  outline-offset: 3px;
}

.result-thumbnail-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reveal-error {
  min-height: 17px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 11px;
}

.result-folder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.result-folder > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.result-folder span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.result-folder code {
  overflow-wrap: anywhere;
  color: #505854;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.image-viewer {
  width: min(94vw, 1180px);
  max-width: min(94vw, 1180px);
  max-height: 94vh;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0;
  color: var(--text);
  background: var(--surface-strong);
}

.image-viewer::backdrop {
  background: rgba(23, 32, 29, 0.72);
}

.image-viewer-shell {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.image-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.image-viewer-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  object-fit: contain;
  background: #f2f0e9;
}

.quality-line {
  margin: 0;
  border-left: 3px solid var(--teal);
  padding: 9px 11px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 700;
}

.technical-details {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.technical-details pre {
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  color: #dbe7e3;
  background: #1f2c28;
  white-space: pre-wrap;
  word-break: break-word;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.action-bar {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 78px;
  padding: 12px clamp(24px, 3vw, 48px);
  border-top: 1px solid rgba(25, 69, 61, 0.35);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 36px;
  color: #fff;
  background: #2f7568;
}

.action-bar > div {
  display: grid;
  gap: 3px;
  text-align: right;
}

.action-bar strong {
  font-size: 14px;
}

.action-bar span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.action-bar button {
  min-width: 190px;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  padding: 0 22px;
  color: var(--teal-dark);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.action-bar button:hover:not(:disabled) {
  background: #f5faf8;
}

.action-bar button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.42);
  outline-offset: 2px;
}

.action-bar button:disabled {
  cursor: wait;
  opacity: 0.58;
}

@media (max-width: 1080px) {
  .create-layout {
    grid-template-columns: minmax(280px, 0.8fr) minmax(440px, 1.2fr);
  }

  .process-column {
    border-right: 0;
  }

  .output-column {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .output-content {
    min-height: 0;
  }

  .output-empty {
    min-height: 260px;
  }

  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: 116px;
  }

  .create-header {
    min-height: 72px;
    padding: 14px 18px;
  }

  .brand {
    display: grid;
    gap: 2px;
  }

  .brand strong {
    font-size: 23px;
  }

  .brand span {
    font-size: 11px;
  }

  .advanced-link {
    font-size: 13px;
  }

  .create-layout {
    display: block;
  }

  .source-column,
  .process-column,
  .output-column {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 28px 20px 34px;
  }

  .source-options {
    grid-template-columns: 1fr 116px;
  }

  .flow-step {
    padding-left: 42px;
  }

  .step-panel {
    padding: 15px;
  }

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

  .result-folder {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .result-folder .small-button {
    width: 100%;
  }

  .action-bar {
    min-height: 104px;
    padding: 12px 18px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .action-bar > div {
    text-align: left;
  }

  .action-bar button {
    width: 100%;
    min-height: 42px;
  }
}
