:root {
  --bg: #fbf6f0;
  --card: #ffffff;
  --ink: #2b211b;
  --muted: #8a7a6e;
  --line: #eadfd4;
  --accent: #f07b22;
  --accent-ink: #c55a0c;
  --accent-soft: #fdebdc;
  --danger: #c62828;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
#top { padding: 18px 16px 10px; }
#shop { font-size: 22px; font-weight: 800; }
#table { color: var(--accent-ink); font-weight: 700; }
#cats {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.cat {
  flex: none; padding: 6px 14px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600;
}
#menu { padding: 0 16px; }
.cat-title { margin: 22px 0 8px; font-size: 17px; scroll-margin-top: 64px; }
.product {
  display: flex; width: 100%; justify-content: space-between; align-items: center;
  min-height: 60px; padding: 14px 16px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-align: left;
}
.p-name { font-weight: 700; font-size: 17px; }
.p-price { font-weight: 700; color: var(--accent-ink); }
.sold-out { opacity: .5; }
#cartbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 3;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border: none; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 17px; box-shadow: 0 6px 20px rgba(240,123,34,.35);
}
dialog {
  width: min(520px, 100vw - 24px); max-height: 88vh; border: none; border-radius: 20px; padding: 0;
  color: var(--ink); background: var(--card);
}
dialog::backdrop { background: rgba(30, 20, 10, .45); }
#item-form { padding: 20px; overflow-y: auto; }
#item-form h2 { margin: 0 0 12px; font-size: 20px; }
.group { border: none; padding: 0; margin: 0 0 14px; }
.group legend { font-weight: 700; margin-bottom: 6px; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 10px;
}
.opt input { width: 20px; height: 20px; accent-color: var(--accent); }
.opt-price { margin-left: auto; color: var(--muted); }
.note { display: block; margin: 8px 0; font-weight: 600; }
.note input, .note textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.qty-row { display: flex; justify-content: center; align-items: center; gap: 22px; margin: 14px 0; }
.qty-row button, .round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 22px;
}
#qty { font-size: 22px; font-weight: 800; min-width: 28px; text-align: center; }
.actions { display: flex; gap: 10px; }
.actions button { flex: 1; }
.primary {
  padding: 14px; border: none; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800;
}
.primary:disabled { opacity: .5; }
.primary.big { width: 100%; font-size: 18px; padding: 16px; }
.ghost { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; }
.error { color: var(--danger); font-weight: 600; }
#cart, #done, #fatal {
  position: fixed; inset: 0; z-index: 4; overflow-y: auto; background: var(--bg);
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-head .ghost { padding: 8px 12px; }
#cart-lines { list-style: none; margin: 0; padding: 0; }
.line {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 12px; margin-bottom: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.line-name { font-weight: 700; }
.line-opts, .line-note { color: var(--muted); font-size: 14px; }
.line-note { color: var(--accent-ink); }
.line-qty { display: flex; align-items: center; gap: 10px; }
.line-qty .round { width: 34px; height: 34px; font-size: 18px; }
.line-price { grid-column: 2; text-align: right; font-weight: 700; }
#total-row { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0; font-size: 18px; }
#total-row strong { font-size: 26px; }
#turnstile { margin: 8px 0 12px; min-height: 65px; }
.done-box { text-align: center; padding-top: 18vh; }
#done-icon {
  width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent-ink); font-size: 38px; line-height: 72px; font-weight: 800;
}
#done-title { margin: 0 0 6px; }
#done-text { color: var(--muted); margin: 0 0 24px; }
#fatal { display: flex; align-items: center; justify-content: center; text-align: center; font-size: 18px; }
