:root {
  --paper: #f8f4eb;
  --surface: #fffdf8;
  --surface-muted: #f2eadc;
  --ink: #251f18;
  --ink-soft: #706659;
  --gold: #a76d21;
  --gold-deep: #815014;
  --gold-pale: #ead6b1;
  --line: rgba(95, 70, 36, 0.18);
  --danger: #a33d2f;
  --success: #3f7653;
  --shadow: 0 20px 60px rgba(65, 46, 21, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shell: 1240px;
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input { font: inherit; }

button,
label { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

a { color: inherit; text-decoration: none; }

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

.shell {
  width: min(calc(100% - 48px), var(--shell));
  margin-inline: auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 244, 235, 0.92);
  backdrop-filter: blur(18px);
}

.header-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-name {
  color: var(--gold);
  font: 700 24px/1 var(--display);
  letter-spacing: 0.12em;
}

.brand-product {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(63, 118, 83, 0.1);
}

.app-main { padding: 72px 0 96px; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 480px);
  align-items: end;
  gap: 80px;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--line);
  animation: rise-in 0.55s ease both;
}

.eyebrow {
  margin-bottom: 15px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.intro h1 {
  font: 700 clamp(42px, 5vw, 68px)/1.12 var(--display);
  letter-spacing: -0.02em;
}

.intro-copy {
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.85;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.7fr);
  gap: 56px;
  padding: 58px 0 38px;
  animation: rise-in 0.55s 0.08s ease both;
}

.workspace-main { min-width: 0; }

.section-label {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 28px;
}

.section-label > span {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-pale);
  border-radius: 50%;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
}

.section-label h2 {
  font: 700 24px/1.25 var(--display);
}

.section-label p {
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.section-label.compact { margin-bottom: 26px; }
.section-label.compact h2 { font-size: 22px; }

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-module {
  min-width: 0;
  padding: 28px;
}

.upload-module + .upload-module { border-left: 1px solid var(--line); }

.module-heading {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.module-heading h3 { font-size: 16px; }

.module-heading h3 span {
  margin-left: 5px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
}

.module-heading p {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.module-index {
  color: var(--gold-pale);
  font: 700 30px/1 var(--display);
}

.dropzone {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  border: 1px dashed rgba(129, 80, 20, 0.38);
  border-radius: var(--radius-md);
  background: #fbf6ec;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--gold);
  background: #f7edda;
  transform: translateY(-2px);
}

.dropzone-action {
  margin-bottom: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  color: #fffaf0;
  background: var(--gold-deep);
  font-size: 12px;
  font-weight: 700;
}

.dropzone strong { font-size: 14px; }
.dropzone small { color: var(--ink-soft); font-size: 11px; line-height: 1.6; }

.upload-preview {
  position: relative;
  min-height: 310px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  animation: preview-in 0.28s ease both;
}

.upload-preview img {
  width: 100%;
  height: 228px;
  display: block;
  object-fit: contain;
  background: #eee5d5;
}

.upload-preview figcaption {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 10px;
  color: var(--ink-soft);
  font-size: 10px;
}

.upload-preview figcaption span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  gap: 18px;
  padding: 0 16px 14px;
}

.text-action {
  padding: 0;
  border: 0;
  color: var(--gold-deep);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.text-action:hover { text-decoration: underline; }
.text-action.danger { color: var(--danger); }

.prompt-panel {
  padding-left: 40px;
  border-left: 1px solid var(--line);
}

.field-group + .field-group { margin-top: 28px; }

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

.field-heading label { font-size: 13px; font-weight: 700; }
.field-heading span { color: var(--ink-soft); font-size: 10px; }

.field-group textarea {
  width: 100%;
  min-height: 240px;
  display: block;
  resize: vertical;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.8;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-group textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(167, 109, 33, 0.1);
}

.field-group textarea::placeholder { color: #9b9184; }

.system-field textarea {
  min-height: 204px;
  color: #716757;
  background: #efe7da;
}

.field-help {
  margin-top: 9px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.6;
}

.form-message {
  margin: 0 0 18px;
  padding: 13px 16px;
  border: 1px solid rgba(163, 61, 47, 0.22);
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: rgba(163, 61, 47, 0.055);
  font-size: 12px;
}

.form-message.is-success {
  border-color: rgba(63, 118, 83, 0.24);
  color: var(--success);
  background: rgba(63, 118, 83, 0.06);
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: 22px 0 38px;
  border-top: 1px solid var(--line);
}

.action-note { display: flex; align-items: center; gap: 16px; }

.action-note > span {
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
}

.action-note p {
  max-width: 600px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.action-buttons { display: flex; gap: 12px; }

.button {
  min-width: 116px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.button:hover:not(:disabled) { transform: translateY(-2px); }

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

.button-primary {
  min-width: 152px;
  color: #fffaf0;
  background: var(--gold-deep);
  box-shadow: 0 12px 28px rgba(129, 80, 20, 0.2);
}

.button-secondary {
  border-color: var(--line);
  background: transparent;
}

.button-progress {
  width: 14px;
  height: 14px;
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.button.is-loading .button-progress { display: block; }

.loading-state {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 28px;
  margin-top: 12px;
  padding: 24px;
  border: 1px solid var(--gold-pale);
  border-radius: var(--radius-md);
  background: #f6eddd;
}

.loading-state[hidden] { display: none; }

.loading-state strong { font-size: 13px; }
.loading-state p { margin-top: 5px; color: var(--ink-soft); font-size: 11px; }

.loading-line {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(167, 109, 33, 0.15);
}

.loading-line span {
  width: 42%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--gold);
  animation: loading-slide 1.45s ease-in-out infinite;
}

.result-section {
  margin-top: 42px;
  padding-top: 50px;
  border-top: 1px solid var(--line);
}

.result-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
}

.result-mode {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 10px;
}

.result-empty {
  min-height: 250px;
  display: grid;
  place-content: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink-soft);
  text-align: center;
}

.result-empty p { color: var(--ink); font: 700 20px/1.3 var(--display); }
.result-empty span { font-size: 11px; }

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

.result-grid[hidden] { display: none; }

.result-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: result-in 0.45s ease both;
}

.result-image-button {
  width: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: #eee5d5;
  cursor: zoom-in;
}

.result-image-button img {
  width: 100%;
  max-height: 680px;
  display: block;
  object-fit: contain;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 18px;
}

.result-meta span { color: var(--ink-soft); font-size: 11px; }

.download-link {
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 700;
}

.download-link:hover { text-decoration: underline; }

.app-footer {
  padding: 28px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  background: #f1eadf;
  font-size: 10px;
}

.app-footer .shell { display: flex; justify-content: space-between; gap: 20px; }

.image-dialog {
  width: min(94vw, 1120px);
  max-height: 92vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-md);
  background: #181510;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
}

.image-dialog::backdrop {
  background: rgba(30, 25, 19, 0.78);
  backdrop-filter: blur(8px);
}

.dialog-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  color: #fff;
}

.dialog-bar h2 { font-size: 13px; }

.dialog-bar button {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  color: #fff;
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}

.image-dialog img {
  width: 100%;
  max-height: calc(92vh - 52px);
  display: block;
  object-fit: contain;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes preview-in {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes loading-slide {
  0% { transform: translateX(-110%); }
  50% { transform: translateX(135%); }
  100% { transform: translateX(350%); }
}

@media (max-width: 980px) {
  .intro { grid-template-columns: 1fr; gap: 22px; }
  .intro-copy { max-width: 650px; }
  .workspace { grid-template-columns: 1fr; gap: 48px; }
  .prompt-panel { padding: 0; border-left: 0; }
  .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
}

@media (max-width: 720px) {
  .shell { width: min(calc(100% - 28px), var(--shell)); }
  .app-main { padding: 44px 0 72px; }
  .brand-product { display: none; }
  .header-status span:last-child { display: none; }
  .intro { padding-bottom: 34px; }
  .intro h1 { font-size: clamp(38px, 12vw, 52px); }
  .workspace { padding-top: 40px; }
  .upload-grid { grid-template-columns: 1fr; }
  .upload-module { padding: 22px; }
  .upload-module + .upload-module { border-top: 1px solid var(--line); border-left: 0; }
  .dropzone,
  .upload-preview { min-height: 280px; }
  .upload-preview img { height: 202px; }
  .field-group textarea { min-height: 220px; }
  .system-field textarea { min-height: 220px; }
  .action-bar { align-items: stretch; flex-direction: column; gap: 20px; }
  .action-buttons { width: 100%; }
  .action-buttons .button { flex: 1; }
  .loading-state { grid-template-columns: 1fr; gap: 16px; }
  .result-heading { flex-direction: column; gap: 0; }
  .result-grid { grid-template-columns: 1fr; }
  .app-footer .shell { flex-direction: column; gap: 8px; }
}

@media (max-width: 420px) {
  .header-inner { min-height: 66px; }
  .intro h1 { font-size: 39px; }
  .module-heading { min-height: 88px; }
  .button { min-width: 0; padding-inline: 16px; }
  .result-empty { min-height: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
