/* 编辑器：浅色、干净。左工具栏 / 中间预览 / 右面板 */
:root {
  --ui: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --ink: #1d1b18; --mute: #8b857c; --line: #ebe7e0; --soft: #f6f4f0; --bg: #fbfaf8; --accent: #1d1b18;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .4 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body.ed { font: 14px/1.5 var(--ui); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; cursor: pointer; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.top { height: 56px; flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.back { display: flex; align-items: center; gap: 4px; color: var(--ink); text-decoration: none; font-weight: 600; justify-self: start; }
.back svg { width: 18px; height: 18px; }
.steps { display: flex; align-items: center; gap: 6px; }
.steps button { border: 0; background: none; padding: 6px 6px; color: var(--mute); font-size: 13px; display: flex; align-items: center; gap: 6px; border-radius: 8px; }
.steps button:hover { background: var(--soft); }
.steps button b { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: #ece8e1; color: #7d776e; }
.steps button.done b { background: #e3dccd; color: #6b5a33; }
.steps button.on { color: var(--ink); font-weight: 600; }
.steps button.on b { background: var(--ink); color: #fff; }
.steps i { width: 14px; height: 1px; background: #d9d3c9; }
.count { justify-self: end; color: var(--mute); font-size: 12px; }
.pill { justify-self: end; height: 34px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 500; }
.pill.big { width: 100%; height: 46px; border-radius: 12px; font-size: 15px; margin-top: 18px; }
.pill:disabled { opacity: .55; }

.body { flex: 1; display: flex; min-height: 0; }

.canvas { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; background: #f3f1ec; }
.stagebox { height: min(100%, 820px); width: min(100%, 900px); max-width: 100%; border-radius: 18px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 20px 50px rgba(60,40,20,.1); background: #ece7df; flex: 1 1 auto; min-height: 0; }
.stagebox iframe { width: 100%; height: 100%; border: 0; display: block; }
.seeing { flex: none; height: 18px; font-size: 12px; color: var(--mute); }
.grip { display: none; }

.panel { width: 360px; flex: none; border-left: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.pbody { flex: 1; overflow-y: auto; padding: 20px 18px 30px; }
.nav { flex: none; display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--bg); }
.nav .pill { flex: 1; height: 42px; font-size: 14px; }
.ghost { height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px; }
.ghost.wide { width: 100%; margin-top: 12px; }
.link-btn { display: block; margin: 14px auto 0; border: 0; background: none; color: var(--mute); font-size: 12px; text-decoration: underline; }
.grp { border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 0; margin-bottom: 14px; background: #fff; }
.grp > b { display: block; font-size: 12px; color: #8b6a2e; font-weight: 600; margin-bottom: 10px; }
.panel h3 { font-size: 13px; margin: 20px 0 8px; }
.check em[data-goto] { cursor: pointer; text-decoration: underline; }
.pcs { display: flex; flex-direction: column; gap: 8px; }
.pc { border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.pc.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.pch { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; }
.pch img { width: 40px; height: 40px; object-fit: contain; }
.pch span { flex: 1; font-size: 13px; }
.pch button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: #6f6a62; font-size: 15px; }
.pch button:hover { background: var(--soft); }
.pcc { padding: 2px 12px 12px; }
.pcc label { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #5b564f; }
.pcc label span { width: 28px; flex: none; }
.pcc input { flex: 1; accent-color: var(--ink); }
.libg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.libg button { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px 4px 6px; font-size: 11px; color: #5b564f; }
.libg button:hover { border-color: #bdb6ab; }
.libg img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; margin-bottom: 4px; }
.panel h2 { font-size: 15px; margin: 0 0 2px; }
.panel .sub { color: var(--mute); font-size: 12px; margin: 0 0 16px; }
.panel h2 + :not(.sub) { margin-top: 16px; }

.tpls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tpl { border: 0; background: none; padding: 0; text-align: left; }
.tpl img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; display: block; box-shadow: 0 0 0 1px rgba(0,0,0,.06); transition: .2s; }
.tpl span { display: block; font-size: 12px; color: #5b564f; margin-top: 6px; }
.tpl.on img { box-shadow: 0 0 0 2px var(--ink), 0 8px 20px rgba(0,0,0,.12); }
.tpl.on span { color: var(--ink); font-weight: 600; }

.f { display: block; margin-bottom: 16px; }
.f > span { display: flex; justify-content: space-between; font-size: 12px; color: #5b564f; margin-bottom: 6px; }
.f em { font-style: normal; color: var(--mute); }
.f input, .f textarea, .link input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 11px; font: 15px/1.65 "LXGW WenKai Screen", var(--ui); color: var(--ink); outline: none; resize: vertical; }
.f input:focus, .f textarea:focus { border-color: #bdb6ab; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }

.phs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border: 1px dashed #d3cdc3; border-radius: 10px; display: grid; place-items: center; cursor: pointer; overflow: hidden; background: #fff; color: var(--mute); font-size: 20px; }
.ph.has { border-style: solid; border-color: transparent; }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph .rm { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; line-height: 1; }


.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 12px; text-align: left; }
.row i { width: 26px; height: 26px; border-radius: 8px; background: var(--soft); display: grid; place-items: center; font-style: normal; font-size: 13px; }
.row span { flex: 1; }
.row em { font-style: normal; font-size: 11px; color: var(--mute); }
.row.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.row.on i { background: var(--ink); color: #fff; }

.skins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.skin { border: 0; background: none; padding: 0; font-size: 12px; color: #5b564f; }
.skin i { display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: 10px; margin-bottom: 6px; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.skin b { width: 46%; aspect-ratio: .82; display: grid; place-items: center; border-radius: 4px; font: 20px Didot, Georgia, serif; box-shadow: 0 2px 5px rgba(0,0,0,.25); }
.skin.on i { box-shadow: 0 0 0 2px var(--ink); }
.skin.on { color: var(--ink); font-weight: 600; }

.days { display: flex; flex-direction: column; gap: 8px; }
.day { display: grid; grid-template-columns: 22px 1fr 52px; gap: 8px; align-items: center; }
.day b { font: 17px Didot, Georgia, serif; color: #9b2f2a; text-align: right; }
.day textarea { border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; font: 14px/1.5 "LXGW WenKai Screen", var(--ui); resize: none; outline: none; }
.day .ph { width: 52px; font-size: 16px; }

.check { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.check div { display: flex; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.check div:first-child { border-top: 0; }
.check span { width: 56px; flex: none; color: var(--mute); }
.check b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check em { font-style: normal; color: #c0392b; font-weight: 400; }
#result .qr { width: 160px; margin: 22px auto 14px; }
#result .qr svg { width: 100%; height: auto; display: block; }
.link { display: flex; gap: 6px; }
.link input { font: 12.5px var(--ui); padding: 8px 10px; }
.link button { flex: none; border: 0; border-radius: 10px; background: var(--ink); color: #fff; padding: 0 14px; font-size: 13px; }
.open { display: block; text-align: center; margin: 12px 0 0; color: var(--ink); font-size: 13px; }
.editlink { margin-top: 22px; font-size: 12px; color: var(--mute); }
.editlink span { display: block; margin-bottom: 6px; }
.err { color: #c0392b; }
#toast { position: fixed; left: 50%; top: 66px; transform: translate(-50%, -10px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: .25s; z-index: 60; pointer-events: none; }
#toast.in { opacity: 1; transform: translate(-50%, 0); }

/* 手机：上面预览（跟着滚）/ 下面面板 / 底部固定 上一步·下一步 */
@media (max-width: 860px), (max-aspect-ratio: 4/5) {
  body.ed { overflow: visible; height: auto; min-height: 100%; display: block; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .top { position: sticky; top: 0; z-index: 10; padding: 0 10px; grid-template-columns: 32px 1fr 0; }
  .back span { display: none; }
  .steps { justify-self: center; gap: 2px; }
  .steps button { padding: 4px 3px; }
  .steps button span { display: none; }
  .steps button.on span { display: inline; }
  .steps i { width: 6px; }
  .count { display: none; }
  .body { display: block; }
  .canvas { height: 46vh; height: 46svh; height: calc(var(--vh, 1svh) * 54); padding: 8px 12px 6px; gap: 4px; position: sticky; top: 56px; z-index: 5; flex: none; }
  .stagebox { flex: 1 1 auto; height: auto; min-height: 0; border-radius: 14px; }
  .seeing { height: 16px; font-size: 11px; }
  .grip { display: flex; flex: none; width: 100%; height: 22px; align-items: center; justify-content: center; touch-action: none; cursor: ns-resize; margin-bottom: -6px; }
  .grip i { width: 44px; height: 5px; border-radius: 3px; background: #cfc8bd; transition: .15s; }
  .grip.on i { background: var(--ink); width: 60px; }
  .panel { width: auto; border-left: 0; display: block; min-height: 0; }
  .pbody { overflow: visible; padding: 12px 14px 20px; }
  .panel h2 { font-size: 14px; }
  .panel .sub { margin-bottom: 10px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0,0,0,.05); }
  .tpls { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .tpl span { font-size: 11px; }
  .libg { grid-template-columns: repeat(4, 1fr); }
  .f input, .f textarea { font-size: 16px; }          /* iOS 小于 16px 会自动放大页面 */
}

/* ───── 首页 ───── */
body.home { margin: 0; font: 14px/1.6 var(--ui); color: var(--ink); background: var(--bg); }
.hero { text-align: center; padding: 72px 20px 36px; }
.hero .en { font: italic 20px Didot, "Bodoni 72", Georgia, serif; color: #8b6a2e; }
.hero h1 { font: 600 38px/1.3 "LXGW WenKai Screen", "Songti SC", serif; letter-spacing: .18em; margin: 10px 0 12px .18em; }
.hero p { color: var(--mute); margin: 0; }
.picks { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; padding: 10px 20px 48px; }
.pick { width: 300px; text-decoration: none; color: inherit; }
.pick .shot { height: 470px; border-radius: 20px; overflow: hidden; background: #ece7df; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 20px 50px rgba(60,40,20,.12); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.pick:hover .shot { transform: translateY(-6px); }
.pick iframe { width: 100%; height: 100%; border: 0; pointer-events: none; }
.pick h2 { font-size: 17px; margin: 16px 0 2px; }
.pick p { margin: 0; color: var(--mute); font-size: 13px; }
.pick .cta { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; }
.mine { max-width: 640px; margin: 0 auto; padding: 0 20px 60px; }
.mine h3 { font-size: 13px; color: var(--mute); font-weight: 500; }
.mine a { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.mine a span { color: var(--mute); }

/* 上传图片：自动抠图 + 滤镜 */
.popt { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 10px; }
.tog { align-self: flex-start; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; font-size: 12.5px; color: #4c4741; }
.tog i { width: 30px; height: 18px; border-radius: 9px; background: #ddd7cd; position: relative; transition: .2s; }
.tog i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tog.on i { background: var(--ink); }
.tog.on i::after { left: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 12px; color: #5b564f; }
.chips button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.ph.has img { object-fit: contain; background: #f1ede6; }
.eggs { margin-top: 18px; }
.eggs h3 { margin: 0 0 8px; }
.egg { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.egg b { font-weight: 600; }
.egg span { grid-column: 1; color: var(--mute); font-size: 12px; }
.egg button { grid-column: 2; grid-row: 1 / span 2; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12px; }
.pick .shot img { width: 100%; height: 100%; object-fit: cover; display: block; }

.libhead { display: flex; justify-content: space-between; align-items: flex-start; position: sticky; top: -20px; background: var(--bg); padding: 4px 0 8px; z-index: 2; }
.libhead .pill { height: 32px; }
.libg button.added { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }

@media (max-width: 860px), (max-aspect-ratio: 4/5) {
  body.immersive .seeing { display: none; }
  body.immersive .canvas { padding: 6px 6px 2px; }
}

/* 摆件：一行小卡片，选中的调节放下面 */
.pcs { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.pc { width: calc(25% - 6px); min-width: 70px; padding: 0; text-align: center; }
.pc .pch { flex-direction: column; gap: 4px; padding: 8px 4px 6px; }
.pc .pch img { width: 46px; height: 46px; }
.pc .pch span { font-size: 11px; line-height: 1.25; }
.pc.add { border-style: dashed; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #6f6a62; font-size: 11px; }
.pc.add b { font-size: 20px; font-weight: 400; }
.pcc { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.pcct { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pcct b { flex: 1; }
.pcct button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.hint { color: var(--mute); font-size: 12px; margin: 10px 0 0; }
/* 音乐、飘落：横排小按钮 */
.list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.row { padding: 7px 11px; border-radius: 999px; gap: 6px; font-size: 13px; }
.row i { width: 20px; height: 20px; border-radius: 50%; font-size: 11px; }
.row span { flex: none; }
.row em { display: none; }

/* 照片：处理中 / 抠图原图切换 / 最近的照片 */
.ph .spin { display: none; position: absolute; inset: 0; background: rgba(251,250,248,.9); flex-direction: column; align-items: center; justify-content: center; gap: 6px; z-index: 2; }
.ph.busy .spin { display: flex; }
.ph .spin b { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid #e3ddd3; border-top-color: var(--ink); animation: spin .8s linear infinite; }
.ph .spin em { font-style: normal; font-size: 11px; color: #6f6a62; }
@keyframes spin { to { transform: rotate(360deg); } }
.ph .swap { position: absolute; left: 4px; bottom: 4px; border: 0; border-radius: 999px; background: rgba(29,27,24,.72); color: #fff; font-size: 10.5px; padding: 3px 7px; z-index: 1; }
.hist { margin-top: 12px; }
.hist > span { display: block; font-size: 12px; color: var(--mute); margin-bottom: 6px; }
.hist > div { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.hist button { flex: none; width: 54px; height: 54px; border: 1px solid var(--line); border-radius: 8px; padding: 0; background: #f1ede6; overflow: hidden; }
.hist img { width: 100%; height: 100%; object-fit: contain; }

/* 选图面板：系统图库 + 从相册上传 */
#picker { position: fixed; inset: 0; z-index: 70; background: rgba(20,16,12,.45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .25s; }
#picker.in { opacity: 1; }
#picker[hidden] { display: none; }
.pk { width: min(560px, 100%); max-height: 78vh; background: var(--bg); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; transform: translateY(30px); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
#picker.in .pk { transform: none; }
@media (min-width: 861px) and (min-aspect-ratio: 4/5) { #picker { align-items: center; } .pk { border-radius: 16px; } }
.pkh { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.pkx { border: 0; background: none; font-size: 22px; color: #6f6a62; }
.pkup { margin: 4px 16px 6px; height: 44px; border: 0; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; }
.pkb { overflow-y: auto; padding: 0 16px 20px; }
.pkb h3 { font-size: 12.5px; color: var(--mute); font-weight: 500; margin: 14px 0 8px; }
.pkb .libg { grid-template-columns: repeat(4, 1fr); }
