:root {
  --paper: #f5efe5;
  --paper-2: #ece2d2;
  --card: #fffaf2;
  --ink: #2b2622;
  --ink-soft: #4b433c;
  --muted: #84786c;
  --line: rgba(43, 38, 34, 0.14);
  --line-strong: rgba(43, 38, 34, 0.24);
  --accent: #b05f3c;
  --accent-deep: #8d472b;
  --sage: #74836c;
  --gold: #c69a5c;
  --danger: #a3402f;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --shadow: 0 18px 50px rgba(64, 48, 33, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(198, 154, 92, 0.16), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(116, 131, 108, 0.12), transparent 60%),
    var(--paper);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    repeating-linear-gradient(0deg, rgba(43, 38, 34, 0.018) 0px, rgba(43, 38, 34, 0.018) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
}

button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: 0.01em; margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px calc(12px + env(safe-area-inset-top));
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(245, 239, 229, 0.96), rgba(245, 239, 229, 0.82) 70%, rgba(245, 239, 229, 0));
  backdrop-filter: blur(8px);
}

.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-cn { font-family: var(--serif); font-size: 18px; letter-spacing: 0.12em; }
.brand-en { font-size: 8.5px; letter-spacing: 0.28em; color: var(--muted); margin-top: 4px; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink);
}
.icon-btn svg { width: 18px; height: 18px; }
.back[hidden] { visibility: hidden; display: grid; }

.quota-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: rgba(255, 250, 242, 0.6);
}

main {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 8px 20px 40px;
}

.screen { display: none; }
.screen.active { display: block; animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 9.5px;
  letter-spacing: 0.34em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.lede {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
  margin-top: 14px;
}

.desktop-only { display: none; }

/* ---------- 邀请页 ---------- */
.invite-hero { padding: 18px 0 8px; }
.invite-hero h1 {
  font-size: clamp(34px, 9vw, 62px);
  line-height: 1.24;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}
.invite-card {
  margin-top: 34px;
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 460px;
}
.field-label { display: block; font-size: 12px; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 8px; }
.code-input {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fffdf8;
  font-size: 16px;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(176, 95, 60, 0.12); }
.field-error { color: var(--danger); font-size: 12px; min-height: 18px; margin: 8px 0 0; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 10px; }
.fineprint { color: var(--muted); font-size: 11px; line-height: 1.8; margin-top: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14.5px;
  letter-spacing: 0.08em;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.985); }
.btn.primary {
  background: var(--ink);
  color: #fbf6ec;
  width: 100%;
  margin-top: 16px;
}
.btn.primary:hover { background: #3a332c; }
.btn.primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink-soft);
}
.btn.ghost:hover { background: rgba(255, 250, 242, 0.7); }

.invite-visual { display: none; }
.vertical-note { writing-mode: vertical-rl; letter-spacing: 0.22em; color: var(--muted); font-size: 10px; }

/* ---------- 首页 ---------- */
.home-head { padding: 26px 0 8px; max-width: 640px; }
.home-head h2 { font-size: clamp(28px, 7vw, 44px); line-height: 1.3; }

.entry-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 28px; }
.entry-card {
  position: relative;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 20px;
  overflow: hidden;
  min-height: 186px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(64, 48, 33, 0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}
.entry-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.entry-card.family { background: linear-gradient(140deg, #f3e6d2, #fbf6ec 62%); }
.entry-card.parentchild { background: linear-gradient(140deg, #e6eadf, #fbf6ec 62%); }
.entry-art { position: absolute; right: -8px; bottom: -4px; width: 58%; max-width: 250px; color: rgba(43, 38, 34, 0.42); }
.entry-art svg { width: 100%; height: auto; }
.entry-kicker { font-size: 9px; letter-spacing: 0.3em; color: var(--muted); }
.entry-title { font-family: var(--serif); font-size: 26px; margin-top: 10px; }
.entry-desc { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.entry-arrow { margin-top: auto; font-size: 12px; letter-spacing: 0.12em; color: var(--accent-deep); padding-top: 18px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 36px 0 12px; }
.section-head h3 { font-size: 20px; }
.text-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-decoration: underline; text-underline-offset: 3px; }
.text-btn.danger { color: var(--danger); }

.recent { display: grid; gap: 10px; }
.recent-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 242, 0.7);
  text-align: left;
  width: 100%;
}
.recent-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--paper-2); }
.recent-meta { min-width: 0; }
.recent-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.recent-status { font-size: 10.5px; color: var(--accent-deep); letter-spacing: 0.06em; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: 16px; padding: 22px; color: var(--muted); font-size: 12.5px; text-align: center; }

.notes-strip { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.notes-strip p { font-size: 11.5px; color: var(--muted); line-height: 1.8; }

/* ---------- 主题 ---------- */
.screen-head { padding: 26px 0 6px; max-width: 680px; }
.screen-head h2 { font-size: clamp(26px, 6.6vw, 40px); }
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.template-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  text-align: left;
  padding: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.template-card[disabled] { opacity: 0.42; }
.template-cover { position: relative; aspect-ratio: 4 / 3; overflow: hidden; display: grid; place-items: center; }
.template-cover svg { width: 84%; height: 84%; color: rgba(43, 38, 34, 0.55); }
.template-cover .cover-index { position: absolute; top: 10px; left: 12px; font-size: 9px; letter-spacing: 0.2em; color: rgba(43, 38, 34, 0.55); }
.cover-outdoor { background: linear-gradient(160deg, #dfe6cf, #f4ecd8 70%); }
.cover-birthday { background: linear-gradient(160deg, #f3ddc9, #faf0e2 70%); }
.cover-autumn { background: linear-gradient(160deg, #e8c99a, #f6e9d2 70%); }
.cover-chinese { background: linear-gradient(160deg, #dfe3dc, #f3efe6 70%); }
.cover-spring { background: linear-gradient(160deg, #eed7cd, #f8eee3 70%); }
.cover-cozy { background: linear-gradient(160deg, #e8dfd0, #f8f2e7 70%); }
.template-body { padding: 12px 13px 14px; }
.template-name { font-family: var(--serif); font-size: 17px; }
.template-tag { font-size: 11.5px; color: var(--muted); line-height: 1.65; margin-top: 6px; min-height: 36px; }
.template-people { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip { font-size: 9.5px; letter-spacing: 0.05em; border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; color: var(--muted); }
.season-chip { color: var(--accent-deep); border-color: rgba(176, 95, 60, 0.3); }

/* ---------- 上传 ---------- */
.selected-template {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 242, 0.7);
  margin-top: 22px;
}
.selected-template .st-cover { width: 52px; height: 52px; border-radius: 10px; overflow: hidden; flex: none; display: grid; place-items: center; }
.selected-template .st-cover svg { width: 80%; height: 80%; color: rgba(43, 38, 34, 0.55); }
.selected-template .st-name { font-family: var(--serif); font-size: 16px; }
.selected-template .st-desc { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.guidance { margin-top: 20px; border-left: 2px solid var(--gold); padding: 4px 0 4px 16px; }
.guidance-title { font-size: 12.5px; letter-spacing: 0.06em; margin-bottom: 8px; }
.guidance ul li { font-size: 12px; color: var(--muted); line-height: 1.9; position: relative; padding-left: 12px; }
.guidance ul li::before { content: ""; position: absolute; left: 0; top: 0.8em; width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }

.dropzone {
  margin-top: 20px;
  display: block;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 250, 242, 0.55);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover { border-color: var(--accent); background: rgba(255, 250, 242, 0.8); }
.dropzone input { display: none; }
.dropzone-empty { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; }
.drop-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); margin-bottom: 8px; }
.drop-icon svg { width: 20px; height: 20px; }
.drop-title { font-family: var(--serif); font-size: 18px; }
.drop-sub { font-size: 11.5px; color: var(--muted); }
.dropzone-preview { position: relative; }
.dropzone-preview img { width: 100%; max-height: 62vh; object-fit: contain; background: #1c1916; }
.change-photo { position: absolute; right: 12px; bottom: 12px; background: rgba(28, 25, 22, 0.7); color: #f7f1e7; font-size: 11px; padding: 6px 10px; border-radius: 999px; }

.form-block { margin-top: 26px; }
.people-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.people-row button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 250, 242, 0.7);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.people-row button.active { border-color: var(--ink); background: var(--ink); color: #fbf6ec; }
.people-row button[disabled] { opacity: 0.3; cursor: not-allowed; }

.consent-block { margin-top: 26px; display: grid; gap: 12px; }
.check { display: grid; grid-template-columns: 18px 1fr; gap: 10px; font-size: 12px; line-height: 1.75; color: var(--ink-soft); align-items: start; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); }

.order-bar {
  margin-top: 28px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.8);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.order-title { font-family: var(--serif); font-size: 17px; }
.order-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.order-bar .btn { margin-top: 0; }

/* ---------- 进度 ---------- */
.progress-wrap { max-width: 520px; margin: 8vh auto 0; text-align: center; }
.progress-visual { position: relative; width: 140px; height: 140px; margin: 0 auto 22px; color: var(--accent); }
.progress-visual svg { width: 100%; height: 100%; position: relative; z-index: 1; animation: spin 18s linear infinite; }
.halo { position: absolute; inset: 18px; border-radius: 50%; background: radial-gradient(circle, rgba(198, 154, 92, 0.26), transparent 68%); animation: pulse 3.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(0.9); opacity: 0.6; } 50% { transform: scale(1.08); opacity: 1; } }
.progress-wrap h2 { font-size: 28px; }
.stepper { margin: 34px auto 0; max-width: 320px; text-align: left; }
.step { display: flex; align-items: center; gap: 12px; padding: 9px 0; color: var(--muted); font-size: 13px; position: relative; }
.step i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; flex: none; }
.step.done { color: var(--ink); }
.step.done i { background: var(--sage); border-color: var(--sage); }
.step.active { color: var(--accent-deep); }
.step.active i { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px rgba(176, 95, 60, 0.12); }
.step:not(:last-child)::after { content: ""; position: absolute; left: 4px; top: 26px; width: 1px; height: 14px; background: var(--line); }
.elapsed { margin-top: 24px; font-size: 11.5px; color: var(--muted); letter-spacing: 0.08em; }
.progress-wrap .btn { margin-top: 22px; min-width: 220px; }

/* ---------- 结果 ---------- */
.result-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 26px; }
.result-card { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--card); }
.result-image-wrap { position: relative; background: #1c1916; }
.result-image-wrap img { width: 100%; height: auto; min-height: 220px; object-fit: contain; }
.ai-badge { position: absolute; left: 12px; bottom: 12px; font-size: 9.5px; letter-spacing: 0.14em; color: rgba(255, 250, 242, 0.92); border: 1px solid rgba(255, 250, 242, 0.45); border-radius: 999px; padding: 4px 9px; backdrop-filter: blur(4px); background: rgba(28, 25, 22, 0.35); }
.result-card-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; gap: 10px; }
.result-label { font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.save-btn { border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 8px 14px; font-size: 12px; }
.save-btn:hover { background: var(--ink); color: #fbf6ec; border-color: var(--ink); }
.result-note { margin-top: 16px; font-size: 11.5px; color: var(--muted); line-height: 1.8; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.result-actions .btn { margin-top: 0; width: 100%; }
.result-links { display: flex; justify-content: space-between; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.result-links .text-btn { font-size: 11.5px; }

/* ---------- 底部/弹层 ---------- */
.footer { position: relative; z-index: 1; padding: 26px 20px calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); text-align: center; }
.footer p { font-size: 10.5px; color: var(--muted); line-height: 2; }
.footer .text-btn { font-size: 10.5px; }
.dot { margin: 0 6px; opacity: 0.5; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(43, 38, 34, 0.94);
  color: #fbf6ec;
  font-size: 12.5px;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 80;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal { position: fixed; inset: 0; z-index: 70; background: rgba(28, 25, 22, 0.55); backdrop-filter: blur(4px); display: grid; place-items: end center; padding: 0; }
.modal[hidden] { display: none; }
.modal-card {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 26px 22px calc(22px + env(safe-area-inset-bottom));
  position: relative;
  animation: sheet 0.3s ease both;
}
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; font-size: 24px; color: var(--muted); line-height: 1; }
.modal-card h3 { font-size: 22px; margin-bottom: 14px; }
.modal-body p { font-size: 12.5px; color: var(--ink-soft); line-height: 1.95; margin-bottom: 12px; }
.modal-card .btn { margin-top: 10px; }

.feedback-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.feedback-options button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 8px 12px; font-size: 12px; color: var(--ink-soft); }
.feedback-options button.active { background: var(--ink); color: #fbf6ec; border-color: var(--ink); }
#feedbackText { width: 100%; border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px; font-size: 13px; background: #fffdf8; resize: vertical; outline: none; }
#feedbackText:focus { border-color: var(--accent); }

/* ---------- 桌面 ---------- */
@media (min-width: 760px) {
  .topbar { padding-left: 40px; padding-right: 40px; }
  main { padding: 12px 40px 60px; }
  .desktop-only { display: inline; }
  .invite-hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 60px; align-items: center; padding: 6vh 0; }
  .invite-visual { display: flex; justify-content: flex-end; gap: 16px; align-items: flex-end; min-height: 460px; position: relative; }
  .frame { position: absolute; border: 1px solid var(--line-strong); background: rgba(255, 250, 242, 0.5); box-shadow: var(--shadow); }
  .f1 { width: 190px; height: 260px; right: 40px; top: 30px; transform: rotate(-4deg); background: linear-gradient(160deg, #eadfce, #fdf8ef); }
  .f2 { width: 170px; height: 230px; right: 170px; top: 130px; transform: rotate(5deg); background: linear-gradient(160deg, #e4e8dd, #fbf7ee); }
  .f3 { width: 150px; height: 200px; right: 90px; top: 220px; transform: rotate(-1deg); background: linear-gradient(160deg, #f1ddce, #fdf8ef); }
  .vertical-note { position: absolute; right: 0; bottom: 0; }
  .entry-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
  .entry-card { padding: 26px; min-height: 240px; }
  .template-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .order-bar { flex-direction: row; align-items: center; justify-content: space-between; }
  .order-bar .btn { width: auto; min-width: 180px; padding: 0 34px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .progress-wrap { margin-top: 10vh; }
  .modal { place-items: center; padding: 24px; }
  .modal-card { border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
