:root {
  --brown: #3E261E;
  --brown-soft: #5a3d32;
  --blue: #98DCFF;
  --blue-soft: #d9f1ff;
  --cream: #F5EFE4;
  --paper: #FFFCF7;
  --line-green: #06C755;
  --text: #3E261E;
  --muted: #7d6a62;
  --border: #e6dccd;
  --danger: #b3261e;
  /* role tokens: themes (e.g. halloween.css) override these */
  --ink: var(--brown);           /* accent text and outlines on light surfaces */
  --on-dark: var(--paper);       /* text on dark (brown) fills */
  --on-accent: var(--brown);     /* text on blue fills */
  --field: #fff;                 /* inputs, chips, small buttons */
  --panel: rgba(255, 255, 255, .45);
  --close-bg: rgba(255, 252, 247, .9);
  --warn-bg: #fde7c7;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(62, 38, 30, .12);
  --font: "Be Vietnam Pro", "IBM Plex Sans Thai", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 0 22px;
  border: 0; border-radius: 999px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brown); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-line { background: var(--line-green); color: #fff; }
.grow { flex: 1; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brown); color: var(--blue);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 500; letter-spacing: .02em; }
.brand img { border-radius: 10px; }
.member-btn {
  display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 4px 14px 4px 4px;
  border: 1.5px solid rgba(152, 220, 255, .5); border-radius: 999px;
  background: transparent; color: var(--blue); font: inherit; cursor: pointer;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue) center/cover no-repeat;
  display: grid; place-items: center; color: var(--on-accent); font-weight: 600; font-size: .9rem;
}

/* ---------- hero ---------- */
.hero {
  display: grid; gap: 24px;
  padding: 32px 16px 40px;
  background: var(--brown); color: var(--on-dark);
}
.eyebrow { margin: 0 0 8px; color: var(--blue); text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; }
.hero h1 { font-size: clamp(2rem, 7vw, 3.4rem); }
.semi { color: var(--blue); margin-left: .1em; }
.lead { color: #e9ddd6; max-width: 34ch; margin: 0 0 24px; }
.hero .btn-primary { background: var(--blue); color: var(--on-accent); }
.hero-photo img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: var(--radius);
}

/* ---------- active order banner ---------- */
.active-order {
  margin: 16px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--blue); border-radius: var(--radius); cursor: pointer;
}
.active-order strong { font-size: 1.1rem; }

/* ---------- menu ---------- */
.menu-section { padding: 32px 16px 24px; max-width: 1080px; margin: 0 auto; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 1.6rem; }
.tabs { display: flex; gap: 8px; overflow-x: auto; min-width: 0; max-width: 100%; }
.tab {
  min-height: 40px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--brown); color: var(--blue); }

.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); text-align: left;
  font: inherit; color: inherit; padding: 0; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: center 70%; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card-name { font-weight: 600; }
.card-th { color: var(--muted); font-size: .88rem; }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 600; }
.add-icon {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brown); color: var(--blue); font-size: 1.3rem; line-height: 1;
}
.card[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- member promo ---------- */
.member-promo {
  margin: 16px; padding: 24px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  background: var(--blue-soft); border-radius: var(--radius);
  max-width: 1048px;
}
@media (min-width: 1080px) { .member-promo { margin: 16px auto; } }
.member-promo p { margin: 0; color: var(--brown-soft); }

.footer { padding: 40px 16px 120px; text-align: center; }
.footer img { margin: 0 auto 8px; border-radius: 12px; }
.footer p { margin: 2px 0; }

/* ---------- cart bar ---------- */
.cart-bar {
  position: fixed; z-index: 20; left: 16px; right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--brown); color: var(--blue);
  font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
}
.cart-count {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  display: grid; place-items: center; background: var(--blue); color: var(--on-accent); font-size: .9rem;
}
.cart-total { margin-left: auto; }

/* ---------- sheets (dialogs) ---------- */
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: 24px 24px 0 0;
  background: var(--paper); color: var(--text);
}
.sheet::backdrop { background: rgba(30, 18, 14, .55); }
.sheet[open] { animation: slide-up .22s ease-out; }
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 24px; }
}
.sheet-body { position: relative; display: flex; flex-direction: column; max-height: 92dvh; margin: 0; }
.sheet-pad { padding: 24px 20px 8px; overflow-y: auto; }
.sheet-foot {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 20px; padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--paper);
}
.close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--close-bg); color: var(--ink);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.item-photo { width: 100%; aspect-ratio: 16 / 11; object-fit: cover; object-position: center 65%; flex-shrink: 0; }
#itemForm { overflow-y: auto; }
#itemForm .sheet-pad { overflow: visible; }

.opt-group { border: 0; padding: 0; margin: 18px 0 0; }
.opt-group legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.opt-group legend small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--border); cursor: pointer; background: var(--field);
}
.chip input:checked + span { border-color: var(--ink); background: var(--blue-soft); font-weight: 500; }
.chip input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.chip em { font-style: normal; color: var(--muted); font-size: .85rem; }

.field { display: grid; gap: 6px; margin-top: 16px; }
.field span { font-weight: 500; font-size: .92rem; }
.field input, .field select, .field textarea {
  min-height: 46px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--field); color: var(--text); font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; }

.stepper { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 999px; }
.stepper button {
  width: 44px; height: 44px; border: 0; background: transparent;
  font-size: 1.3rem; color: var(--ink); cursor: pointer;
}
.stepper output { min-width: 24px; text-align: center; font-weight: 600; }

.cart-lines { list-style: none; padding: 0; margin: 8px 0 0; }
.cart-line { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.cart-line img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; }
.cart-line .opts { color: var(--muted); font-size: .85rem; }
.cart-line .line-actions { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.cart-line .line-actions button {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--field); color: var(--ink); cursor: pointer; font-size: 1rem; line-height: 1;
}
.cart-line .line-actions span { min-width: 22px; text-align: center; }

.reward { display: flex; gap: 10px; align-items: center; margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--blue-soft); cursor: pointer; }
.reward input { width: 20px; height: 20px; accent-color: var(--ink); }
.hint { font-size: .88rem; color: var(--muted); margin: 12px 0 0; }
.hint button { border: 0; background: none; padding: 0; color: var(--ink); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

.totals { margin: 16px 0 0; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; }
.totals .grand { font-weight: 600; font-size: 1.15rem; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 10px; }
.totals .grand dt { color: var(--text); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: .9rem; }

/* ---------- member card ---------- */
.member-card {
  position: relative; overflow: hidden;
  padding: 22px; border-radius: var(--radius);
  background: var(--brown); color: var(--on-dark);
}
.member-card::after {
  content: ";"; position: absolute; right: 18px; bottom: -40px;
  font-size: 9rem; line-height: 1; color: var(--blue); opacity: .9; font-weight: 600;
}
.member-card .who { display: flex; align-items: center; gap: 12px; }
.member-card .avatar { width: 48px; height: 48px; font-size: 1.2rem; }
.member-card .points { font-size: 2.4rem; font-weight: 600; color: var(--blue); margin: 16px 0 0; line-height: 1; }
.progress { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .18); margin: 12px 0 6px; max-width: 70%; }
.progress div { height: 100%; border-radius: inherit; background: var(--blue); }
.history { list-style: none; padding: 0; margin: 8px 0 0; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.history .meta { color: var(--muted); font-size: .85rem; }

/* ---------- status ---------- */
.order-number { font-size: 3rem; font-weight: 600; letter-spacing: .04em; margin: 4px 0; }
.steps { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.steps li::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
}
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--ink); border-color: var(--ink); }
.steps li.current { color: var(--text); font-weight: 600; }
.steps li.current::before { background: var(--blue); border-color: var(--ink); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--blue-soft); font-size: .8rem; font-weight: 500; }
.badge.ready { background: var(--blue); }

.toast {
  position: fixed; left: 50%; bottom: 90px; z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 999px;
  background: var(--brown); color: var(--blue); font-weight: 500;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  .hero { grid-template-columns: 1.1fr .9fr; align-items: center; padding: 56px max(24px, calc((100% - 1048px) / 2)); }
  .hero-photo img { aspect-ratio: 4 / 4.6; }
  .menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
}
@media (min-width: 1000px) {
  .menu-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- pickup / delivery ---------- */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin: 20px 0 0; padding: 4px; border: 0;
  background: var(--cream); border-radius: 14px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid; place-items: center; min-height: 42px;
  border-radius: 10px; font-weight: 500; cursor: pointer; color: var(--muted);
}
.segmented input:checked + span { background: var(--brown); color: var(--blue); }
.segmented input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.field textarea { padding: 12px 14px; min-height: auto; resize: vertical; }
.notice { margin: 16px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--blue-soft); font-size: .9rem; }
.locate { width: 100%; min-height: 44px; }
.locate::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 3px var(--ink); }
.map { width: 100%; height: 180px; border: 0; border-radius: 12px; margin-top: 4px; }

.driver {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  margin: 16px 0 0; padding: 14px 16px; border-radius: var(--radius);
  background: var(--brown); color: var(--on-dark);
}
.driver small { color: var(--blue); }
.driver .btn { min-height: 40px; padding: 0 16px; background: var(--blue); color: var(--on-accent); }
.deliver-to { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--cream); font-size: .92rem; }
.deliver-to a { color: var(--ink); font-weight: 500; }
.hint a { color: var(--ink); font-weight: 500; }

/* ---------- payment ---------- */
.pay { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.pay h4 { margin: 0; font-size: 1.05rem; }
.pay .segmented { margin-top: 12px; }
#transferBox { display: grid; justify-items: center; gap: 10px; margin-top: 14px; text-align: center; }
.pay-amount { margin: 0; }
.pay-amount strong { display: block; font-size: 2rem; color: var(--ink); }
.pay-qr { width: min(260px, 80%); border-radius: 16px; box-shadow: var(--shadow); }
.save-qr { min-height: 40px; }
.slip-drop {
  width: 100%; display: grid; place-items: center; gap: 8px;
  padding: 18px; border: 2px dashed var(--border); border-radius: 14px;
  background: var(--field); cursor: pointer; color: var(--ink); font-weight: 500;
}
.slip-drop:focus-within { border-color: var(--ink); }
.slip-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slip-drop.has-slip { border-style: solid; border-color: var(--ink); background: var(--blue-soft); }
.slip-drop img { max-height: 220px; border-radius: 10px; }
.pay-state { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 999px; background: var(--blue-soft); font-size: .88rem; font-weight: 500; }

/* ---------- option cards (e.g. matcha cultivar) ---------- */
.price small { font-weight: 400; color: var(--muted); font-size: .8rem; }
.opt-cards { display: grid; gap: 8px; }
.opt-card input { position: absolute; opacity: 0; pointer-events: none; }
.opt-card > span {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--field);
}
.opt-card strong { font-weight: 600; }
.opt-card small { color: var(--muted); }
.opt-card .notes { grid-column: 1; font-size: .82rem; color: var(--muted); letter-spacing: .01em; }
.opt-card .opt-price { grid-column: 2; grid-row: 1 / span 2; font-weight: 600; }
.opt-card input:checked + span { border-color: var(--ink); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--ink); }
.opt-card input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.opt-card.sold-out > span { cursor: not-allowed; opacity: .55; }
.opt-card.sold-out .opt-price { color: var(--danger); font-size: .85rem; letter-spacing: .04em; }
.chip input:disabled + span { opacity: .5; cursor: not-allowed; }
.card { position: relative; }
.card-badge {
  position: absolute; top: 10px; left: 10px; z-index: 1;
  padding: 4px 10px; border-radius: 999px;
  background: #ffd84d; color: var(--brown); font-size: .8rem; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
