:root {
  color-scheme: light;
  --red-950: #650b17;
  --red-900: #83101f;
  --red-800: #9f1525;
  --red-700: #bc1c2e;
  --gold-500: #d9aa53;
  --gold-300: #f2d390;
  --cream-50: #fffdf8;
  --cream-100: #faf6ee;
  --ink-900: #251a1b;
  --ink-600: #786a6b;
  --line: #eadfd5;
  --shadow: 0 16px 40px rgba(84, 21, 28, 0.1);
  font-family:
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: #ece5dc;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink-900);
  background: #ece5dc;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(217, 170, 83, 0.55);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 95% 35%, rgba(217, 170, 83, 0.1), transparent 22rem),
    var(--cream-100);
}

.hero {
  position: relative;
  padding: calc(20px + env(safe-area-inset-top)) 20px 42px;
  overflow: hidden;
  color: #fff9ec;
  background:
    radial-gradient(circle at 78% 12%, rgba(255, 220, 148, 0.36) 0 2px, transparent 3px),
    radial-gradient(circle at 89% 28%, rgba(255, 220, 148, 0.2) 0 3px, transparent 4px),
    radial-gradient(circle at 14% 78%, rgba(255, 220, 148, 0.18) 0 2px, transparent 3px),
    linear-gradient(145deg, var(--red-950), var(--red-700) 68%, #d03b3b);
}

.hero::after {
  position: absolute;
  right: -84px;
  bottom: -130px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(247, 211, 144, 0.22);
  border-radius: 50%;
  box-shadow:
    0 0 0 28px rgba(247, 211, 144, 0.06),
    0 0 0 64px rgba(247, 211, 144, 0.04);
  content: "";
}

.brand-card {
  position: relative;
  z-index: 1;
  display: flex;
  width: fit-content;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 22px rgba(65, 5, 13, 0.16);
}

.brand-card img {
  display: block;
  width: 152px;
  height: auto;
}

.brand-card span {
  padding-left: 10px;
  border-left: 1px solid #ddd1c5;
  color: var(--red-800);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.hero-kicker {
  position: relative;
  z-index: 1;
  margin: 36px 0 12px;
  color: var(--gold-300);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3em;
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: clamp(31px, 9vw, 42px);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: 0.03em;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 310px;
  margin: 15px 0 23px;
  color: rgba(255, 250, 238, 0.78);
  font-size: 14px;
  line-height: 1.7;
}

.trust-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trust-row span {
  padding: 6px 10px;
  border: 1px solid rgba(255, 229, 175, 0.26);
  border-radius: 999px;
  color: #ffe6b0;
  background: rgba(84, 4, 15, 0.2);
  font-size: 11px;
}

main {
  position: relative;
  z-index: 2;
  padding: 0 14px;
  margin-top: -20px;
}

.panel {
  padding: 22px 18px;
  border: 1px solid rgba(223, 209, 196, 0.75);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 14px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-number {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--red-800);
  background: #f8ead5;
  font-size: 12px;
  font-weight: 800;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.5;
}

.template-list {
  display: flex;
  gap: 12px;
  margin: 18px -18px -2px;
  padding: 2px 18px 10px;
  overflow-x: auto;
  scroll-padding-left: 18px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.template-list::-webkit-scrollbar {
  display: none;
}

.template-loading {
  display: grid;
  width: 100%;
  min-height: 178px;
  place-items: center;
  color: var(--ink-600);
  font-size: 13px;
}

.template-card {
  position: relative;
  width: 138px;
  flex: 0 0 138px;
  padding: 6px;
  scroll-snap-align: start;
  text-align: left;
  border: 2px solid transparent;
  border-radius: 15px;
  color: inherit;
  background: #f8f3eb;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.template-card:active {
  transform: scale(0.985);
}

.template-card[aria-pressed="true"] {
  border-color: var(--red-700);
  background: #fffaf1;
  box-shadow: 0 9px 22px rgba(135, 17, 32, 0.14);
}

.template-preview {
  position: relative;
  display: block;
  height: 154px;
  overflow: hidden;
  border-radius: 10px;
  background: #eadbd2;
}

.template-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.selected-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  display: none;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: rgba(152, 18, 35, 0.92);
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(67, 0, 8, 0.24);
}

.template-card[aria-pressed="true"] .selected-badge {
  display: block;
}

.template-name {
  display: block;
  margin: 9px 3px 2px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-description {
  display: block;
  min-height: 32px;
  margin: 0 3px 3px;
  overflow: hidden;
  color: var(--ink-600);
  font-size: 10px;
  line-height: 1.5;
}

.details-panel {
  padding-bottom: 20px;
}

.field-list {
  display: grid;
  gap: 15px;
  margin-top: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-900);
  background: #fff;
  font-size: 16px;
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease;
}

.field input::placeholder {
  color: #b5a8a4;
}

.field input:focus {
  border-color: var(--red-700);
  box-shadow: 0 0 0 4px rgba(188, 28, 46, 0.08);
}

.field input:user-invalid {
  border-color: #c83243;
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 62px;
}

.input-with-unit > span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--ink-600);
  font-size: 13px;
  transform: translateY(-50%);
  pointer-events: none;
}

.field-readonly input {
  color: var(--red-800);
  background: #fbf4e8;
  font-weight: 750;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  padding: 12px;
  border-radius: 12px;
  color: #665957;
  background: #f8f3eb;
}

.privacy-mark {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #728e64;
  font-size: 12px;
  font-weight: 800;
}

.privacy-note p {
  margin: 0;
  font-size: 11px;
  line-height: 1.65;
}

.privacy-note strong {
  display: block;
  margin-bottom: 1px;
  color: #4d413f;
  font-size: 12px;
}

.submit-dock {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin: 0 -14px;
  padding: 18px 14px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(250, 246, 238, 0), rgba(250, 246, 238, 0.96) 25%);
}

.generate-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 16px;
  color: #fff8e8;
  background: linear-gradient(135deg, var(--red-900), var(--red-700));
  box-shadow: 0 12px 24px rgba(132, 14, 30, 0.26);
  cursor: pointer;
}

.generate-button span {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.generate-button small {
  padding-left: 9px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 248, 232, 0.78);
  font-size: 10px;
}

.generate-button:disabled {
  background: #a89d99;
  box-shadow: none;
  cursor: not-allowed;
}

.generate-button:not(:disabled):active {
  transform: translateY(1px);
  box-shadow: 0 7px 16px rgba(132, 14, 30, 0.24);
}

.site-footer {
  padding: 20px 20px calc(30px + env(safe-area-inset-bottom));
  text-align: center;
  color: #9b8e89;
}

.site-footer img {
  width: 138px;
  height: auto;
  opacity: 0.72;
}

.site-footer p {
  margin: 7px 0 0;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.result-layer,
.busy-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.result-layer {
  display: grid;
  align-items: end;
}

.result-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(32, 12, 15, 0.66);
  backdrop-filter: blur(4px);
}

.result-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 94vh;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  background: var(--cream-50);
  box-shadow: 0 -16px 48px rgba(35, 6, 10, 0.25);
}

.result-handle {
  width: 38px;
  height: 4px;
  margin: 1px auto 14px;
  border-radius: 999px;
  background: #ddd1ca;
}

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

.result-heading p {
  margin: 0 0 3px;
  color: var(--red-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.result-heading h2 {
  margin: 0;
  font-size: 19px;
}

.close-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 50%;
  color: #756865;
  background: #f2ece5;
  font-size: 26px;
  line-height: 1;
}

.result-image-frame {
  display: flex;
  min-height: 260px;
  max-height: 53vh;
  align-items: center;
  justify-content: center;
  margin-top: 15px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid #ead8ca;
  border-radius: 15px;
  background:
    linear-gradient(45deg, #f1e9e2 25%, transparent 25%),
    linear-gradient(-45deg, #f1e9e2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1e9e2 75%),
    linear-gradient(-45deg, transparent 75%, #f1e9e2 75%),
    #fffaf3;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.result-image-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(53vh - 16px);
  object-fit: contain;
  box-shadow: 0 9px 26px rgba(60, 15, 21, 0.17);
  -webkit-touch-callout: default;
  user-select: auto;
}

.save-tip {
  margin: 12px 0;
  color: var(--ink-600);
  font-size: 12px;
  text-align: center;
}

.download-button,
.secondary-button {
  display: grid;
  width: 100%;
  min-height: 50px;
  place-items: center;
  border-radius: 13px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 750;
}

.download-button {
  color: #fff8e8;
  background: linear-gradient(135deg, var(--red-900), var(--red-700));
}

.secondary-button {
  margin-top: 9px;
  color: var(--red-800);
  background: #f6ede2;
}

.busy-layer {
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 12, 15, 0.54);
  backdrop-filter: blur(3px);
}

.busy-card {
  width: min(270px, 82vw);
  padding: 28px 20px;
  border-radius: 20px;
  text-align: center;
  background: #fffdf8;
  box-shadow: 0 24px 60px rgba(31, 3, 7, 0.25);
}

.spinner {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid #eed9c5;
  border-top-color: var(--red-700);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.busy-card strong {
  display: block;
  font-size: 16px;
}

.busy-card p {
  margin: 6px 0 0;
  color: var(--ink-600);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 40;
  width: max-content;
  max-width: calc(100vw - 36px);
  padding: 10px 15px;
  border-radius: 999px;
  color: #fff;
  background: rgba(38, 23, 24, 0.92);
  box-shadow: 0 8px 30px rgba(33, 10, 12, 0.2);
  font-size: 12px;
  text-align: center;
  transform: translateX(-50%);
}

body.modal-open {
  overflow: hidden;
}

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

@media (min-width: 600px) {
  body {
    padding: 24px 0;
  }

  .app-shell {
    width: 520px;
    min-height: calc(100vh - 48px);
    margin: 0 auto;
    border-radius: 28px;
    box-shadow: 0 20px 80px rgba(75, 37, 34, 0.2);
  }

  .result-sheet {
    max-width: 520px;
    margin: 0 auto;
    border-radius: 24px 24px 0 0;
  }
}

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