:root {
  --bg: #fbf7f2;
  --card: #ffffff;
  --ink: #2b2420;
  --muted: #8a7f77;
  --line: #ece4db;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e6;
  --ok: #2b8a3e;
  --ok-soft: #e9f7ec;
  --warn: #e67700;
  --warn-soft: #fff4e0;
  --bad: #c92a2a;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }

/* ---------- 頂部與底部導覽 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; letter-spacing: .5px; }
.topbar .avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--line); }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  text-decoration: none; color: var(--muted); font-size: 11px; text-align: center; padding: 8px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.on { color: var(--accent); font-weight: 700; }
main { padding: 14px 16px 8px; max-width: 760px; margin: 0 auto; }

/* ---------- 基本元件 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
.pre { white-space: pre-wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 700; cursor: pointer; background: var(--accent); color: var(--accent-ink);
  transition: transform .05s, opacity .2s; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: #f1ece6; color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=email], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 90px; resize: vertical; }

.chip {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f1ece6; color: var(--ink);
  white-space: nowrap; font-weight: 600;
}
.st-ordered { background: var(--accent-soft); color: var(--accent); }
.st-wait { background: var(--warn-soft); color: var(--warn); }
.st-bought, .st-arrived { background: #e7f0ff; color: #1c5fd6; }
.st-confirm { background: #e5f4ea; color: #2f7a4f; }
.st-out { background: var(--bad-soft); color: var(--bad); }
.st-cancel { background: #f1f1f1; color: #999; }
.st-done { background: var(--ok-soft); color: var(--ok); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; white-space: nowrap; cursor: pointer;
}
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: rgba(30, 24, 20, .92); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100;
  transition: all .25s; max-width: 88vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--bad); }

.loading { text-align: center; padding: 60px 0; color: var(--muted); }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- 摘要卡 ---------- */
.summary { background: linear-gradient(135deg, #fff1e4 0%, #fde6ee 100%); color: var(--ink); box-shadow: none; border: 1px solid #f6dfd2; }
.summary .label { font-size: 12px; color: var(--muted); }
.summary .big { font-size: 28px; font-weight: 800; letter-spacing: .5px; margin-top: 2px; }
.summary .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.summary .grid > div { background: rgba(255, 255, 255, .75); border-radius: 12px; padding: 8px 10px; }
.summary .grid b { display: block; font-size: 15px; }
.summary .due { background: var(--accent); color: #fff; border-radius: 12px; padding: 10px 12px; margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.summary .due.ok { background: #5aa97f; }

/* ---------- 商品牆 ---------- */
.event-head { margin-bottom: 12px; }
.event-head .cover { border-radius: var(--radius); margin-bottom: 10px; max-height: 220px; width: 100%; object-fit: cover; }
.deadline { font-size: 13px; color: var(--accent); font-weight: 700; }
.pgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 620px) { .pgrid { grid-template-columns: repeat(3, 1fr); } }
.pcard { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.pcard .img { aspect-ratio: 1 / 1; background: #f3ede6; position: relative; cursor: zoom-in; }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; }
.pcard .code { position: absolute; top: 8px; left: 8px; background: rgba(43, 36, 32, .85); color: #fff; font-weight: 800; font-size: 12px; padding: 2px 7px; border-radius: 6px; }
.pcard .left { position: absolute; bottom: 8px; right: 8px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #fff; }
.pcard .left.full { background: var(--warn); color: #fff; }
.pcard .body { padding: 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard .name { font-size: 14px; font-weight: 600; line-height: 1.35; }
.pcard .price { font-weight: 800; color: var(--accent); }
.pcard .price small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.pcard select { padding: 6px 8px; font-size: 13px; }
.pcard .mine { font-size: 11px; color: var(--ok); font-weight: 700; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: auto; }
.stepper button { width: 36px; height: 34px; border: 0; background: #f7f2ec; font-size: 18px; cursor: pointer; }
.stepper span { flex: 1; text-align: center; font-weight: 700; }
.stepper.has { border-color: var(--accent); }
.stepper.has span { color: var(--accent); }

.cartbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 25;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 736px; margin: 0 auto;
}
.cartbar .grow b { font-size: 16px; }
.cartbar .tiny { opacity: .75; }

/* ---------- 抽屜 / 彈窗 ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 760px; max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img { max-height: 90vh; border-radius: 8px; }

/* ---------- 訂單列表 ---------- */
.line-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.line-item:last-child { border-bottom: 0; }
.line-item .grow .t { font-weight: 600; }
.line-item .amt { text-align: right; white-space: nowrap; font-weight: 700; }
.kv { display: flex; justify-content: space-between; padding: 4px 0; }
.kv.total { font-weight: 800; font-size: 16px; }
.notice { background: var(--warn-soft); color: #8a4b00; border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.notice.info { background: #eef4ff; color: #234a91; }
.bank { background: #f7f2ec; border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.upload { border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; display: block; }
.upload img { max-height: 180px; margin: 0 auto; border-radius: 8px; }

/* ---------- 我的訂單：商品列 ---------- */
.oi { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.oi:last-child { border-bottom: 0; padding-bottom: 2px; }
.oi:first-of-type { padding-top: 2px; }
.oi-img, .li-img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: #f6efe7; flex: none; cursor: zoom-in; }
.li-img { width: 46px; height: 46px; border-radius: 10px; }
.ph { display: flex; align-items: center; justify-content: center; color: #c7b8aa; font-weight: 800; font-size: 20px; cursor: default; }
.li-img.ph { font-size: 16px; }
.oi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.oi-top { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.oi-name { font-weight: 600; line-height: 1.4; }
.oi-code { display: inline-block; font-size: 11px; font-weight: 800; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 0 6px; margin-right: 6px; vertical-align: 1px; }
.oi-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.oi-meta b { margin-left: auto; color: var(--ink); font-size: 15px; }
.tag { background: #f3ede6; color: #6d5c50; border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.oi-note { background: #fffaf0; border: 1px dashed #f0dfc0; color: #7a5a2a; border-radius: 10px; padding: 7px 10px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; margin-top: 4px; }
.linkbtn { align-self: flex-start; border: 0; background: none; color: var(--bad); font-size: 13px; padding: 2px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 下單選項 ---------- */
.opt-box { background: #fbfdf9; border: 1px solid #e3efe4; border-radius: 14px; padding: 0 12px; margin-top: 14px; }
.opt-box textarea { min-height: 56px; background: #fff; }
.card.order .lo-head { margin-bottom: 2px; }
.pref-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #edf3ec; cursor: pointer; }
.pref-row.col { flex-direction: column; align-items: stretch; gap: 8px; cursor: default; }
.pref-row .grow { display: flex; flex-direction: column; }
.pref-ico { font-size: 18px; width: 26px; text-align: center; }
.pref-fee { font-size: 13px; font-weight: 700; color: #5aa97f; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: #dcd6cf; position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch:checked { background: #5aa97f; }
.switch:checked::after { transform: translateX(18px); }

/* ---------- 付款紀錄 ---------- */
.pay-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-row:last-child { border-bottom: 0; }
.pay-row .amt { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* ---------- 原畫展舊訂單 ---------- */
.lo { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; background: #fffdfb; }
.lo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.li { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.li-name { font-size: 14px; line-height: 1.4; }
.lo-sub { font-size: 12px; font-weight: 700; color: #c25410; background: #fff1e6; border-radius: 8px; padding: 4px 8px; margin: 8px 0 2px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.pill { font-size: 12px; border-radius: 999px; padding: 3px 10px; background: #f3efea; color: #8a7f77; }
.pill.on { background: #e5f4ea; color: #2f7a4f; font-weight: 700; }
.lo-money { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.lo-money > div { background: #f7f2ec; border-radius: 10px; padding: 6px 7px; display: flex; flex-direction: column; min-width: 0; }
.lo-money span { font-size: 11px; color: var(--muted); }
.lo-money b { font-size: 13px; }
@media (max-width: 400px) { .lo-money { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.deadline-note { margin-top: 10px; background: #fff4e6; color: #a8510c; border-radius: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.5; }

/* ---------- 付款方式 ---------- */
.steps { list-style: none; counter-reset: st; padding: 0; margin: 4px 0 6px; }
.steps li { counter-increment: st; position: relative; padding: 0 0 14px 40px; display: flex; flex-direction: column; gap: 2px; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 30px; bottom: 4px; width: 2px; background: #f3e4d8; }
.steps li span { font-size: 13px; color: var(--muted); }
.paybtns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.linebtn { background: #06c755; }

/* ---------- 特殊保護 ---------- */
.protect-box { background: #fffaf3; border: 1px solid #f3e2cc; border-radius: 14px; padding: 12px 14px; margin-top: 14px; }
.protect-head { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.protect-head input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.protect-head b { display: block; margin-bottom: 4px; }
.protect-desc { display: block; font-size: 13px; color: #8a6b4f; line-height: 1.6; }
.protect-q { font-size: 14px; color: #7a6656; margin: 12px 0 6px; }
.protect-box textarea { background: #fff; min-height: 70px; }

/* ---------- 許願跳轉 ---------- */
.wish-row[data-row] { cursor: pointer; }
.focus-flash { animation: flash 2.4s ease-out 1; box-shadow: 0 0 0 3px var(--accent); border-radius: var(--radius); }
@keyframes flash { 0% { box-shadow: 0 0 0 6px rgba(232, 89, 12, .45); } 100% { box-shadow: 0 0 0 3px rgba(232, 89, 12, .25); } }

/* ---------- 頁尾 ---------- */
.site-footer { text-align: center; font-size: 12px; color: #b3a79c; padding: 12px 16px calc(140px + env(safe-area-inset-bottom)); letter-spacing: .3px; }
