/* 蛋糕预订点单 —— 移动优先
   配色取自烘焙/咖啡类暖色系；字体用系统栈：
   微信里拉 fonts.googleapis.com 经常超时，系统字体反而更稳也更快。
   触摸目标一律 >= 44px，尊重安全区。 */

:root {
  --bg: #FFFBF5;
  --bg-soft: #FEF3C7;
  --card: #FFFFFF;
  --ink: #3F2410;
  --ink-strong: #78350F;
  --muted: #8A7563;
  --primary: #92400E;
  --primary-ink: #FFFFFF;
  --primary-soft: #FDF0DC;
  --accent: #B45309;
  --border: #F0E2CE;
  --border-strong: #FDE68A;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --ok: #15803D;
  --info: #0369A1;
  --warn: #C2410C;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --shadow: 0 2px 10px rgba(120, 53, 15, .06);
  --shadow-up: 0 -4px 20px rgba(120, 53, 15, .10);
  --tap: 44px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { padding-bottom: calc(84px + var(--safe-b)); }
body.no-bar { padding-bottom: var(--safe-b); }

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── 顶部 ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + var(--space-3)) var(--space-4) var(--space-3);
  background: linear-gradient(180deg, #FFF7E8, var(--bg));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-3);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; color: var(--ink-strong); letter-spacing: .3px; }
.topbar .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); font-weight: 400; }
.topbar .spacer { flex: 1; }

.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--card);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--primary);
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:active { transform: scale(.94); background: var(--primary-soft); }

/* ── 容器 ── */
.wrap { padding: var(--space-4); max-width: 720px; margin: 0 auto; }
.section-title {
  font-size: 13px; font-weight: 700; color: var(--muted);
  letter-spacing: 1px; margin: var(--space-5) 0 var(--space-3);
  text-transform: uppercase;
}
.section-title:first-child { margin-top: var(--space-2); }

/* ── 商品卡 ── */
.product {
  display: flex; gap: var(--space-3); align-items: stretch;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3);
  margin-bottom: var(--space-3); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease;
}
.product:active { transform: scale(.99); }
.product.off { opacity: .5; }
.product .pic {
  width: 92px; height: 92px; flex: none; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg-soft);
}
.product .pic.empty { display: flex; align-items: center; justify-content: center; color: var(--accent); }
.product .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.product .name { font-size: 16px; font-weight: 700; color: var(--ink-strong); }
.product .desc {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product .price { margin-top: auto; color: var(--danger); font-weight: 700; font-size: 17px; }
.product .price small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.product .badge-lead {
  align-self: flex-start; margin-top: var(--space-2);
  font-size: 11px; color: var(--accent); background: var(--primary-soft);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 8px;
}

/* ── 按钮 ── */
.btn {
  min-height: var(--tap); padding: 0 var(--space-4);
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--primary); color: var(--primary-ink);
  font-weight: 600; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--primary); border-color: var(--border-strong); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 var(--space-3); font-size: 13px; border-radius: 8px; }

/* ── 底部购物车条 ── */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--border);
  box-shadow: var(--shadow-up);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-b));
  display: flex; align-items: center; gap: var(--space-3);
  max-width: 720px; margin: 0 auto;
}
.cartbar .total { flex: 1; min-width: 0; }
.cartbar .total .amt { color: var(--danger); font-size: 20px; font-weight: 700; }
.cartbar .total .hint { font-size: 12px; color: var(--muted); }

/* ── 弹层 ── */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(63, 36, 16, .38);
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-mask.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transform: translateY(102%); transition: transform .24s cubic-bezier(.22,.61,.36,1);
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--space-4) + var(--safe-b));
  max-width: 720px; margin: 0 auto;
}
.sheet.show { transform: translateY(0); }
.sheet-head {
  position: sticky; top: 0; background: var(--card); z-index: 2;
  padding: var(--space-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-3);
}
.sheet-head h2 { margin: 0; font-size: 17px; color: var(--ink-strong); flex: 1; }
.sheet-body { padding: var(--space-4); }

/* ── 规格选项 ── */
.spec-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.spec {
  min-height: var(--tap); padding: 0 var(--space-4);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  transition: all .12s ease;
}
.spec .p { color: var(--danger); font-weight: 700; }
.spec[aria-pressed="true"] {
  border-color: var(--primary); background: var(--primary-soft); color: var(--ink-strong);
}

/* ── 数量步进 ── */
.stepper { display: inline-flex; align-items: center; gap: var(--space-3); }
.stepper button {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--card);
  color: var(--primary); font-size: 20px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.stepper button:active { background: var(--primary-soft); }
.stepper button[disabled] { opacity: .35; }
.stepper .n { min-width: 28px; text-align: center; font-weight: 700; font-size: 17px; }

/* ── 表单 ── */
.field { margin-bottom: var(--space-4); }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-strong); margin-bottom: 6px; }
.field .tip { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap); padding: 10px var(--space-3);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); outline: none; transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(146, 64, 14, .12); }
textarea.input { min-height: 72px; resize: vertical; }
.date-grid, .slot-grid { display: grid; gap: var(--space-2); }
.date-grid { grid-template-columns: repeat(3, 1fr); }
.slot-grid { grid-template-columns: repeat(2, 1fr); }
.choice {
  min-height: var(--tap); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer; padding: var(--space-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; transition: all .12s ease;
}
.choice[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.choice[disabled] { opacity: .38; cursor: not-allowed; text-decoration: line-through; }
.choice .d { font-weight: 700; }
.choice .r { font-size: 11px; color: var(--muted); }

/* ── 提示 ── */
.alert {
  border-radius: var(--radius-sm); padding: var(--space-3); font-size: 13.5px;
  margin-bottom: var(--space-3); border: 1px solid;
}
.alert.err { background: var(--danger-soft); border-color: #FECACA; color: #991B1B; }
.alert.ok { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.alert.info { background: var(--primary-soft); border-color: var(--border-strong); color: var(--ink-strong); }

/* ── 状态标签 ── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.tag.pending { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.tag.confirmed { background: #E0F2FE; color: #075985; border-color: #BAE6FD; }
.tag.making { background: #FFEDD5; color: #9A3412; border-color: #FED7AA; }
.tag.ready { background: #DCFCE7; color: #166534; border-color: #BBF7D0; }
.tag.done { background: #F1F5F9; color: #475569; border-color: #E2E8F0; }
.tag.cancelled { background: #F1F5F9; color: #94A3B8; border-color: #E2E8F0; }

/* ── 订单卡（商家端）── */
.order-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-3); margin-bottom: var(--space-3); box-shadow: var(--shadow);
}
.order-card.unread { border-color: var(--border-strong); border-left: 4px solid var(--accent); }
.order-card .row1 { display: flex; align-items: center; gap: var(--space-2); }
.order-card .code {
  font-size: 20px; font-weight: 800; color: var(--ink-strong);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.order-card .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.order-card .lines { margin: var(--space-3) 0 0; padding: var(--space-2) 0 0; border-top: 1px dashed var(--border); }
.order-card .line { display: flex; justify-content: space-between; font-size: 14px; padding: 2px 0; }
.order-card .line .l { color: var(--ink); }
.order-card .line .r { color: var(--muted); font-variant-numeric: tabular-nums; }
.order-card .remark {
  margin-top: var(--space-2); background: var(--primary-soft); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: 13.5px; color: var(--ink-strong);
}
.order-card .actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

/* ── 汇总条 ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-bottom: var(--space-3); }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-2); text-align: center;
}
.stat .v { font-size: 19px; font-weight: 800; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--muted); }

/* ── 筛选 ── */
.tabs { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-2); -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; min-height: 38px; padding: 0 var(--space-4); border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--muted);
  font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.tab[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab .dot {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700;
}

/* ── 空/加载态 ── */
.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--muted); }
.empty svg { opacity: .5; margin-bottom: var(--space-3); }
.skeleton {
  background: linear-gradient(90deg, #F6EDE0 25%, #EFE3D2 37%, #F6EDE0 63%);
  background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: var(--radius);
  height: 116px; margin-bottom: var(--space-3);
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── 时间线 ── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--space-4) var(--space-5); }
.timeline li::before {
  content: ''; position: absolute; left: 5px; top: 8px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--border-strong);
}
.timeline li.on::before { background: var(--primary); }
.timeline li::after {
  content: ''; position: absolute; left: 9px; top: 20px; bottom: 0; width: 1px; background: var(--border);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline .t { font-weight: 600; color: var(--ink-strong); font-size: 14px; }
.timeline .s { font-size: 12px; color: var(--muted); }

/* ── 商品图片画廊 ── */
.gallery { margin-bottom: var(--space-3); }
.gallery .stage {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-soft); aspect-ratio: 4 / 3; cursor: zoom-in;
}
.gallery .stage img { width: 100%; height: 100%; object-fit: cover; }
.gallery .zoom-hint {
  position: absolute; right: var(--space-2); bottom: var(--space-2);
  background: rgba(63, 36, 16, .62); color: #fff; font-size: 11.5px;
  padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px;
}
.gallery .thumbs { display: flex; gap: var(--space-2); margin-top: var(--space-2); overflow-x: auto; }
.gallery .thumbs img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none;
  border: 2px solid transparent; cursor: pointer;
}
.gallery .thumbs img[aria-current="true"] { border-color: var(--primary); }
.img-fallback { object-fit: contain !important; padding: 6px; }

/* ── 全屏看图（灯箱）── */
.lightbox {
  /* 必须接近不透明：半透明时底下的规格文字会透出来，画面显得很脏 */
  position: fixed; inset: 0; z-index: 90; background: #190D04;
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y; animation: lb-in .18s ease;
}
@keyframes lb-in { from { opacity: 0 } to { opacity: 1 } }
.lightbox .lb-viewport { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lightbox .lb-viewport img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb-close {
  position: absolute; top: calc(var(--safe-t) + 12px); right: 12px;
  width: var(--tap); height: var(--tap); border-radius: 50%;
  background: rgba(0, 0, 0, .45); color: #fff; border: 1px solid rgba(255, 255, 255, .28);
  cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2;
}
.lightbox .lb-count {
  position: absolute; top: calc(var(--safe-t) + 24px); left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px; background: rgba(0, 0, 0, .45); border: 1px solid rgba(255, 255, 255, .28);
  padding: 3px 12px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .45); border: 1px solid rgba(255, 255, 255, .28);
  color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox .lb-nav.prev { left: 10px; }
.lightbox .lb-nav.next { right: 10px; }
.lightbox .lb-nav[hidden] { display: none; }

/* ── 商家端图片管理 ── */
.img-strip { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.img-item { position: relative; width: 72px; height: 72px; margin: 0; }
.img-item img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.img-item .cover-tag {
  position: absolute; left: 0; bottom: 0; font-size: 10px; padding: 1px 5px;
  background: var(--primary); color: #fff; border-radius: 0 6px 0 8px;
}
.img-item .rm {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px;
  border-radius: 50%; border: 0; background: var(--danger); color: #fff;
  font-size: 13px; line-height: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.img-add {
  width: 72px; height: 72px; border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm); background: var(--card); color: var(--primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; cursor: pointer;
}

.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
