/* 一封信 · 封面主页 / 体验入口（手机优先） */
@font-face {
  font-family: "YfxBrand"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("brand.woff2") format("woff2");
}
@font-face { font-family: "YfxMashan"; font-display: swap; src: url("font-mashan.woff2") format("woff2"); }
@font-face { font-family: "YfxLongcang"; font-display: swap; src: url("font-longcang.woff2") format("woff2"); }
@font-face { font-family: "YfxZhimang"; font-display: swap; src: url("font-zhimang.woff2") format("woff2"); }

:root {
  --bg: #f2eee6;
  --paper: #fffaf3;
  --ink: #33251a;
  --muted: #7a6a58;
  --line: rgba(58, 42, 27, 0.13);
  --gold: #b98f44;
  --wax: #a5302b;
  --wax-deep: #7f201c;
  --ok: #2c6b4a;
  --shadow: 0 10px 30px rgba(58, 42, 27, 0.1);
  --brand: "YfxBrand", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--sans); min-height: 100dvh; overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.page { max-width: 480px; margin: 0 auto; padding: 0 20px calc(28px + env(safe-area-inset-bottom)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 26px; border: 0; border-radius: 999px;
  font-weight: 650; font-size: 17px; letter-spacing: .06em; text-decoration: none;
  background: var(--wax); color: #fff8ee;
  box-shadow: 0 8px 20px rgba(165, 48, 43, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px) scale(.985); background: var(--wax-deep); }
.btn:disabled { opacity: .55; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 8px 16px; font-size: 14px; letter-spacing: .02em; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- 首页 ---------- */
.hero { text-align: center; padding: calc(44px + env(safe-area-inset-top)) 0 8px; }
.seal { width: 62px; height: 62px; margin: 0 auto 14px; display: block; filter: drop-shadow(0 6px 10px rgba(127, 32, 28, 0.3)); }
.hero h1 { font: 400 64px/1.1 var(--brand); letter-spacing: .12em; text-indent: .12em; color: var(--ink); }
.hero .tagline { margin-top: 12px; font-size: 18px; color: var(--ink); letter-spacing: .04em; }
.hero .sub { margin-top: 6px; font-size: 14px; color: var(--muted); }
.hero .cta { margin-top: 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero .cta .btn { min-width: 220px; }
.hero .cta small { font-size: 13px; color: var(--muted); }

.section { margin-top: 44px; }
.section > h2 { font: 400 30px/1.2 var(--brand); letter-spacing: .1em; text-align: center; }
.section > .lead { margin-top: 6px; text-align: center; font-size: 14px; color: var(--muted); }

.carousel { margin: 18px -20px 0; position: relative; }
.track {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 6px calc(50% - 105px) 18px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.track::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 210px; scroll-snap-align: center; margin: 0; text-align: center;
  transition: transform .35s ease, opacity .35s ease; transform: scale(.9); opacity: .55;
}
.slide.on { transform: scale(1); opacity: 1; }
.slide .shot {
  display: block; width: 210px; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px;
  background: #e9e2d4; box-shadow: 0 14px 30px rgba(58, 42, 27, 0.18); border: 1px solid rgba(58, 42, 27, 0.08);
}
.slide figcaption { margin-top: 12px; font-size: 14px; color: var(--ink); }
.slide figcaption small { display: block; font-size: 11px; color: var(--gold); letter-spacing: .14em; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots button { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: rgba(58, 42, 27, 0.18); transition: all .25s; }
.dots button.on { width: 18px; border-radius: 4px; background: var(--wax); }

.steps { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; counter-reset: s; }
.steps li {
  counter-increment: s; display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
}
.steps li::before {
  content: counter(s); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font: 400 22px/1 var(--brand); color: var(--wax); border: 1px solid rgba(165, 48, 43, 0.35); background: #fff;
}
.steps b { display: block; font-weight: 650; }
.steps span { font-size: 13px; color: var(--muted); }

.contacts { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.contact {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 10px 12px;
  text-align: center; min-width: 0;
}
.contact .qr {
  width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; background: #fff; display: block; object-fit: contain;
  border: 1px solid var(--line);
}
.contact .qr.todo {
  display: grid; place-items: center; border-style: dashed; color: var(--muted); font-size: 12px; line-height: 1.5; padding: 8px;
}
.contact h3 { margin-top: 10px; font-size: 15px; font-weight: 650; }
.contact .id {
  display: inline-block; margin-top: 2px; padding: 2px 6px; border: 0; background: none; border-radius: 6px;
  font-size: 13px; color: #6b4a1b; font-variant-numeric: tabular-nums; word-break: break-all;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.contact .tip { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }

.custom { margin-top: 44px; text-align: center; padding: 26px 18px; border-radius: 20px; background: #efe6d3; border: 1px solid var(--line); }
.custom p { font: 400 26px/1.4 var(--brand); letter-spacing: .06em; }
.custom .btn { margin-top: 14px; }
.foot { margin-top: 30px; text-align: center; font-size: 12px; color: var(--muted); }
.foot a { text-decoration: none; }

/* 弹层 */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center;
  background: rgba(40, 28, 18, 0.5); opacity: 0; pointer-events: none; transition: opacity .22s;
}
.modal.on { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(24px); transition: transform .25s ease;
}
.modal.on .sheet { transform: none; }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet header h2 { font: 400 26px/1.2 var(--brand); letter-spacing: .08em; }
.sheet .close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(58, 42, 27, 0.08); font-size: 20px; line-height: 1; }
.sheet .lead { font-size: 13px; color: var(--muted); margin-top: 4px; }
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  z-index: 80; background: rgba(40, 28, 18, 0.9); color: #fff; font-size: 14px; padding: 9px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .2s; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 体验码输入页 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 6px; }
.topbar .brand { font: 400 28px/1 var(--brand); letter-spacing: .1em; text-decoration: none; }
.topbar .back { font-size: 14px; color: var(--muted); text-decoration: none; padding: 8px 0 8px 12px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 22px 18px; margin-top: 16px; }
.panel h1 { font: 400 34px/1.2 var(--brand); letter-spacing: .08em; text-align: center; }
.panel .lead { text-align: center; font-size: 14px; color: var(--muted); margin-top: 6px; }
.code-input {
  width: 100%; margin-top: 18px; padding: 14px 10px; text-align: center; border: 1px solid var(--line); border-radius: 14px; background: #fff; outline: none;
  font: 700 26px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .22em; text-indent: .22em; text-transform: uppercase;
}
.code-input::placeholder { font: 400 16px/1.9 var(--sans); letter-spacing: .04em; text-indent: 0; color: #b3a696; }
.code-input:focus, .field:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(185, 143, 68, 0.2); }
.msg { min-height: 1.5em; margin-top: 10px; font-size: 14px; text-align: center; color: var(--wax); }
.msg.ok { color: var(--ok); }
.nocode { margin-top: 26px; text-align: center; }
.nocode h2 { font-size: 16px; font-weight: 650; }
.nocode p { font-size: 15px; color: var(--ink); margin-top: 4px; }

/* ---------- 体验编辑页 ---------- */
.notice {
  position: sticky; top: 0; z-index: 20; margin: 0 -20px; padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: #fbf1d8; border-bottom: 1px solid rgba(185, 143, 68, 0.4); font-size: 14px; line-height: 1.5; color: #5a3f12; text-align: center;
}
.notice b { font-weight: 650; }
.notice .left { display: block; font-size: 12px; opacity: .85; font-variant-numeric: tabular-nums; }
.form h2 { font-size: 17px; font-weight: 650; margin: 22px 0 4px; }
.form h2 small { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }
.form label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.field { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; outline: none; }
textarea.field { min-height: 170px; resize: vertical; line-height: 1.7; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.style-item { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 5px 5px 7px; text-align: center; font-size: 11px; line-height: 1.35; color: var(--ink); min-width: 0; }
.style-item img { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; display: block; background: #e9e2d4; margin-bottom: 5px; }
.style-item.on { border-color: var(--wax); box-shadow: 0 0 0 2px rgba(165, 48, 43, 0.28); background: #fff6f0; }
.font-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.font-item { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 4px 8px; text-align: center; font-size: 12px; color: var(--muted); }
.font-item b { display: block; font-weight: 400; font-size: 24px; line-height: 1.25; color: #1a1a1a; }
.font-item.on { border-color: var(--wax); box-shadow: 0 0 0 2px rgba(165, 48, 43, 0.28); }
.f-mashan { font-family: "YfxMashan", serif; }
.f-longcang { font-family: "YfxLongcang", serif; }
.f-zhimang { font-family: "YfxZhimang", serif; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px dashed rgba(58, 42, 27, 0.3); background: #fff; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 15px; line-height: 1; z-index: 2; }
.caps { display: grid; gap: 8px; margin-top: 10px; }
.caps .cap { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; }
.caps .cap img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
/* 封面配图 */
.cover-row { display: grid; grid-template-columns: 104px 1fr; gap: 12px; align-items: center; }
.cover-row .photo { width: 104px; }
.cover-row .hint { margin: 0; }
/* 小图案画板（画板本身和后台编辑器共用 doodle-board.js） */
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.tiny { min-height: 38px; padding: 6px 14px; font-size: 13px; letter-spacing: .02em; box-shadow: none; }
.btn.tiny.ghost { box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: #fff; color: var(--wax); box-shadow: inset 0 0 0 1px rgba(165, 48, 43, 0.4); }
.doodle-gallery { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.doodle-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 6px 2px; font-size: 11px; color: var(--muted);
}
.doodle-item:active { border-color: var(--wax); }
.doodle-item img { width: 44px; height: 44px; object-fit: contain; pointer-events: none; }
.doodle-stage-wrap { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; touch-action: none; }
.doodle-stage { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; touch-action: none; }
.doodle-tools { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.form .doodle-tools label { flex: 1; margin: 0; display: flex; align-items: center; gap: 8px; }
.doodle-tools input[type=range] { flex: 1; min-width: 0; }
/* 二维码样式 */
.shell-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.shell-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 5px 5px 7px; font-size: 12px; color: var(--ink);
}
.shell-item img { width: 100%; height: auto; aspect-ratio: 1080 / 1560; object-fit: cover; border-radius: 8px; background: #f6f1e8; pointer-events: none; }
.shell-item.on { border-color: var(--wax); box-shadow: 0 0 0 2px rgba(165, 48, 43, 0.28); background: #fff6f0; }
.submit { margin-top: 26px; }
.result { margin-top: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px; text-align: center; }
.result + .result { margin-top: 12px; }
.result h3 { font-size: 17px; font-weight: 650; }
.result h3 i { font-style: normal; color: var(--wax); }
.result .url { display: block; margin-top: 6px; font-size: 13px; color: #6b4a1b; word-break: break-all; }
.result img.qr { display: block; width: 100%; max-width: 250px; margin: 12px auto 4px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.result .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.done-note { margin-top: 18px; text-align: center; font-size: 14px; color: var(--muted); }

@media (min-width: 700px) {
  .hero h1 { font-size: 76px; }
  .modal { place-items: center; }
  .sheet { border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .slide, .btn, .modal, .sheet, .toast { transition: none; }
}
