/* ── Reset & Vars ─────────────────────────────────── */
:root {
  --brand: #6f2f1e;
  --brand2: #a54825;
  --accent: #ef8e2f;
  --bg: #fffdf8;
  --surface: #ffffff;
  --muted: #7a6255;
  --line: #ede0d4;
  --green: #28704f;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { background: var(--bg); color: #261712; }
body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(80px + var(--safe-bottom));
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; }
textarea { font: inherit; }

/* ── Header ───────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(120deg,#4f1c13,#7e351f 60%,#973f22);
  color: white;
  box-shadow: 0 4px 20px rgba(52,18,8,.25);
}
.header-inner {
  max-width: 680px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 30px; }
.brand strong { display: block; font-size: 20px; letter-spacing: .02em; }
.brand small { display: block; font-size: 11px; color: #f6d7bd; margin-top: 1px; }
.cart-btn {
  position: relative; width: 48px; height: 48px;
  border-radius: 14px; background: rgba(255,255,255,.15);
  font-size: 22px; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.2);
}
.cart-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--accent); color: white;
  border-radius: 999px; font-size: 11px; font-weight: 900;
  display: grid; place-items: center;
}

/* ── Hero ─────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg,#4f1c13 0%,#7e351f 50%,#c05a2a 100%);
  color: white; padding: 28px 20px 36px;
  text-align: center;
}
.hero-sub { font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: #f6d7bd; margin-bottom: 8px; }
.hero h1 { font-size: clamp(26px,5vw,38px); font-weight: 900; letter-spacing: -.02em; }

/* ── Category tabs ────────────────────────────────── */
.cat-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 16px 16px 4px;
  scrollbar-width: none; max-width: 680px; margin: 0 auto;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: 0 0 auto; min-height: 40px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 800; font-size: 14px;
  white-space: nowrap; transition: all .16s;
}
.cat-tab.active {
  background: var(--brand); border-color: var(--brand); color: white;
}

/* ── Menu grid ────────────────────────────────────── */
.menu-main { max-width: 680px; margin: 0 auto; }
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 12px 16px 24px;
}
.menu-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; text-align: left;
  box-shadow: 0 4px 14px rgba(71,43,26,.07);
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.menu-card:active { transform: scale(.97); }
.menu-card-img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: linear-gradient(145deg,#f9e1c5,#fff5df);
}
.menu-card-body { padding: 10px 12px 12px; }
.menu-card-cat { font-size: 10px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; }
.menu-card-name { display: block; margin: 3px 0 6px; font-size: 15px;
  font-weight: 900; line-height: 1.25; }
.menu-card-desc { font-size: 12px; color: var(--muted); line-height: 1.4;
  margin-bottom: 10px; }
.menu-card-foot { display: flex; align-items: center; justify-content: space-between; }
.menu-card-price { font-size: 16px; font-weight: 900; color: var(--brand2); }
.menu-card-price.tbd { color: var(--muted); font-size: 13px; }
.add-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand); color: white; font-size: 22px;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(111,47,30,.3);
}

/* ── Backdrop ─────────────────────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(31,18,10,.5); backdrop-filter: blur(3px);
}

/* ── Bottom sheet (cart & pay) ────────────────────── */
.cart-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
  background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 50px rgba(52,18,8,.18);
  max-height: 88vh; display: flex; flex-direction: column;
  max-width: 680px; margin: 0 auto;
  padding-bottom: var(--safe-bottom);
}
.sheet-handle {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--line); margin: 12px auto 4px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px 14px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 20px; font-weight: 900; }
.close-btn { font-size: 20px; width: 38px; height: 38px;
  border-radius: 50%; background: #f4ece3; display: grid; place-items: center; }
.back-btn { font-size: 14px; font-weight: 800; color: var(--brand); padding: 4px 0; }

/* Cart items */
.cart-items { flex: 1; overflow-y: auto; padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.cart-item { display: flex; align-items: center; gap: 12px;
  padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.ci-img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  background: #f9e1c5; flex: 0 0 auto; }
.ci-info { flex: 1; min-width: 0; }
.ci-name { font-weight: 900; font-size: 14px; }
.ci-price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ci-qty { display: flex; align-items: center; gap: 6px; }
.ci-qty button { width: 28px; height: 28px; border-radius: 8px;
  background: #f4ece3; font-size: 18px; display: grid; place-items: center; }
.ci-qty output { font-weight: 900; font-size: 15px; min-width: 22px; text-align: center; }
.cart-note-wrap { padding: 0 20px 12px; }
.cart-note-wrap label { display: flex; flex-direction: column; gap: 5px;
  font-size: 13px; font-weight: 800; color: var(--muted); }
.cart-note-wrap textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; resize: none; outline: none; font-size: 14px;
}
.cart-footer { padding: 14px 20px; border-top: 1px solid var(--line); }
.cart-total-row { display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px; }
.cart-total-row span { font-size: 15px; color: var(--muted); font-weight: 700; }
.cart-total-row strong { font-size: 26px; font-weight: 900; color: var(--brand); }
.checkout-btn {
  width: 100%; min-height: 54px; border-radius: 14px;
  background: linear-gradient(135deg,var(--brand2),var(--accent));
  color: white; font-size: 17px; font-weight: 900;
  box-shadow: 0 8px 20px rgba(165,72,37,.3);
}

/* ── Payment sheet ────────────────────────────────── */
.pay-sheet { overflow-y: auto; }
.pay-amount-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; background: #fff8f0;
  border-bottom: 1px solid var(--line);
}
.pay-amount-row span { font-size: 14px; color: var(--muted); font-weight: 700; }
.pay-amount-row strong { font-size: 28px; font-weight: 900; color: var(--brand); }
.pay-methods { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; padding: 16px 20px; }
.pay-method-btn {
  border: 2px solid var(--line); border-radius: 14px;
  padding: 14px 10px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-size: 13px; font-weight: 800;
  background: var(--surface); transition: all .15s;
}
.pay-method-btn.active { border-color: var(--brand); background: #fff1dc; color: var(--brand); }
.pay-method-btn.coming { opacity: .55; }
.pay-method-btn small { font-size: 11px; color: var(--muted); font-weight: 600; }
.pay-logo { width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 13px; font-weight: 900; color: white; }
.fps-logo { background: #e8232a; font-size: 11px; }
.alipay-logo { background: #1677ff; font-size: 18px; font-weight: 900; }
.wechat-logo { background: #07c160; font-size: 20px; }
.oct-logo { background: #00843d; font-size: 20px; }

/* FPS & Alipay QR panels */
.fps-panel, .alipay-panel { padding: 0 20px 20px; text-align: center; }
.fps-hint, .alipay-hint { font-size: 13px; line-height: 1.6; color: var(--muted); margin-bottom: 14px; }
.fps-hint strong { color: var(--brand); }
.alipay-hint strong { color: #1677ff; }
.highlight-amount { font-size: 22px; font-weight: 900; }
.qr-wrap {
  width: 240px; height: 240px; margin: 0 auto 14px;
  border: 2px solid var(--line); border-radius: 16px;
  display: grid; place-items: center; background: white;
  overflow: hidden;
}
.qr-wrap img { width: 220px; height: 220px; object-fit: contain; }
.qr-loading { color: var(--muted); font-size: 14px; }
.qr-error { color: #a3342c; font-size: 13px; padding: 12px; }
.fps-name, .alipay-name { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.pay-instruction-box {
  background: #f0f7ff; border: 1px solid #bae0ff; border-radius: 12px;
  padding: 12px 14px; text-align: left; font-size: 12px; line-height: 1.6;
  margin-bottom: 16px; color: #1f3b64;
}
.pay-instruction-box ol { margin: 6px 0 0 16px; }

.confirm-pay-btn {
  width: 100%; min-height: 52px; border-radius: 14px;
  background: var(--green); color: white; font-size: 16px; font-weight: 900;
  box-shadow: 0 6px 16px rgba(40,112,79,.3);
  transition: opacity .2s;
}
.confirm-pay-btn:disabled { opacity: .6; cursor: not-allowed; }
.alipay-confirm-btn {
  background: #1677ff;
  box-shadow: 0 6px 16px rgba(22,119,255,.3);
}

/* ── Sticky bar ───────────────────────────────────── */
.sticky-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 55;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  max-width: 680px; margin: 0 auto;
}
.sticky-bar-btn {
  width: 100%; min-height: 56px; border-radius: 16px;
  background: linear-gradient(135deg,var(--brand2),var(--accent));
  color: white; font-size: 15px; font-weight: 900;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 8px 24px rgba(165,72,37,.35);
}
.sb-count { background: rgba(255,255,255,.22); border-radius: 99px;
  padding: 4px 10px; font-size: 13px; }
.sb-total { font-size: 18px; }

/* ── Success screen ───────────────────────────────── */
.success-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg); display: grid; place-items: center; padding: 24px;
}
.success-inner { text-align: center; max-width: 340px; }
.success-icon { font-size: 72px; margin-bottom: 16px; }
.success-inner h2 { font-size: 28px; font-weight: 900; margin-bottom: 20px; }
.order-id-label { font-size: 13px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; }
.order-id { font-size: 32px; font-weight: 900; color: var(--brand);
  letter-spacing: .08em; margin: 6px 0 20px; }
.success-msg { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 28px; }
.new-order-btn {
  min-height: 50px; padding: 0 32px; border-radius: 14px;
  background: var(--brand); color: white; font-size: 16px; font-weight: 900;
}

/* ── Empty cart ───────────────────────────────────── */
.cart-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.cart-empty span { display: block; font-size: 42px; margin-bottom: 10px; }
