html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:root {
  --red: #B3322A; --red-dark: #8E2A1E; --cream: #F6F0E4; --paper: #FFFDF8;
  --ink: #2A211C; --muted: #7A6F66; --line: #EBE3D3; --ok: #2E7D4F; --warn: #B86A00;
  --badge-space: 0px; /* 以前给 Netlify 右下角浮标留的位置；Cloudflare 没有浮标 */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Hiragino Sans GB", "Apple SD Gothic Neo", "Microsoft YaHei", "Malgun Gothic", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", sans-serif; }
body { padding-bottom: calc(150px + var(--badge-space) + env(safe-area-inset-bottom)); }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 12px; }
.hidden { display: none !important; }

header.brand { background: var(--red); color: #FBF6EC; padding: 14px 16px 14px; }
header.brand .wrap { display: flex; align-items: center; gap: 14px; }
header.brand svg { flex-shrink: 0; }
header.brand .brand-name { flex: 1; min-width: 0; font: 600 22px/1.2 "Songti SC", "STSong", "Noto Serif SC", serif; letter-spacing: 2px; }
header.brand .brand-title { display: block; margin-top: 10px; }
header.brand h1 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.4; word-break: break-word; }
header.brand h1.long { font-size: 16px; }
header.brand h1.hidden { display: none; }
header.brand .sub { font-size: 13px; opacity: .85; margin-top: 2px; }

.tabs { display: flex; gap: 6px; padding: 12px 0 4px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px 0; font-size: 15px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--red); border-color: var(--red); font-weight: 600; }

.card { background: var(--paper); border-radius: 14px; padding: 16px; margin: 12px 0; box-shadow: 0 1px 0 var(--line); }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.notice { white-space: pre-wrap; color: var(--ink); font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.closed { color: var(--red); font-weight: 600; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.prod { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.prod:last-child { border-bottom: 0; }
.prod .name { font-weight: 500; }
.price { color: var(--red); font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 20px; line-height: 1; color: var(--ink); }
.stepper button.plus { background: var(--red); border-color: var(--red); color: #fff; }
.stepper input { width: 46px; text-align: center; border: 0; background: transparent; font-size: 16px; }

.field { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field label { min-width: 76px; flex-shrink: 0; white-space: nowrap; color: var(--muted); font-size: 15px; }
.field label.req::after { content: " *"; color: var(--red); }
.field input, .field select, .field textarea { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink); padding: 6px 0; text-align: right; }
.field select { text-align-last: right; appearance: none; -webkit-appearance: none; }
.field input::placeholder, .field textarea::placeholder { color: #B9AFA4; }
.stack { display: block; }
.stack label { display: block; width: auto; margin-bottom: 6px; }
.stack input, .stack textarea, .stack select { width: 100%; text-align: left; background: #F7F2E8; border-radius: 8px; padding: 10px 12px; }

.privacy { text-align: center; color: var(--muted); font-size: 13px; padding: 4px 0 16px; }

.footer { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; box-shadow: 0 -2px 12px rgba(0,0,0,.06); padding: 12px 16px calc(12px + var(--badge-space) + env(safe-area-inset-bottom)); }
.footer .wrap { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 0; }
.footer .btn { width: 100%; }
.footer .sum { flex: 1; }
.footer .sum b { color: var(--red); font-size: 20px; }

.btn { border: 0; border-radius: 10px; background: var(--red); color: #fff; font: 600 16px/1 inherit; font-family: inherit; padding: 14px 22px; min-height: 46px; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn.small { padding: 8px 14px; min-height: 36px; font-size: 14px; border-radius: 8px; }
.btn.gray { background: #EFE9DE; color: var(--ink); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #E6C3BF; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.order-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.tag.pending { background: #FFF1DC; color: var(--warn); }
.tag.done { background: #E3F2E8; color: var(--ok); }
.tag.cancelled { background: #EEE; color: #888; }
.line { display: flex; justify-content: space-between; font-size: 15px; padding: 4px 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.chips button.on { background: var(--red); border-color: var(--red); color: #fff; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.link { color: var(--red); background: none; border: 0; font: inherit; font-size: 14px; padding: 4px 6px; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; }
.inline-add input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; background: #fff; }

.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #D9D0C2; border-radius: 15px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(20px); }

.modal-bg { position: fixed; inset: 0; background: rgba(30,20,15,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: var(--paper); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 20px 16px calc(16px + var(--badge-space) + env(safe-area-inset-bottom)); max-height: 85vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; }
.modal .body { white-space: pre-wrap; font-size: 15px; margin-bottom: 16px; }
.modal .btn-row { flex-direction: column-reverse; }
.modal .btn-row .btn { width: 100%; }

#toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(30,20,15,.88); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; z-index: 60; max-width: 80%; text-align: center; }

.login { max-width: 380px; margin: 40px auto; }
.stat { display: flex; gap: 16px; margin-top: 4px; }
.stat div b { display: block; font-size: 20px; color: var(--red); }
.round-select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; font: inherit; }

/* 语言切换 */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lang-pick { position: relative; display: flex; align-items: center; gap: 4px; flex-shrink: 0; color: #FBF6EC;
  border: 1px solid rgba(251,246,236,.55); border-radius: 18px; padding: 0 8px 0 10px; height: 36px; }
.lang-pick select { appearance: none; -webkit-appearance: none; background: transparent; border: 0; color: inherit;
  font: inherit; font-size: 14px; padding: 0 2px; height: 100%; cursor: pointer; }
.lang-pick select option { color: var(--ink); }

/* 产品照片 */
.prod { justify-content: flex-start; }
.prod-info { flex: 1; min-width: 0; }
.thumb { flex-shrink: 0; width: 64px; height: 64px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: #EFE9DE; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(20,14,10,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px 16px calc(20px + var(--badge-space)); }
.lightbox img { max-width: 100%; max-height: 70vh; border-radius: 12px; object-fit: contain; }
.lb-track { width: 100%; max-width: 640px; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide { flex: 0 0 100%; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; }
.lb-dots { display: flex; gap: 8px; }
.lb-dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.35); cursor: pointer; }
.lb-dots button.on { background: #fff; }
.lb-count { opacity: .7; font-size: 13px; margin-left: 6px; }
.lb-nav { position: absolute; top: 42%; width: 40px; height: 56px; border: 0; border-radius: 10px; background: rgba(255,255,255,.14); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
@media (hover: none) { .lb-nav { display: none; } }
.lb-name { color: #FBF6EC; font-size: 17px; text-align: center; }
.lb-close { background: #FBF6EC; color: var(--ink); border: 0; border-radius: 22px; padding: 10px 28px; font: inherit; font-size: 15px; min-height: 44px; }
/* 后台照片编辑 */
.photo-edit { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.photo-edit .preview { width: 72px; height: 72px; border-radius: 10px; background: #EFE9DE center/cover no-repeat; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.photo-edit input[type=file] { display: none; }
.list-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; vertical-align: middle; margin-right: 8px; background: #EFE9DE; }

/* 修改订单提示条 */
.edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #FFF1DC; color: var(--warn);
  border: 1px solid #F3D9AE; border-radius: 12px; padding: 10px 12px; margin: 12px 0 0; font-size: 14px; font-weight: 500; }
.edit-banner.hidden { display: none; }
.lock-note { background: #FFF1DC; color: var(--warn); border-radius: 10px; padding: 10px 12px; margin: 12px 0; font-size: 14px; }

/* 限量 */
.stock { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stock.low { color: var(--warn); font-weight: 600; }
.stock.out { color: var(--red); font-weight: 600; }
.prod.is-out .name, .prod.is-out .price { opacity: .5; }
.prod.is-out .thumb { opacity: .5; }
.stepper button:disabled { background: #E7E1D6; border-color: #E7E1D6; color: #fff; }

/* 付款 */
.pay-sheet { text-align: left; }
.pay-amount { font-size: 16px; margin-bottom: 10px; }
.pay-amount b { color: var(--red); font-size: 22px; }
.pay-qr { display: block; width: 100%; max-width: 280px; margin: 0 auto; border-radius: 12px; background: #fff; border: 1px solid var(--line); -webkit-touch-callout: default; }
.pay-hint { margin-top: 8px; text-align: center; }
.pay-note { margin-top: 8px; background: #F7F2E8; border-radius: 8px; padding: 8px 10px; font-size: 14px; white-space: pre-wrap; }
.pay-step { margin: 14px 0 8px; font-weight: 600; font-size: 15px; }
.pay-proof { display: flex; align-items: center; justify-content: center; min-height: 72px; border: 1.5px dashed #D8CDBA; border-radius: 12px;
  color: var(--red); font-size: 15px; cursor: pointer; background: #FFFDF8 center/cover no-repeat; position: relative; overflow: hidden; }
.pay-proof input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pay-proof.has { min-height: 160px; border-style: solid; }
.pay-proof.has span { background: rgba(30,20,15,.7); color: #fff; padding: 6px 12px; border-radius: 16px; font-size: 13px; }
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.pay-row.pay-unpaid { background: #F3EFE8; color: var(--muted); }
.pay-row.pay-claimed { background: #FFF1DC; color: var(--warn); font-weight: 600; }
.pay-row.pay-paid { background: #E3F2E8; color: var(--ok); font-weight: 600; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

/* 勾选订单 */
.sel-line { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.sel-box, .sel-all input { width: 22px; height: 22px; accent-color: var(--red); flex-shrink: 0; margin: 0; }
.sel-all { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.card.is-sel { box-shadow: 0 0 0 2px var(--red); }
.round-name { display: flex; align-items: center; gap: 6px; margin: 2px 0 6px; font-size: 15px; font-weight: 600; color: var(--ink); }
.round-name .muted { font-weight: 400; }
.round-select { max-width: 55%; }
.name-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 4px; font-size: 13px; }
.name-chips:empty { display: none; }
.name-chip { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 16px; padding: 6px 12px; font: inherit; font-size: 13px; min-height: 32px; cursor: pointer; }
.name-chip:active { background: #F7F2E8; }

/* WhatsApp 通知 */
.name-chip.on { background: var(--red); border-color: var(--red); color: #fff; }
.btn.wa-btn { background: #fff; color: #128C4A; border: 1px solid #25D366; }
.btn.wa-btn.sent { color: var(--muted); border-color: var(--line); }
.btn.wa-btn:disabled { opacity: .5; }
.wa-msg { width: 100%; box-sizing: border-box; margin: 8px 0 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 15px; resize: vertical; }
a.btn.wa-go { display: flex; align-items: center; justify-content: center; width: 100%; box-sizing: border-box; background: #25D366; color: #fff; text-decoration: none; }
.wa-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.wa-row.sent b { color: var(--muted); }
.wa-row a.btn { text-decoration: none; flex-shrink: 0; }
.wa-note { color: #128C4A; font-size: 13px; }
.wa-row.sent .wa-note { color: var(--muted); }
.wa-warn { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: #FFF1DC; color: var(--warn); font-size: 14px; }

/* 多张产品照片 */
.thumb { position: relative; }
.pic-count { position: absolute; right: 3px; bottom: 3px; min-width: 16px; padding: 1px 5px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 15px; text-align: center; }
.list-thumb-wrap { position: relative; display: inline-block; vertical-align: middle; margin-right: 8px; }
.list-thumb-wrap .list-thumb { margin-right: 0; }
.list-thumb-wrap .pic-count { right: -4px; bottom: -2px; font-size: 10px; padding: 0 4px; }
.photo-edit.multi { display: block; }
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.ph-slot { position: relative; aspect-ratio: 1; border-radius: 10px; background: #EFE9DE center/cover no-repeat; overflow: hidden; }
.ph-cover, .ph-front { position: absolute; left: 0; right: 0; bottom: 0; border: 0; padding: 3px 0; font: inherit; font-size: 11px; text-align: center; color: #fff; background: rgba(0,0,0,.55); }
.ph-cover { background: var(--red); }
.ph-front { cursor: pointer; }
.ph-del { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; cursor: pointer; }
.ph-add { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1.5px dashed #D6CBBB; background: #FAF6EE; color: var(--red); font-size: 13px; line-height: 1.3; cursor: pointer; }
.ph-add span { color: var(--muted); font-size: 11px; }
.name-chip { max-width: 100%; white-space: normal; text-align: left; word-break: break-word; }
/* 组合价 */
.deal { display: inline-block; margin-top: 3px; padding: 1px 8px; border-radius: 6px; background: #FBE7E4; color: var(--red); font-size: 13px; font-weight: 600; }
.deal-more { margin-top: 3px; color: var(--warn); font-size: 12px; }
.deal-tag { display: inline-block; padding: 0 6px; border-radius: 6px; background: #FBE7E4; color: var(--red); font-size: 12px; }
.bundle-in { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; color: var(--muted); }
.field .bundle-in input { flex: 0 0 auto; width: 64px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: center; }
.group-head { margin: 14px 0 2px; padding: 6px 10px; border-radius: 8px; background: #F3E6D8; color: var(--red); font-weight: 700; font-size: 15px; }
.group-head:first-child { margin-top: 0; }
.round-tag { display: inline-block; margin-bottom: 6px; padding: 1px 8px; border-radius: 6px; background: #F3E6D8; color: var(--red); font-size: 12px; font-weight: 600; }
.round-pick { flex-shrink: 0; margin-left: 6px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-size: 13px; color: var(--ink); }
.active-rounds { margin-top: 10px; }
.active-rounds:empty { display: none; }
.active-rounds .link { white-space: nowrap; flex-shrink: 0; }
.round-pick { max-width: 112px; }
.pay-copy { margin-left: 10px; vertical-align: middle; }
/* 下单页字号适当缩小（输入框保持 16px，避免 iPhone 自动放大页面） */
header.brand .brand-name { font-size: 19px; letter-spacing: 1px; }
header.brand h1 { font-size: 15px; line-height: 1.45; }
header.brand h1.long { font-size: 14px; }
header.brand .sub { font-size: 12px; }
.prod .name { font-size: 15px; line-height: 1.35; }
.prod .price { font-size: 15px; }
.group-head { font-size: 14px; }
