:root {
  --bg: #F6EDE2;
  --paper: #FFFAF4;
  --ink: #4A3428;
  --muted: #9A8174;
  --rose: #C46F7E;
  --rose-d: #A85566;
  --rose-l: #F6E1E1;
  --line: #E4D3C1;
  --hover: #F0E3D5;
  --gold: #D2B48F;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image: var(--toile);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.logo {
  font-family: Georgia, "Palatino Linotype", "Times New Roman", serif;
  font-weight: 700;
  color: var(--ink);
}
.logo span { color: var(--rose); }

/* 开场 */
.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, #FFFBF6 0, rgba(246, 237, 226, 0) 62%);
}
#introCake {
  width: min(58vmin, 420px);
  height: min(58vmin, 420px);
  animation: float 3.4s ease-in-out infinite;
}
.intro .logo { margin: 6px 0 0; font-size: clamp(44px, 8vmin, 76px); }
.tagline { margin: 8px 0 28px; color: var(--muted); font-size: 17px; }

/* 开场飘落的玫瑰花瓣:外层往下落,里层左右摆和翻转。在文字和按钮后面,不接点击 */
.petals { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.intro > :not(.petals):not(.corner) { position: relative; z-index: 1; }
.petals i {
  position: absolute;
  top: -6%;
  animation-name: petal-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.petals i b {
  display: block;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  animation: petal-sway 3.2s ease-in-out infinite alternate;
}
@keyframes petal-fall {
  to { transform: translateY(112vh); }
}
@keyframes petal-sway {
  from { transform: translateX(-14px) rotate(-25deg); }
  to { transform: translateX(14px) rotate(35deg); }
}
@media (prefers-reduced-motion: reduce) {
  .petals { display: none; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* 复古玫瑰装饰:藤蔓花边、画框、四角玫瑰。图案由 decor.js 生成后塞进 CSS 变量 */
.app::before, .nav::before {
  content: "";
  display: block;
  height: 30px;
  background-image: var(--garland);
  background-repeat: repeat-x;
  background-position: center;
  pointer-events: none;
}
.app::before { flex: none; margin-top: 6px; }

.stage-frame {
  position: absolute;
  inset: 10px;
  z-index: 2;
  border: 1px solid var(--gold);
  border-radius: 26px;
  outline: 1px solid var(--gold);
  outline-offset: -6px;
  pointer-events: none;
}
.corner { position: absolute; z-index: 2; width: 150px; height: 150px; pointer-events: none; }
.corner svg { display: block; width: 100%; height: 100%; }
.corner.tl { top: 0; left: 0; }
.corner.tr { top: 0; right: 0; transform: scaleX(-1); }
.corner.bl { bottom: 0; left: 0; transform: scaleY(-1); }
.corner.br { bottom: 0; right: 0; transform: scale(-1, -1); }
.intro .corner { position: fixed; width: min(28vmin, 220px); height: min(28vmin, 220px); }

.label::before, .tag::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  background: var(--bud) center / contain no-repeat;
}
.tag::before { width: 16px; height: 16px; vertical-align: -3px; }

/* 主界面 */
.app { height: 100%; display: flex; flex-direction: column; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 6px 40px 4px;
}
.tag { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--rose); }
.title { margin: 4px 0 6px; font-size: 30px; font-weight: 700; }
.hint { margin: 0; font-size: 14px; color: var(--muted); }

.steps { list-style: none; display: flex; gap: 14px; margin: 6px 0 0; padding: 0; }
.steps li {
  min-width: 26px;
  padding: 4px 2px 6px;
  border-bottom: 2px solid var(--line);
  text-align: center;
  font-size: 13px;
  color: #C2AFA3;
}
.steps li.done { color: var(--muted); border-color: #CDB8AA; }
.steps li.on { color: var(--ink); font-weight: 700; border-color: var(--rose); }

.main { flex: 1; min-height: 0; display: flex; gap: 24px; padding: 8px 40px 0; }

.panel { width: 300px; flex-shrink: 0; overflow-y: auto; padding: 6px 8px 16px 0; }

.stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  background: radial-gradient(circle at 50% 52%, #FFFBF7 0%, rgba(255, 251, 247, 0) 60%);
}
#stage {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.stage-wrap[data-tool] #stage { cursor: none; }
.item { cursor: grab; }

.label { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--muted); }
.group { margin-bottom: 22px; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 4px; }
.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px 2px;
  border: 0;
  border-radius: 14px;
  background: none;
  font-size: 13px;
  cursor: pointer;
}
.swatch i {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(74, 52, 40, .1);
}
.swatch:hover { background: var(--hover); }
.swatch.on { font-weight: 700; }
.swatch.on i { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--rose); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: none;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.pill:hover { background: var(--hover); }
.pill.on { border-color: var(--rose); background: var(--rose-l); color: var(--rose-d); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px 6px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: none;
  font-size: 12px;
  cursor: pointer;
  touch-action: none;
}
.tile svg { width: 56px; height: 46px; pointer-events: none; }
.grid.four .tile svg { width: 46px; height: 38px; }
.tile span { pointer-events: none; }
.tile:hover { background: var(--hover); }
.tile.on { border-color: var(--rose); background: var(--paper); font-weight: 700; }

.dots { display: flex; flex-wrap: wrap; gap: 10px; }
.dot {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(74, 52, 40, .14);
  cursor: pointer;
}
.dot.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--rose); }

input[type=range] { width: 100%; accent-color: var(--rose); }

.meter { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.meter .track { flex: 1; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter .bar { height: 100%; border-radius: 99px; background: var(--rose); transition: width .15s; }
.meter b { width: 44px; text-align: right; font-size: 14px; color: var(--rose-d); }

.field { display: flex; gap: 8px; }
.field input, input.name {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  outline: none;
}
.field input:focus, input.name:focus { border-color: var(--rose); }
input.name { width: 100%; margin-bottom: 14px; }
.note { margin: 0 0 18px; font-size: 13px; line-height: 1.6; color: var(--muted); }

.btn {
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #FFF8F1;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s, opacity .2s;
}
.btn:hover { background: #5E4537; }
.btn:active { transform: scale(.97); }
.btn.wait { opacity: .45; }

.link {
  padding: 4px 0 3px;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  background: none;
  font-size: 15px;
  cursor: pointer;
}

.text-btn {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--rose-d);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.nav {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 34px 40px 20px;
}
.nav::before { position: absolute; top: 2px; left: 0; right: 0; transform: scaleY(-1); }
.nav #prevBtn { justify-self: start; }
.nav #nextBtn { justify-self: end; }

/* 底部中间的小开关:音乐、背景、重新开始 */
.opts { display: flex; align-items: center; gap: 20px; }
.opt, .opt-group {
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--muted);
  white-space: nowrap;
}
.opt { cursor: pointer; }
.more, .tabs { display: none; }
.opt:hover { color: var(--ink); }
.opt-group { display: flex; align-items: center; gap: 7px; }
.bgdot {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(74, 52, 40, .18);
  cursor: pointer;
}
.bgdot.rose { background-image: var(--bud); background-size: 15px; background-position: center; background-repeat: no-repeat; }
.bgdot.plaid {
  background-image:
    linear-gradient(90deg, rgba(196, 111, 126, .38) 50%, transparent 50%),
    linear-gradient(rgba(196, 111, 126, .38) 50%, transparent 50%);
  background-size: 8px 8px;
}
.bgdot.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--rose); }

/* 背景选项二:复古格纹。格子尺寸和 decor.js 里存图用的 plaidBody 一致 */
body.bg-plaid {
  background-image:
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(210, 180, 143, .4) 6px 7px, transparent 7px 40px),
    repeating-linear-gradient(0deg, transparent 0 6px, rgba(210, 180, 143, .4) 6px 7px, transparent 7px 40px),
    repeating-linear-gradient(90deg, transparent 0 27px, rgba(141, 162, 123, .3) 27px 28px, transparent 28px 40px),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(141, 162, 123, .3) 27px 28px, transparent 28px 40px),
    repeating-linear-gradient(90deg, rgba(196, 111, 126, .13) 0 14px, transparent 14px 40px),
    repeating-linear-gradient(0deg, rgba(196, 111, 126, .13) 0 14px, transparent 14px 40px);
}

/* 选中装饰后的小工具条 */
.item-bar {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 14px;
  max-width: calc(100% - 320px);
  padding: 10px 16px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 6px 20px rgba(74, 52, 40, .12);
}
.item-bar label, .item-bar .stepper, .item-bar .dots { white-space: nowrap; }
.item-bar label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.item-bar input[type=range] { width: 84px; }
.item-bar .dots { flex-wrap: nowrap; gap: 8px; }
.item-bar .dot { width: 22px; height: 22px; }
.item-bar .bar-text {
  width: 110px;
  padding: 5px 9px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #FFFFFF;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.item-bar .bar-text:focus { border-color: var(--rose); }
.item-bar .fonts { display: flex; gap: 4px; }
.item-bar .fonts button {
  padding: 4px 9px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: none;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.item-bar .fonts button.on { border-color: var(--rose); background: var(--rose-l); color: var(--rose-d); font-weight: 700; }
.item-bar .stepper { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.item-bar .stepper button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: none;
  line-height: 1;
  cursor: pointer;
}
.item-bar .stepper b { min-width: 12px; text-align: center; }
.item-bar .del { padding: 0; border: 0; background: none; color: var(--rose-d); font-weight: 700; cursor: pointer; }

/* 完成时的效果 */
.stage-wrap.celebrate::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 46%, rgba(255, 255, 255, .9), rgba(255, 251, 247, 0) 58%);
  animation: glow 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glow {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

.flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flick .45s ease-in-out infinite alternate;
}
@keyframes flick {
  from { transform: scale(1, 1); }
  to { transform: scale(.86, 1.12); }
}

.pop {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: pop .38s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes pop {
  from { transform: scale(.2); opacity: .3; }
  to { transform: scale(1); opacity: 1; }
}

/* 完成页的照片预览盖在舞台上,蛋糕本体还留着给预览引用花纹 */
#framePrev { position: absolute; inset: 8px; z-index: 1; width: calc(100% - 16px); height: calc(100% - 16px); pointer-events: none; filter: drop-shadow(0 6px 14px rgba(74, 52, 40, .16)); }
.stage-wrap.framed #stage { opacity: 0; }
.stage-wrap.framed .stage-frame, .stage-wrap.framed .corner { display: none; }

/* 抹奶油的反馈:奶油屑落下,进度条跳一下,抹满时一道光扫过、冒星星 */
.crumb { transform-box: fill-box; transform-origin: center; animation: crumb .7s ease-in forwards; }
@keyframes crumb {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.5); }
}
.spark { transform-box: fill-box; transform-origin: center; opacity: 0; animation: spark 1.1s ease-out forwards; }
@keyframes spark {
  0% { opacity: 0; transform: scale(.2); }
  35% { opacity: 1; transform: scale(1.3) rotate(25deg); }
  100% { opacity: 0; transform: scale(.6) rotate(60deg); }
}
.meter .bar.bump { animation: bump .45s ease-out; }
@keyframes bump {
  0% { box-shadow: 0 0 0 0 rgba(224, 115, 138, .55); }
  100% { box-shadow: 0 0 0 7px rgba(224, 115, 138, 0); }
}
.stage-wrap.shine::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, .7) 50%, rgba(255, 255, 255, 0) 65%);
  background-size: 250% 100%;
  animation: shine 1.2s ease-in-out forwards;
}
@keyframes shine {
  from { background-position: 120% 0; }
  to { background-position: -20% 0; }
}

.confetti { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -6%;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  animation-name: fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes fall {
  to { top: 106%; transform: rotate(var(--r)); }
}

.toast {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 8px;
  transform: translate(-50%, -10px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFF8F1;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 手机上保存图片:弹出照片,长按保存 */
.photo {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(74, 52, 40, .55);
}
.photo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  padding: 16px 16px 18px;
  border-radius: 22px;
  background: var(--paper);
}
.photo-card img {
  display: block;
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 14px;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
.photo-card p { margin: 0; font-size: 14px; color: var(--muted); }

/* 烘焙小游戏 */
.bake { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(74, 52, 40, .55); }
.bake-card { width: 100%; max-width: 520px; padding: 18px 22px 20px; border-radius: 22px; background: var(--paper); }
.bake-card .title { font-size: 22px; }
#bakeStage { display: block; width: 100%; height: auto; aspect-ratio: 400 / 290; margin: 6px 0 10px; touch-action: none; cursor: grab; }
.bake-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* 顾客订单 */
.order { margin-bottom: 18px; padding: 12px 14px; border-radius: 16px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); }
.order-who { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.order-who b { font-size: 14px; color: var(--rose-d); }
.order-who span { font-size: 12px; color: var(--muted); }
.order ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.order li { position: relative; padding-left: 20px; font-size: 13px; }
.order li::before { content: ""; position: absolute; left: 0; top: 2px; width: 12px; height: 12px; border: 1.5px solid var(--line); border-radius: 50%; }
.order li.ok { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(154, 129, 116, .5); }
.order li.ok::before { border-color: #8DA27B; background: #8DA27B; box-shadow: inset 0 0 0 2px var(--paper); }
.rating { margin-bottom: 16px; padding: 12px 14px; border-radius: 16px; background: #FFF6E8; text-align: center; }
.stars { font-size: 24px; letter-spacing: 3px; color: #D9A441; }
.stars i { font-style: normal; color: #E6D6C8; }
.rating p { margin: 4px 0 0; font-size: 14px; color: var(--ink); }
.rating .from { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.intro-album + .intro-album { margin-top: 8px; }

/* 蛋糕册 */
.intro-album { margin-top: 18px; }
.album {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(74, 52, 40, .55);
}
.album-card {
  width: 100%;
  max-width: 760px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px 22px;
  border-radius: 22px;
  background: var(--paper);
}
.album-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.album-head h2 { margin: 0; font-size: 20px; }
.album-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.album-item { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; background: #FFFFFF; box-shadow: 0 2px 8px rgba(74, 52, 40, .08); }
.album-item img { display: block; width: 100%; border-radius: 12px; }
.album-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; }
.album-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-meta span { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.album-item .pills { gap: 6px; }
.album-item .pill { padding: 6px 12px; font-size: 13px; }

/* 竖屏和手机 */
/* 手机竖屏一屏放下,不让页面上下滚:标题一行,蛋糕占中间,选项分标签放下面,底栏收窄 */
@media (max-width: 860px) {
  .app { height: 100vh; height: 100dvh; overflow: hidden; }
  .app::before { height: 18px; margin-top: 2px; background-size: auto 18px; }
  .top { flex: none; align-items: center; gap: 10px; padding: 2px 14px 0; }
  .heading { min-width: 0; }
  .tag { display: none; }
  .title { margin: 0; font-size: 18px; }
  .hint { font-size: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .steps { flex: none; gap: 6px; margin: 0; }
  .steps li { min-width: 16px; padding: 2px 1px 3px; font-size: 12px; }
  .corner { width: 64px; height: 64px; }
  .stage-frame { inset: 4px; border-radius: 18px; outline-offset: -5px; }
  .main { flex-direction: column; gap: 4px; padding: 4px 10px 0; }
  .stage-wrap { order: -1; flex: 1 1 0; min-height: 180px; }
  .panel { flex: none; width: auto; max-height: 38%; overflow-y: auto; padding: 0 2px 4px; }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-bottom: 8px;
    padding: 4px 0;
    background: var(--bg);
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button {
    flex: none;
    padding: 5px 12px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: none;
    font: inherit;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
  }
  .tabs button.on { border-color: var(--rose); background: var(--rose-l); color: var(--rose-d); font-weight: 700; }
  .group.off { display: none; }
  .tabs ~ .group:not(.pin) > .label { display: none; }
  .group { margin-bottom: 10px; }
  .label { margin-bottom: 6px; }
  .note { margin-bottom: 8px; font-size: 12px; }
  .order { margin-bottom: 8px; padding: 8px 12px; }
  .order ul { grid-template-columns: 1fr 1fr; gap: 3px 10px; }

  /* 色块和图块排成一行左右滑,竖着拖还能把装饰拖到蛋糕上 */
  .swatches, .grid, .grid.four { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; touch-action: pan-x; scrollbar-width: none; }
  .panel, .swatches, .grid { scrollbar-width: none; }
  .panel::-webkit-scrollbar, .swatches::-webkit-scrollbar, .grid::-webkit-scrollbar { display: none; }
  .swatch, .tile { flex: none; min-width: 70px; }

  .hscroll { position: relative; --fl: 0px; --fr: 0px; }
  .hscroll.has-more:not(.at-start) { --fl: 30px; }
  .hscroll.has-more:not(.at-end) { --fr: 40px; }
  .hscroll > .swatches, .hscroll > .grid {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
  }
  .harrow, .hbar { display: none; }
  .hscroll.has-more .harrow {
    position: absolute;
    top: calc(50% - 20px);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0 0 3px;
    border: 1.5px solid var(--line);
    border-radius: 50%;
    background: var(--paper);
    box-shadow: 0 2px 6px rgba(74, 52, 40, .14);
    font-size: 22px;
    line-height: 1;
    color: var(--rose-d);
    cursor: pointer;
    transition: opacity .2s;
  }
  .harrow.l { left: 0; }
  .harrow.r { right: 0; }
  .hscroll.at-start .harrow.l, .hscroll.at-end .harrow.r { opacity: 0; pointer-events: none; }
  .hscroll.has-more .hbar { position: relative; display: block; height: 4px; margin: 4px 28% 0; border-radius: 2px; background: var(--line); }
  .hbar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--rose); }

  .item-bar { bottom: 6px; flex-wrap: wrap; justify-content: center; gap: 8px 10px; max-width: calc(100% - 16px); padding: 6px 10px; white-space: normal; }

  .nav {
    flex: none;
    grid-template-columns: 1fr auto 1fr;
    padding: 6px 14px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--bg);
  }
  .nav::before { display: none; }
  .nav .btn { padding: 9px 20px; font-size: 15px; }
  .nav .link { font-size: 14px; }
  .more {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    box-shadow: 0 1px 4px rgba(74, 52, 40, .1);
    font-size: 13px;
    color: var(--ink);
    transition: border-color .15s, background .15s;
  }
  .more::after { content: "▴"; font-size: 11px; color: var(--rose); transition: transform .2s; }
  .nav.open .more { border-color: var(--rose); background: var(--rose-l); color: var(--rose-d); font-weight: 700; }
  .nav.open .more::after { transform: rotate(180deg); }
  .opts {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    z-index: 6;
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding: 12px;
    border: 1.5px solid var(--line);
    border-radius: 18px;
    background: var(--paper);
    box-shadow: 0 6px 20px rgba(74, 52, 40, .18);
    transform: translateX(-50%);
  }
  .opts::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 12px;
    height: 12px;
    border-right: 1.5px solid var(--line);
    border-bottom: 1.5px solid var(--line);
    background: var(--paper);
    transform: translateX(-50%) rotate(45deg);
  }
  .nav.open .opts { display: flex; animation: menu-pop .18s ease-out; }
  .opts .opt, .opts .opt-group {
    padding: 7px 14px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: #FFFFFF;
    font-size: 13px;
    letter-spacing: .04em;
    color: var(--ink);
  }
  .opts .opt-group { padding: 4px 8px 4px 14px; }
  .more:active, .opts .opt:active, .bgdot:active, .harrow:active, .tabs button:active { transform: scale(.94); }
  .opts .opt:active { border-color: var(--rose); background: var(--rose-l); }
}
@keyframes menu-pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 手机横过来高度太矮,改回左右排 */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .app { height: 100vh; height: 100dvh; overflow: hidden; }
  .main { flex-direction: row; }
  .stage-wrap { order: 0; min-height: 0; }
  .panel { width: 280px; max-height: none; }
  .top .hint { display: none; }
}
