:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f6efe4;
  --line: #eadfce;
  --text: #2b1d0e;
  --muted: #7c6a55;
  --accent: #b45309;
  --accent-ink: #ffffff;
  --accent-soft: #fdecd3;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(60, 35, 10, .06), 0 6px 20px rgba(60, 35, 10, .06);
  --radius: 16px;
  --font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120c; --surface: #221a12; --surface-2: #2a2016; --line: #3a2d1f; --text: #f5ebdd; --muted: #b9a68e;
    --accent: #f59e0b; --accent-ink: #1f1302; --accent-soft: #3a2a12;
    --ok: #4ade80; --ok-bg: #0b2e18; --info: #93c5fd; --info-bg: #102340; --err: #f87171; --err-bg: #3b0d0d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17120c; --surface: #221a12; --surface-2: #2a2016; --line: #3a2d1f; --text: #f5ebdd; --muted: #b9a68e;
  --accent: #f59e0b; --accent-ink: #1f1302; --accent-soft: #3a2a12;
  --ok: #4ade80; --ok-bg: #0b2e18; --info: #93c5fd; --info-bg: #102340; --err: #f87171; --err-bg: #3b0d0d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand b { font-size: 17px; }
.brand small { color: var(--muted); font-size: 12px; }
.top-link { font-size: 14px; text-decoration: none; white-space: nowrap; }

.main { max-width: 720px; margin: 0 auto; padding: 0 16px 120px; }
.foot { max-width: 720px; margin: 0 auto; padding: 0 16px 120px; color: var(--muted); font-size: 13px; text-align: center; }

/* menu */
.tabs { position: sticky; top: 57px; z-index: 4; display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  background: var(--bg); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 16px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cat h2 { font-size: 15px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; letter-spacing: .05em; }
.items { display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.item.has { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 650; }
.item .desc { color: var(--muted); font-size: 13px; }
.item .price { font-weight: 700; color: var(--accent); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 4px; flex: none; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.stepper button.add { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper .q { min-width: 26px; text-align: center; font-weight: 700; }

/* cart bar */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
.bar-in { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.bar .sum { flex: 1; min-width: 0; }
.bar .sum b { font-size: 22px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 18px; font-weight: 650; cursor: pointer; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.lg { padding: 14px 22px; font-size: 17px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

/* checkout / receipt */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-top: 16px; }
.card h1 { font-size: 20px; margin: 0 0 12px; }
.lines { width: 100%; border-collapse: collapse; }
.lines td { padding: 8px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.lines td.r { text-align: right; white-space: nowrap; padding-left: 12px; }
.lines tr:last-child td { border-bottom: 0; }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid var(--text); margin-top: 8px; padding-top: 10px; font-weight: 700; }
.total b { font-size: 26px; }
.field { display: grid; gap: 6px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.field input { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 16px; color: var(--text); }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row > * { flex: 1; }

.ticket { text-align: center; }
.ticket .no { font-size: 14px; color: var(--muted); }
.ticket .no b { display: block; font-size: 44px; color: var(--text); line-height: 1.1; }
.code { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: .18em; margin: 6px 0 2px; }
.qr { width: min(260px, 72vw); aspect-ratio: 1; margin: 14px auto 6px; background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--line); }
.qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.amount { font-size: 30px; font-weight: 800; margin: 4px 0; }
.status { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 6px 14px; font-weight: 700; margin: 8px 0; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status.pending { background: var(--accent-soft); color: var(--accent); }
.status.paying { background: var(--info-bg); color: var(--info); }
.status.paying::before { animation: blink 1s infinite; }
.status.paid { background: var(--ok-bg); color: var(--ok); }
.status.expired { background: var(--err-bg); color: var(--err); }
@keyframes blink { 50% { opacity: .2; } }
.steps { text-align: left; margin: 14px 0 0; padding-left: 22px; color: var(--muted); font-size: 14px; }
.steps li { margin: 4px 0; }
.paid-box { background: var(--ok-bg); color: var(--ok); border-radius: 14px; padding: 16px; margin-top: 12px; text-align: center; }
.paid-box .big { font-size: 40px; line-height: 1; }
.paid-box p { margin: 6px 0 0; color: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 10; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%); }

@media print {
  .top, .bar, .foot, .row, .steps { display: none !important; }
  .card { box-shadow: none; border: 0; }
}
