:root {
  --paper: #f4efe5;
  --ink: #262b26;
  --muted: #6f756d;
  --green: #315e4d;
  --green-soft: #dfe9de;
  --orange: #dd7b3f;
  --orange-soft: #f7e0d0;
  --line: rgba(38, 43, 38, 0.15);
  --white: #fffefa;
  --shadow: 0 22px 60px rgba(59, 50, 38, 0.11);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.78), transparent 24rem),
    radial-gradient(circle at 88% 15%, rgba(210, 226, 208, 0.58), transparent 26rem),
    var(--paper);
}

main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 6px;
}

button, select, input { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }

.paper-grain {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.23;
  background-image:
    repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(76, 64, 45, 0.018) 4px),
    repeating-linear-gradient(90deg, transparent 0, transparent 5px, rgba(76, 64, 45, 0.015) 6px);
  mix-blend-mode: multiply;
}

.site-header, main, footer {
  width: min(1440px, calc(100% - 48px));
  margin-left: auto;
  margin-right: auto;
}

.site-header {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand strong, .brand small { display: block; }

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

.brand small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
  margin-top: 3px;
}

.brand-mark {
  width: 43px;
  height: 43px;
  position: relative;
  display: grid;
  place-items: center;
  transform: rotate(-4deg);
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1.5px solid var(--ink);
  border-radius: 48% 52% 54% 46%;
}

.brand-mark span {
  position: absolute;
  display: block;
  width: 4px;
  height: 20px;
  border-radius: 9px;
  transform-origin: 50% 100%;
}

.brand-mark span:nth-child(1) { background: var(--orange); transform: translate(-7px, 0) rotate(-14deg); }
.brand-mark span:nth-child(2) { background: #d8ad45; transform: translate(0, -1px); }
.brand-mark span:nth-child(3) { background: var(--green); transform: translate(7px, 0) rotate(14deg); }

.privacy-note {
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.privacy-dot, .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5c8b5e;
  box-shadow: 0 0 0 4px rgba(92, 139, 94, 0.13);
}

.hero {
  min-height: 0;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 6px 28px;
  padding: 8px 3% 6px;
}

.eyebrow {
  color: var(--orange);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  margin: 0 0 4px;
}

.hero h1 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.25;
  margin: 0;
  white-space: nowrap;
}

.hero h1 span {
  color: var(--green);
  position: relative;
  white-space: nowrap;
}

.hero h1 span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 3px;
  border-radius: 50%;
  background: var(--orange);
  transform: rotate(-1deg);
}

.hero-copy {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: none;
  margin: 0;
}

.hero-sketch {
  position: relative;
  justify-self: end;
  width: min(100%, 150px);
  transform: rotate(1deg);
}

.hero-sketch svg { display: block; width: 100%; overflow: visible; }

.hero-sketch path, .hero-sketch circle, .front-paper path {
  fill: none;
  stroke: rgba(49, 94, 77, 0.56);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-sketch span {
  position: absolute;
  right: 3%;
  top: 5%;
  color: var(--orange);
  font-family: "Kaiti SC", "STKaiti", serif;
  font-size: 12px;
  line-height: 1.5;
  transform: rotate(5deg);
}

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  overflow: hidden;
  background: rgba(255, 254, 250, 0.86);
  border: 1px solid rgba(51, 57, 50, 0.12);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  margin-bottom: 0;
}

.control-panel {
  padding: 18px 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.76);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.step-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.step-heading > span {
  color: var(--orange);
  font-family: "Songti SC", serif;
  font-size: 13px;
  font-weight: 700;
  padding-top: 4px;
}

.step-heading h2 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 3px;
}

.step-heading p { color: var(--muted); font-size: 12px; margin: 0; }
.step-heading.compact { margin-bottom: 20px; }

.drop-zone {
  min-height: 120px;
  border: 1.5px dashed rgba(49, 94, 77, 0.38);
  border-radius: 14px;
  background: rgba(223, 233, 222, 0.33);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 180ms ease;
  padding: 12px;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--green);
  background: rgba(223, 233, 222, 0.62);
  transform: translateY(-2px);
}

.drop-zone.has-file { border-style: solid; border-color: rgba(49, 94, 77, 0.6); }

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.upload-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 11px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
}

.upload-icon svg, .download-button svg, .primary-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-zone strong { max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.drop-zone > span:last-child { color: var(--muted); font-size: 11px; margin-top: 7px; }
.divider { border-top: 1px solid var(--line); margin: 28px -34px; }

.field { border: 0; padding: 0; margin: 0 0 20px; }

.field > label, .field legend {
  display: block;
  color: #454b44;
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 9px;
  padding: 0;
}

.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--white);
  padding: 0 38px 0 13px;
  outline: none;
  cursor: pointer;
}

.field select:focus {
  border-color: rgba(49, 94, 77, 0.65);
  box-shadow: 0 0 0 3px rgba(49, 94, 77, 0.08);
}

.field-tip { display: block; color: var(--muted); font-size: 10px; margin-top: 6px; }

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(38, 43, 38, 0.055);
}

.segment label { cursor: pointer; }
.segment input { position: absolute; opacity: 0; }

.segment span {
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  transition: 160ms ease;
}

.segment input:checked + span {
  color: var(--green);
  font-weight: 650;
  background: var(--white);
  box-shadow: 0 2px 8px rgba(45, 54, 45, 0.08);
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin: 23px 0 25px;
  cursor: pointer;
}

.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.toggle-row input { position: absolute; opacity: 0; }

.toggle-row i {
  width: 42px;
  height: 24px;
  border-radius: 20px;
  background: rgba(38, 43, 38, 0.17);
  position: relative;
  transition: 180ms ease;
}

.toggle-row i::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(31, 35, 31, 0.25);
  transition: 180ms ease;
}

.toggle-row input:checked + i { background: var(--green); }
.toggle-row input:checked + i::after { transform: translateX(18px); }

.primary-button {
  width: 100%;
  height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(49, 94, 77, 0.2);
  transition: 180ms ease;
}

.primary-button:hover:not(:disabled) { background: #274f40; transform: translateY(-2px); }
.primary-button:disabled { color: rgba(255, 255, 255, 0.7); background: #9ca99f; box-shadow: none; cursor: not-allowed; }
.primary-button.loading svg { animation: move-arrow 900ms ease-in-out infinite; }

.error-message {
  min-height: 16px;
  color: #a74630;
  font-size: 11px;
  line-height: 1.4;
  margin: 6px 0 0;
}

.preview-panel {
  min-width: 0;
  min-height: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(rgba(49, 94, 77, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(49, 94, 77, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
}

.preview-toolbar {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.preview-toolbar > div { display: flex; align-items: center; gap: 11px; }
.preview-toolbar strong { font-size: 13px; }

.download-button {
  height: 34px;
  padding: 0 13px;
  color: var(--green);
  border: 1px solid rgba(49, 94, 77, 0.25);
  border-radius: 9px;
  background: rgba(255, 254, 250, 0.85);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.download-button svg { width: 16px; height: 16px; }
.download-button:disabled { color: #9ca19c; border-color: var(--line); cursor: not-allowed; }

.preview-stage {
  min-height: 0;
  flex: 1 1 auto;
  height: clamp(180px, calc(100dvh - 290px), 380px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(232, 223, 208, 0.37);
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  overflow: hidden;
}

.empty-state, .loading-state { width: min(380px, 80%); text-align: center; }

.empty-state h3, .loading-state h3 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  margin: 16px 0 6px;
}

.empty-state p, .loading-state p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0; }

.paper-stack { width: 80px; height: 104px; position: relative; margin: 0 auto; }

.paper-stack > div {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(46, 56, 47, 0.14);
  border-radius: 3px;
  background: #fffefa;
  box-shadow: 0 15px 28px rgba(50, 45, 38, 0.1);
}

.paper-stack > div:nth-child(1) { transform: rotate(-7deg) translate(-8px, 4px); }
.paper-stack > div:nth-child(2) { transform: rotate(6deg) translate(7px, 2px); }
.front-paper { display: grid; place-items: center; }
.front-paper svg { width: 82%; }

.pencil-loader {
  width: 190px;
  height: 4px;
  margin: 0 auto;
  border-radius: 3px;
  background: rgba(49, 94, 77, 0.13);
  overflow: hidden;
}

.pencil-loader span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  animation: pencil-progress 1.4s ease-in-out infinite;
}

.comparison {
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 14px;
  padding: 16px;
}

.comparison figure { min-width: 0; min-height: 0; margin: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.comparison figcaption { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; margin: 0 0 9px 3px; }

.comparison img {
  width: 100%;
  min-height: 0;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: white;
  box-shadow: 0 13px 32px rgba(55, 48, 39, 0.12);
}

.result-figure img { border: 8px solid white; }

.result-feedback {
  margin-top: 16px;
  min-height: 54px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 254, 250, 0.84);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.result-feedback > div { display: flex; align-items: baseline; gap: 5px; color: var(--muted); font-size: 11px; }
.result-feedback strong { color: var(--green); font-size: 13px; }
.result-feedback button {
  padding: 7px 10px;
  color: var(--green);
  font-size: 11px;
  border: 0;
  border-radius: 8px;
  background: var(--green-soft);
  cursor: pointer;
}

footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 8px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #555c54;
  font-family: "Kaiti SC", "STKaiti", serif;
  font-size: 13px;
  letter-spacing: 0.08em;
}

@keyframes pencil-progress {
  0% { transform: translateX(-110%); }
  55%, 100% { transform: translateX(240%); }
}

@keyframes move-arrow {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr; }
  .hero-sketch { display: none; }
  .workspace { grid-template-columns: 340px minmax(0, 1fr); }
}

@media (max-width: 780px) {
  .site-header, main, footer { width: min(100% - 24px, 680px); }
  .site-header { height: 60px; }
  .privacy-note { font-size: 10px; }
  .hero { padding: 16px 6px; }
  .hero h1 { font-size: 22px; white-space: normal; line-height: 1.3; }
  .hero-copy { font-size: 13px; }
  .workspace { display: block; border-radius: 18px; }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--line); padding: 26px 22px; }
  .divider { margin-left: -22px; margin-right: -22px; }
  .preview-panel { padding: 18px 14px; }
  .preview-stage { min-height: 0; height: 320px; }
  .comparison { grid-template-columns: 1fr; padding: 13px; }
  .comparison img { height: 100%; }
  .comparison figure:first-child { display: none; }
  .result-feedback { align-items: flex-start; flex-direction: column; }
  footer {
    padding: 16px 0 calc(24px + env(safe-area-inset-bottom, 0px));
    font-size: 12px;
    justify-content: center;
    text-align: center;
  }
  footer span:first-child { max-width: 100%; display: inline-block; }
}
