:root {
  --ink: #22211e;
  --muted: #756f67;
  --paper: #f7f2e8;
  --card: rgba(255, 253, 247, 0.86);
  --brick: #ad4f35;
  --brick-dark: #8f3f2b;
  --sage: #789181;
  --line: #d8cfc1;
  --line-dark: #b9aa96;
  --soft: #e7dece;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: url("/assets/ivory-grid-paper.png");
  background-size: 760px 760px;
  background-attachment: fixed;
}
button, input, textarea { font: inherit; }
button { color: inherit; }

.site-header {
  height: 132px;
  padding: 0 max(28px, calc((100vw - 1500px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 247, 239, 0.54);
}
.brand { display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.brand-name {
  font-family: "Songti SC", STSong, "Noto Serif SC", serif;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .22em;
}
.brand-name::first-letter { color: var(--brick); }
.brand-tagline { margin-top: 5px; color: #736c63; font-size: 13px; letter-spacing: .14em; }
.header-actions { display: flex; align-items: center; gap: 38px; }
.status-pill {
  padding: 11px 18px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #63786b;
  border: 1px solid #b9c5bc;
  border-radius: 999px;
  background: rgba(246, 249, 245, .7);
  font-size: 13px;
}
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: #b59b78; }
.status-pill.ready i { background: #779a82; }
.status-pill.missing i { background: var(--brick); }
.ghost-button, .text-button {
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
  background: none;
}
.ghost-button { font-size: 15px; }
.text-button { color: #81786e; font-size: 12px; }

main { max-width: 1550px; margin: 0 auto; padding: 0 26px 74px; }
.hero { min-height: 378px; padding: 105px 0 64px; }
.eyebrow { color: var(--brick); font-size: 12px; font-weight: 700; letter-spacing: .27em; }
.hero h1 {
  margin: 26px 0 19px;
  font-family: "Songti SC", STSong, "Noto Serif SC", serif;
  font-size: clamp(43px, 5.3vw, 72px);
  font-weight: 500;
  letter-spacing: .025em;
  line-height: 1.15;
}
.hero h1 em { color: var(--brick); font-style: normal; border-bottom: 2px solid rgba(173,79,53,.55); }
.hero p { max-width: 950px; margin: 0; color: var(--muted); font-size: 15px; letter-spacing: .04em; line-height: 1.9; }

.studio-shell { display: grid; grid-template-columns: minmax(390px, 560px) minmax(570px, 1fr); gap: 36px; align-items: start; }
.studio-main, .result-section {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 12px 30px rgba(86, 68, 45, .045);
}
.source-panel, .controls-panel { padding: 38px; }
.source-panel { border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading > div, .result-heading > div { display: flex; align-items: baseline; gap: 18px; }
.panel-heading h2, .result-heading h2 {
  margin: 0;
  font-family: "Songti SC", STSong, "Noto Serif SC", serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: .06em;
}
.step { color: var(--brick); font-family: Georgia, serif; font-size: 13px; letter-spacing: .08em; }
.section-note { margin: 8px 0 22px 40px; color: var(--muted); font-size: 12px; }

.upload-zone {
  position: relative;
  width: 100%;
  height: 132px;
  padding: 0;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  border: 1px dashed var(--line-dark);
  border-radius: 0;
  background: rgba(255,255,255,.24);
  transition: border-color .18s, background-color .18s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--brick); background: rgba(255,250,244,.74); }
.upload-empty { height: 100%; padding: 24px 25px; display: grid; grid-template-columns: 1fr auto; align-content: center; gap: 6px 14px; }
.upload-empty strong { font-family: "Songti SC", STSong, serif; font-size: 17px; }
.upload-empty span { color: var(--muted); font-size: 11px; }
.upload-empty u { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--brick); text-decoration: none; font-size: 13px; }
.source-preview { position: absolute; inset: 0; padding: 18px; display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 17px; background: rgba(255,253,247,.86); }
.source-preview img { width: 78px; height: 94px; display: block; object-fit: cover; }
.source-copy { min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.source-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.source-copy small { color: var(--sage); font-size: 11px; }
.replace-badge { color: var(--brick); font-size: 13px; }

.render-presets { margin: 22px 0 28px; display: grid; gap: 12px; }
.render-presets > button {
  position: relative;
  min-height: 91px;
  padding: 17px 18px;
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 12px;
  align-items: start;
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255,255,255,.22);
}
.render-presets > button.active { border-color: var(--brick); box-shadow: inset 4px 0 0 var(--brick); background: rgba(255,249,244,.68); }
.radio-mark { width: 16px; height: 16px; margin-top: 2px; border: 1px solid #9c9284; border-radius: 50%; }
.render-presets > button.active .radio-mark { border: 5px solid white; outline: 1px solid var(--brick); background: var(--brick); }
.render-presets button > span:nth-child(2) { display: flex; flex-direction: column; gap: 7px; }
.render-presets strong { font-size: 14px; }
.render-presets small { color: var(--muted); font-size: 11px; line-height: 1.55; }
.render-presets em { padding: 4px 7px; color: var(--brick); background: rgba(173,79,53,.055); font-style: normal; font-size: 10px; }

.style-title { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; }
.style-title button { padding: 3px 0; color: var(--brick); border: 0; border-bottom: 1px solid rgba(173,79,53,.4); background: none; cursor: pointer; font-size: 11px; }
.style-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-reference-option { padding: 7px; display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: center; text-align: left; cursor: pointer; border: 1px solid var(--line); border-radius: 0; background: rgba(255,255,255,.24); }
.style-reference-option.active { border-color: var(--brick); background: rgba(255,249,244,.7); }
.style-reference-option img { width: 58px; height: 66px; display: block; object-fit: cover; }
.style-reference-option > span { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.style-reference-option strong { font-size: 11px; }
.style-reference-option small { color: var(--muted); font-size: 9px; line-height: 1.35; }

.compact-row { margin-top: 24px; padding: 17px 0; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.compact-row > div { display: flex; flex-direction: column; gap: 3px; }
.compact-row label { font-size: 12px; font-weight: 600; }
.compact-row small { color: var(--muted); font-size: 10px; }
.switch { position: relative; width: 38px; height: 21px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; cursor: pointer; border: 1px solid #b9ae9f; background: #e7ded1; }
.switch span::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: white; transition: transform .18s; }
.switch input:checked + span { border-color: var(--brick); background: var(--brick); }
.switch input:checked + span::after { transform: translateX(17px); }
.more-options { padding: 15px 0; border-bottom: 1px solid var(--line); }
.more-options summary { color: #5e5851; cursor: pointer; font-size: 11px; }
.details-body { padding-top: 12px; display: grid; gap: 8px; }
.details-body label { color: var(--muted); font-size: 10px; }
.details-body textarea { width: 100%; padding: 10px; resize: vertical; color: #4d4944; border: 1px solid var(--line); border-radius: 0; outline: none; background: rgba(255,255,255,.45); font-size: 11px; line-height: 1.55; }
.details-body textarea:focus { border-color: var(--brick); }

.primary-button, .secondary-button { min-height: 48px; padding: 0 22px; border-radius: 0; cursor: pointer; letter-spacing: .06em; }
.primary-button { color: white; border: 1px solid var(--brick); background: var(--brick); }
.primary-button:hover { background: var(--brick-dark); }
.primary-button:disabled { cursor: not-allowed; opacity: .46; }
.controls-panel > .primary-button { width: 100%; min-height: 60px; margin-top: 28px; font-family: "Songti SC", STSong, serif; font-size: 19px; }
.secondary-button { color: #4d4841; border: 1px solid #a99d8d; background: transparent; }
.primary-button.small { min-height: 48px; background: #25241f; border-color: #25241f; }
.privacy-note { margin: 13px 0 0; text-align: center; color: #8f8a83; font-size: 9px; }

.result-section { padding: 38px; }
.result-heading { min-height: 52px; display: flex; align-items: flex-start; justify-content: space-between; }
.result-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.comparison { --position: 50%; position: relative; width: 100%; min-height: 620px; height: min(810px, calc(100vh - 190px)); margin-top: 22px; overflow: hidden; border: 20px solid var(--soft); background: #ddd3c3; }
.comparison img { width: 100%; height: 100%; display: block; object-fit: contain; background: #161512; }
.before-image { position: absolute; inset: 0; }
.after-layer { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--position)) 0 0); }
.comparison input { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare-handle { position: absolute; z-index: 3; top: 0; bottom: 0; left: var(--position); width: 2px; pointer-events: none; background: rgba(255,255,255,.95); }
.compare-handle span { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 54px; height: 54px; display: grid; place-items: center; color: var(--brick); border: 1px solid var(--line); border-radius: 50%; background: #fffdf7; font-size: 10px; box-shadow: 0 5px 16px rgba(50,40,28,.14); }
.compare-label { position: absolute; z-index: 2; top: 20px; padding: 8px 14px; color: white; background: rgba(37,35,31,.72); font-size: 10px; letter-spacing: .08em; }
.compare-label.before { right: 20px; }
.compare-label.after { left: 20px; }
.comparison-placeholder { position: absolute; inset: 0; z-index: 2; padding: 35px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #e3dacb; }
.comparison-placeholder strong { font-family: "Songti SC", STSong, serif; font-size: 22px; letter-spacing: .06em; }
.comparison-placeholder span { max-width: 360px; margin-top: 12px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.comparison.is-empty .compare-handle, .comparison.is-empty .compare-label { display: none; }
.result-footer { min-height: 77px; padding-top: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.result-footer strong { font-family: "Songti SC", STSong, serif; font-size: 15px; }
.result-footer p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.result-actions { display: flex; gap: 10px; }

footer { max-width: 1500px; margin: 55px auto 0; padding: 25px 0 34px; display: flex; justify-content: space-between; color: #8d857b; border-top: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; }
footer p { margin: 0; }

.generation-overlay { position: fixed; inset: 0; z-index: 20; padding: 20px; display: grid; place-items: center; background: rgba(43,36,29,.58); }
.generation-card { position: relative; width: min(440px, 100%); padding: 43px; text-align: center; border: 1px solid var(--line); background: #fbf7ee; box-shadow: 0 28px 90px rgba(34,27,21,.24); }
.overlay-close, .dialog-close { position: absolute; top: 14px; right: 15px; padding: 4px 0; cursor: pointer; color: #70675e; border: 0; border-bottom: 1px solid currentColor; background: none; font-size: 11px; }
.progress-kicker { color: var(--brick); font-size: 9px; font-weight: 700; letter-spacing: .2em; }
.generation-card h2 { margin: 16px 0 9px; font-family: "Songti SC", STSong, serif; font-size: 26px; }
.generation-card p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.generation-card small { color: #999188; font-size: 9px; }
.progress-track { height: 3px; margin: 0 0 18px; overflow: hidden; background: var(--soft); }
.progress-track span { display: block; width: 35%; height: 100%; background: var(--brick); animation: progress 2.2s ease-in-out infinite; }
@keyframes progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }

dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 0; padding: 0; background: #fbf7ee; box-shadow: 0 25px 90px rgba(25,22,18,.3); }
dialog::backdrop { background: rgba(38,32,26,.6); }
.image-dialog { width: min(700px, calc(100vw - 40px)); overflow: hidden; }
.image-dialog img { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: #ddd4c5; }
.image-dialog > div { padding: 15px 20px 18px; display: flex; justify-content: space-between; gap: 16px; font-size: 11px; }
.image-dialog span { color: var(--muted); }
.help-dialog { width: min(480px, calc(100vw - 40px)); padding: 42px; }
.help-dialog h2 { margin: 15px 0 25px; font-family: "Songti SC", STSong, serif; font-size: 24px; }
.help-dialog ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 18px; }
.help-dialog li { display: flex; align-items: flex-start; gap: 15px; }
.help-dialog li b { color: var(--brick); font-family: Georgia, serif; font-size: 12px; }
.help-dialog li span { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 10px; }
.help-dialog li strong { color: #393632; font-size: 12px; }
.help-dialog > p { margin: 24px 0 0; padding-top: 15px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 40; transform: translate(-50%, 18px); max-width: min(480px, calc(100vw - 30px)); padding: 12px 17px; opacity: 0; pointer-events: none; color: white; background: rgba(45,41,35,.94); font-size: 11px; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(143,63,43,.96); }

@media (max-width: 1120px) {
  .studio-shell { grid-template-columns: 1fr; }
  .studio-main { display: grid; grid-template-columns: minmax(330px, .8fr) minmax(430px, 1.2fr); }
  .source-panel { border-bottom: 0; border-right: 1px solid var(--line); }
  .comparison { height: min(760px, 78vh); }
}
@media (max-width: 780px) {
  .site-header { height: 92px; padding: 0 20px; }
  .brand-name { font-size: 21px; }
  .brand-tagline { font-size: 10px; }
  .status-pill { display: none; }
  .header-actions { gap: 0; }
  main { padding: 0 12px 45px; }
  .hero { min-height: 0; padding: 64px 10px 50px; }
  .hero h1 { font-size: 41px; line-height: 1.28; }
  .hero h1 em { display: block; width: max-content; margin-top: 4px; }
  .hero p { font-size: 12px; }
  .studio-shell, .studio-main { display: block; }
  .studio-main { margin-bottom: 18px; }
  .source-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .source-panel, .controls-panel, .result-section { padding: 25px 20px; }
  .section-note { margin-left: 39px; }
  .style-options { grid-template-columns: 1fr; }
  .comparison { min-height: 470px; height: 68vh; border-width: 10px; }
  .result-footer { flex-direction: column; }
  .result-actions { width: 100%; }
  .result-actions button { flex: 1; }
  footer { margin: 30px 12px 0; }
}
@media (max-width: 430px) {
  .header-actions .ghost-button { font-size: 12px; }
  .hero h1 { font-size: 36px; }
  .panel-heading h2, .result-heading h2 { font-size: 22px; }
  .source-panel, .controls-panel, .result-section { padding: 22px 16px; }
  .render-presets > button { grid-template-columns: 18px 1fr; }
  .render-presets em { grid-column: 2; justify-self: start; }
  .comparison { min-height: 410px; }
  .image-dialog > div { flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
