:root {
  --red: #9e2a1f;
  --red-dark: #7c1f16;
  --red-soft: #fbe9e5;
  --tea: #c7781f;
  --bg: #f7f2ea;
  --card: #ffffff;
  --text: #2b211c;
  --muted: #7a6b62;
  --line: #eadfd3;
  --green: #2e7d32;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 30, 10, 0.08);
  --maxw: 760px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; padding-bottom: 96px; }
a { color: var(--red); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--red); color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; color: var(--red); font-weight: 900; font-size: 1.3rem;
  border: 2px solid var(--tea);
}
.brand-name { font-size: 1.1rem; font-weight: 800; white-space: nowrap; }
.brand-name small { font-size: 0.8rem; font-weight: 500; opacity: 0.9; }
.status { margin: 2px 0 0; font-size: 0.8rem; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ccc; }
.status.open::before { background: #7ee787; box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.3); }
.status.closed::before { background: #ffb4a8; }
.icon-btn {
  flex: none; display: flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, 0.15); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.25); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 16px; }

/* ---------- Mode banner ---------- */
.mode-banner {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 16px; font-size: 0.85rem; text-align: center;
  background: #fff4d6; color: #7a5200; border-bottom: 1px solid #f0dfae;
}
.mode-banner.warn { background: #fdecea; color: #8a1c12; border-color: #f5c6c0; }
.mode-banner a {
  padding: 4px 12px; border-radius: 999px; background: #06c755; color: #fff; font-weight: 700; text-decoration: none;
}
.done-msg { margin: 0 0 8px; font-weight: 600; color: var(--green); }
.done-msg.demo { color: #7a5200; }

/* ---------- Info card ---------- */
.info-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; border-top: 4px solid var(--tea);
}
.info-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.93rem; }
.info-list li { display: flex; gap: 10px; }
.info-label { flex: none; width: 64px; color: var(--muted); }
.info-list a { color: var(--text); text-decoration: none; }
.info-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip-link {
  padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; text-decoration: none;
  background: var(--red-soft); color: var(--red); font-weight: 600;
}
.chip-link.fb { background: #e7efff; color: #1a56db; }
.info-note { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted); }

/* ---------- Tools ---------- */
.menu-tools {
  position: sticky; top: 62px; z-index: 10;
  background: var(--bg); margin: 12px -16px 0; padding: 8px 16px 6px;
}
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; color: var(--muted);
}
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font-size: 16px; }
.search:focus-within { border-color: var(--red); }
.cat-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px;
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 0.88rem; white-space: nowrap;
}
.cat-tab.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ---------- Menu ---------- */
.menu-section { margin-top: 18px; scroll-margin-top: 150px; }
.menu-section h2 {
  font-size: 1.05rem; margin: 0 0 8px; padding-left: 10px;
  border-left: 4px solid var(--red);
}
.items { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .items { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 360px) { .icon-btn span { display: none; } .brand-name small { display: none; } }

.item {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid transparent; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px; color: inherit;
  transition: transform 0.1s, border-color 0.15s;
}
.item:hover { border-color: var(--line); }
.item:active { transform: scale(0.99); }
.item[disabled] { opacity: 0.5; cursor: not-allowed; }
.thumb {
  flex: none; width: 64px; height: 64px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, #fff4e3, #f3dcc0);
  display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.35); transform-origin: 50% 45%; }
.thumb svg { width: 34px; height: 34px; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 6px;
  background: #fff1d6; color: #9a5b00;
}
.badge.gray { background: #eee; color: #666; }
.item-note { font-size: 0.78rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-price { font-size: 0.85rem; margin-top: 4px; color: var(--red); font-weight: 700; }
.item-price span { color: var(--muted); font-weight: 400; margin-right: 2px; }
.add-dot {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: #fff; display: grid; place-items: center; font-size: 1.3rem; line-height: 1;
}
.empty-search { text-align: center; color: var(--muted); padding: 40px 0; }

.site-footer { text-align: center; font-size: 0.8rem; color: var(--muted); padding: 24px 16px 8px; }
.site-footer p { margin: 2px 0; }

/* ---------- Cart bar ---------- */
.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.cart-bar-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: calc(var(--maxw) - 32px); margin: 0 auto;
  background: var(--red); color: #fff; border: 0; border-radius: 999px; padding: 12px 18px;
  box-shadow: 0 6px 18px rgba(158, 42, 31, 0.35); font-weight: 700;
}
.cart-bar-btn:hover { background: var(--red-dark); }
.cart-count {
  min-width: 26px; height: 26px; border-radius: 13px; padding: 0 7px;
  background: #fff; color: var(--red); display: grid; place-items: center; font-size: 0.85rem;
}
.cart-bar-text { flex: 1; text-align: left; }
.bump { animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.06); } }

/* ---------- Sheets (dialog) ---------- */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  max-height: 92vh; max-height: 92dvh;
  border-radius: 20px 20px 0 0; background: var(--card); color: var(--text);
  box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.2);
}
.sheet[open] { animation: up 0.22s ease-out; }
.sheet::backdrop { background: rgba(30, 15, 5, 0.45); }
@keyframes up { from { transform: translateY(40px); opacity: 0.4; } }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 20px; max-height: 88vh; }
}
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { position: relative; border-radius: 20px 20px 0 0; overflow: hidden; }
.item-hero {
  aspect-ratio: 4 / 3; max-height: 34vh; width: 100%; background: linear-gradient(160deg, #fff4e3, #efcfa7);
  display: grid; place-items: center; overflow: hidden;
}
.item-hero img { width: 100%; height: 100%; object-fit: cover; }
.item-hero svg { width: 80px; height: 80px; }
.close-btn {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.9); font-size: 1.4rem; line-height: 1; color: var(--text);
  box-shadow: var(--shadow);
}
.close-btn.plain { position: static; box-shadow: none; background: #f2ebe3; }
.sheet-title-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px; border-bottom: 1px solid var(--line);
}
.sheet-body { padding: 14px 16px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sheet-body h2 { font-size: 1.25rem; }
.sheet-foot {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--card);
}
.sheet-foot.column { flex-direction: column; align-items: stretch; gap: 8px; }

.opt-group { border: 0; padding: 0; margin: 16px 0 0; }
.opt-group legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.opt-group legend em { font-style: normal; font-size: 0.72rem; color: var(--red); background: var(--red-soft); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.opt-group legend .fixed { color: var(--muted); background: #eee; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span {
  display: inline-block; padding: 7px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; font-size: 0.92rem;
}
.opt span small { color: var(--muted); margin-left: 4px; }
.opt input:checked + span { border-color: var(--red); background: var(--red-soft); color: var(--red); font-weight: 700; }
.opt input:checked + span small { color: var(--red); }
.opt input:focus-visible + span { outline: 2px solid var(--tea); outline-offset: 2px; }
.opt input:disabled + span { opacity: 0.5; }

.field { display: grid; gap: 4px; margin-top: 14px; }
.field > span { font-weight: 600; font-size: 0.92rem; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fff; font-size: 16px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--red); }
.field .invalid { border-color: #d93025; }
.err { color: #d93025; min-height: 0; font-size: 0.8rem; }
.err:empty { display: none; }

.stepper { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; }
.stepper button { width: 38px; height: 38px; border: 0; background: none; font-size: 1.2rem; color: var(--red); }
.stepper button:disabled { color: #ccc; cursor: default; }
.stepper output { min-width: 26px; text-align: center; font-weight: 700; }
.stepper.sm button { width: 30px; height: 30px; font-size: 1rem; }

.primary-btn {
  flex: 1; border: 0; border-radius: 999px; padding: 12px 18px;
  background: var(--red); color: #fff; font-weight: 700; font-size: 1rem;
}
.primary-btn:hover { background: var(--red-dark); }
.primary-btn:disabled { background: #c9b8ae; cursor: not-allowed; }
.primary-btn.wide { width: 100%; }

/* ---------- Cart ---------- */
.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-item { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.cart-item-main { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 700; }
.cart-item-opts { font-size: 0.8rem; color: var(--muted); }
.cart-item-price { font-weight: 700; color: var(--red); min-width: 48px; text-align: right; }
.checkout h3 { margin-top: 18px; font-size: 1rem; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
.total-row strong { font-size: 1.3rem; color: var(--red); }

/* ---------- Done ---------- */
.done { text-align: center; }
.done-icon {
  width: 64px; height: 64px; margin: 8px auto 12px; border-radius: 50%;
  background: #e6f4ea; color: var(--green); font-size: 2rem; display: grid; place-items: center; font-weight: 900;
}
.order-no { margin: 8px 0 0; }
.order-no strong { font-size: 1.5rem; color: var(--red); letter-spacing: 1px; }
.done-pickup { font-weight: 700; margin: 4px 0 12px; }
.order-detail { text-align: left; background: #faf6f1; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 0.9rem; }
.order-detail .row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.order-detail .row small { display: block; color: var(--muted); }
.order-detail .sum { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; font-weight: 700; }

.orders-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.order-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.order-card header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.order-card .order-detail { margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); z-index: 100;
  background: rgba(40, 25, 15, 0.92); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 0.9rem; opacity: 0; pointer-events: none; transition: 0.2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
