:root {
  --paper: #FAF6EF;
  --paper-deep: #F3EFE8;
  --card: #FFFFFF;
  --ink: #2B2926;
  --ink-soft: #625B52;
  --line: #E7E0D4;
  --fire: #C2412F;
  --fire-dark: #A23423;
  --fire-soft: #FBE9E3;
  --amber-soft: #FDF1DC;
  --amber-ink: #7A4E0C;
  --ok: #2F6B45;
  --ok-soft: #E3F1E7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 41, 38, .06), 0 6px 18px rgba(43, 41, 38, .06);
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; }
body.locked { overflow: hidden; }
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: var(--fire); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 14px; }
:focus-visible { outline: 3px solid #F2B04A; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 頂欄 */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(250, 246, 239, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand img { display: block; width: 120px; height: auto; }
.search { flex: 1; min-width: 0; }
.search input {
  width: 100%; min-height: 42px; padding: 8px 14px 8px 38px; border: 1px solid var(--line); border-radius: 21px; background: var(--card)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23625B52' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center;
  font-size: 16px;
}
.search input:focus { border-color: var(--ink); outline: none; }
.cart-btn { position: relative; flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; }
.cart-btn svg { width: 24px; height: 24px; }
.cart-count { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--fire); color: #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center; border: 2px solid var(--paper); }

/* 主視覺 */
.shop { max-width: 1180px; margin: 0 auto; padding: 0 16px 140px; }
.hero { margin-top: 16px; padding: 22px 20px; border-radius: 20px; background: var(--ink); color: #fff; display: grid; gap: 16px; }
.hero-kicker { font-size: 14px; font-weight: 700; color: #F2B04A; letter-spacing: .06em; }
.hero h1 { font-size: clamp(28px, 7vw, 44px); font-weight: 900; line-height: 1.2; margin-top: 4px; }
.hero-sub { margin-top: 6px; font-size: 15px; color: #E7E0D4; }
.perks { display: flex; flex-wrap: wrap; gap: 8px; }
.perks li { padding: 6px 12px; border-radius: 20px; background: rgba(255, 255, 255, .1); font-size: 14px; }
.perks b { margin-right: 6px; color: #F2B04A; }
@media (min-width: 800px) {
  .hero { grid-template-columns: 1fr auto; align-items: end; padding: 32px 36px; }
  .perks { flex-direction: column; }
}

/* 分類 */
.cats { position: sticky; top: 67px; z-index: 20; margin: 16px -16px 0; padding: 10px 16px; background: var(--paper); }
.cats-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.cats-row::-webkit-scrollbar { display: none; }
.cat { flex: none; min-height: 40px; padding: 6px 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); font-size: 15px; font-weight: 700; }
.cat[aria-pressed="true"] { background: var(--fire); border-color: var(--fire); color: #fff; }
.result-note { margin-top: 8px; color: var(--ink-soft); font-size: 14px; }

/* 商品卡 */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1020px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; } }
.loading { grid-column: 1 / -1; padding: 48px 0; color: var(--ink-soft); text-align: center; }
.card { display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-media { position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0; background: var(--paper-deep); overflow: hidden; }
.card-media img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.card-media:hover img { transform: scale(1.03); }
.card-seal { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 900; color: #D9CFC0; }
.card-qty { position: absolute; z-index: 2; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--fire); color: #fff; font-size: 14px; font-weight: 900; display: grid; place-items: center; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.card-name { padding: 0; border: 0; background: none; text-align: left; font-size: 16px; font-weight: 700; line-height: 1.4; }
.card-desc { font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 8px; background: var(--amber-soft); color: var(--amber-ink); font-size: 12.5px; font-weight: 700; line-height: 1.6; }
.tag-hot { background: var(--fire-soft); color: #8F2A1C; }
.card-foot { margin-top: auto; padding-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.price { font-size: 18px; font-weight: 900; color: var(--fire); }
.add-btn { min-height: 40px; padding: 6px 14px; border: 0; border-radius: 20px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 700; }
.add-btn:hover { background: #000; }
.add-btn:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 380px) { .add-btn { width: 100%; } }

/* 共用按鈕 */
.primary-btn { min-height: 50px; padding: 10px 18px; border: 0; border-radius: 12px; background: var(--fire); color: #fff; font-size: 16px; font-weight: 900; }
.primary-btn:hover { background: var(--fire-dark); }
.primary-btn:disabled { background: var(--paper-deep); color: var(--ink-soft); cursor: not-allowed; }
.ghost-btn { min-height: 48px; padding: 10px 18px; border: 2px solid var(--ink); border-radius: 12px; background: none; font-weight: 900; }
.wide { display: block; width: 100%; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: none; font-size: 20px; }
.link-btn { padding: 4px 2px; border: 0; background: none; color: var(--ink-soft); text-decoration: underline; font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.step { width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 20px; line-height: 1; }
.step:disabled { opacity: .4; cursor: not-allowed; }
.qty { min-width: 30px; text-align: center; font-weight: 700; }

/* 底部結帳列 */
.cart-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 18px; border: 0; border-radius: 14px; background: var(--fire); color: #fff; font-size: 15px; box-shadow: 0 8px 24px rgba(194, 65, 47, .35);
}
.cart-bar-go { font-size: 17px; font-weight: 900; }
@media (min-width: 900px) { .cart-bar { left: auto; right: 24px; width: 340px; bottom: 76px; } }

.toast { position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom)); z-index: 70; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 22px; background: var(--ink); color: #fff; font-size: 14.5px; box-shadow: var(--shadow); }

/* 彈窗共用 */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop, .drawer-backdrop { position: absolute; inset: 0; background: rgba(43, 41, 38, .5); }
.sheet-card {
  position: relative; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  padding: 20px 20px calc(72px + env(safe-area-inset-bottom)); background: var(--paper); border-radius: 18px 18px 0 0;
}
@media (min-width: 600px) { .sheet { align-items: center; } .sheet-card { border-radius: 18px; padding-bottom: 24px; } }
.sheet-card h2 { padding-right: 36px; font-size: 23px; font-weight: 900; line-height: 1.3; }
.sheet-img { display: block; width: 100%; max-height: 340px; object-fit: contain; margin-bottom: 12px; background: var(--paper-deep); border-radius: 12px; }
.sheet-price { margin-top: 2px; font-size: 21px; font-weight: 900; color: var(--fire); }
.sheet-price s { margin-left: 6px; font-size: 15px; font-weight: 400; color: var(--ink-soft); }
.sheet-desc { margin-top: 6px; font-size: 15px; color: var(--ink-soft); }
.sheet-warn { margin-top: 10px; padding: 8px 12px; background: var(--fire-soft); color: #8F2A1C; border-radius: 10px; font-size: 15px; font-weight: 700; }
.sheet-offer { margin-top: 10px; padding: 8px 12px; background: var(--amber-soft); color: var(--amber-ink); border-radius: 10px; font-size: 15px; font-weight: 700; }
.sheet-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.sheet-foot .primary-btn { flex: 1; min-width: 0; }
.sheet-x { position: absolute; top: 8px; right: 8px; z-index: 1; }

/* 購物車抽屜 */
.drawer { position: fixed; inset: 0; z-index: 45; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); display: flex; flex-direction: column; background: var(--paper); box-shadow: -8px 0 30px rgba(0, 0, 0, .15); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 20px; font-weight: 900; }
.drawer-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.drawer-list { flex: 1; overflow-y: auto; padding: 8px 20px; }
.drawer-foot { padding: 14px 20px calc(80px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card); }
@media (min-width: 600px) { .drawer-foot { padding-bottom: 20px; } }
.empty { margin: auto; padding: 40px 20px; text-align: center; color: var(--ink-soft); display: grid; gap: 16px; }

.cline { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cline-img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--paper-deep); }
.cline-seal { display: grid; place-items: center; font-weight: 900; color: #B9AE9E; font-size: 22px; }
.cline-name { font-weight: 700; line-height: 1.4; }
.cline-unit { font-size: 13.5px; color: var(--ink-soft); }
.cline-ctrl { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.cline-amount { font-weight: 900; }
.gift { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 8px 12px; background: var(--amber-soft); color: var(--amber-ink); border-radius: 10px; font-size: 14.5px; font-weight: 700; }
.gift-hint { margin-top: 8px; font-size: 14px; color: var(--fire); font-weight: 700; }
.sum { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.sum b { font-size: 22px; font-weight: 900; }
.sum.grand { margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--ink); }

/* 結帳 */
.checkout { position: fixed; inset: 0; z-index: 55; overflow-y: auto; background: var(--paper); }
.checkout-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.checkout-head h2 { font-size: 20px; font-weight: 900; }
.back-btn { min-height: 42px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 700; }
.checkout-in { max-width: 1080px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
@media (min-width: 900px) { .checkout-in { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; } .co-summary { position: sticky; top: 76px; } }
.co-main { display: grid; gap: 16px; }
.co-card { padding: 18px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.co-card h3 { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 900; margin-bottom: 4px; }
.step-no { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 14px; display: grid; place-items: center; }
.summary-list { margin-top: 6px; }
.field label, .field-label { display: block; margin-bottom: 4px; font-size: 15px; font-weight: 500; }
.field input, .field select, .field textarea {
  display: block; width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; font-size: 16px;
  background: var(--card); border: 1px solid #D9D1C4; border-radius: 10px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; }
.field select:disabled { background: var(--paper-deep); color: var(--ink-soft); cursor: not-allowed; }
.field textarea { min-height: 70px; resize: vertical; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.opt-list, .pay-list { display: grid; gap: 8px; }
.opt, .pay-opt { position: relative; display: block; }
.opt input, .pay-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt span, .pay-opt > span { display: block; padding: 11px 14px; background: var(--card); border: 1px solid #D9D1C4; border-radius: 10px; }
.opt input:checked + span, .pay-opt input:checked + span { border: 2px solid var(--fire); background: var(--fire-soft); padding: 10px 13px; }
.opt input:focus-visible + span, .pay-opt input:focus-visible + span { outline: 3px solid #F2B04A; outline-offset: 2px; }
.pay-opt b { display: flex; align-items: center; gap: 8px; }
.pay-opt b em { font-style: normal; font-size: 12.5px; padding: 0 8px; border-radius: 8px; background: var(--paper-deep); color: var(--ink-soft); }
.pay-opt small { display: block; margin-top: 2px; font-size: 13.5px; color: var(--ink-soft); }
.pay-opt.soon > span { opacity: .6; }
.pay-opt.soon input { cursor: not-allowed; }
.fine { margin-top: 8px; font-size: 13.5px; color: var(--ink-soft); }
.form-err { margin-top: 10px; padding: 10px 12px; background: var(--fire-soft); color: #8F2A1C; border-radius: 10px; font-size: 15px; }
#submit { margin-top: 12px; }

/* 完成頁 */
.receipt-wrap { position: fixed; inset: 0; z-index: 60; overflow-y: auto; padding: 24px 16px 48px; background: var(--paper); }
.receipt { max-width: 480px; margin: 0 auto; padding: 24px 20px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); }
.receipt-mark { display: block; margin: 0 auto 6px; }
.receipt h2 { font-size: 24px; font-weight: 900; text-align: center; }
.receipt-no { margin: 6px 0 10px; color: var(--ink-soft); font-size: 14px; text-align: center; overflow-wrap: anywhere; }
.receipt-no b { display: block; color: var(--fire); font-size: 18px; font-weight: 900; }
.receipt-meta { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--ink-soft); font-size: 15px; }
.receipt .ghost-btn { margin-top: 16px; }
.bank { margin: 12px 0; padding: 14px 16px; border: 2px solid var(--fire); border-radius: 14px; background: var(--fire-soft); }
.bank-title { font-weight: 700; }
.bank-title b { color: var(--fire); font-size: 20px; }
.bank dl { margin-top: 8px; display: grid; gap: 4px; }
.bank dl div { display: grid; grid-template-columns: 3em 1fr; gap: 8px; align-items: center; }
.bank dt { color: var(--ink-soft); font-size: 14px; }
.bank dd { font-weight: 700; overflow-wrap: anywhere; }
.copy-btn { margin-left: 6px; padding: 2px 10px; border: 1px solid var(--fire); border-radius: 8px; background: var(--card); color: var(--fire); font-size: 13px; font-weight: 700; }
.report-area { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.report-start { display: grid; gap: 8px; }
.report-form { display: grid; gap: 10px; }
.report-done { padding: 14px 16px; border: 2px solid var(--ok); border-radius: 14px; background: var(--ok-soft); }
.done-title { font-size: 18px; font-weight: 900; color: var(--ok); }
.kv { margin-top: 8px; display: grid; gap: 4px; }
.kv div { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; }
.kv dt { color: var(--ink-soft); font-size: 14px; }
.kv dd { font-weight: 700; overflow-wrap: anywhere; }
.kv-sub { margin-top: 10px; font-size: 14px; color: var(--ink-soft); }
.kv-items { margin-top: 2px; padding-left: 1.2em; list-style: disc; font-size: 14.5px; }
.report-form h3 { font-size: 18px; font-weight: 900; }

/* 頁尾 */
.foot { border-top: 1px solid var(--line); background: var(--paper-deep); }
.foot-in { max-width: 1180px; margin: 0 auto; padding: 24px 16px 170px; display: grid; gap: 6px; color: var(--ink-soft); font-size: 14px; }
.foot-in img { width: 110px; height: auto; margin-bottom: 4px; }
.foot-tag { margin-top: 6px; font-weight: 700; color: var(--ink); }
@media (min-width: 900px) { .foot-in { padding-bottom: 40px; } }

@media (prefers-reduced-motion: no-preference) {
  .sheet-card { animation: rise .18s ease-out; }
  .drawer-panel { animation: slide .2s ease-out; }
  @keyframes rise { from { transform: translateY(16px); opacity: .6; } }
  @keyframes slide { from { transform: translateX(24px); opacity: .6; } }
}
