:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #171717;
  --muted: #62636a;
  --line: #e6e6e8;
  --soft: #f5f5f6;
  --yellow: #ffc928;
  --yellow-strong: #f5b900;
  --burgundy: #7c1326;
  --green: #19aa68;
  --red: #d92d20;
  --radius-sm: 12px;
  --radius-md: 18px;
  --shadow: 0 12px 36px rgba(23, 23, 23, .12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { width: 100%; max-width: 720px; min-height: 100dvh; margin: 0 auto; background: var(--surface); }
.view { min-height: 100dvh; }

.store-header { display: grid; grid-template-columns: 72px 1fr 48px; gap: 13px; align-items: center; padding: 18px 18px 4px; }
.store-logo { width: 72px; height: 58px; object-fit: contain; }
.store-heading { min-width: 0; }
.store-heading h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
.store-status { display: flex; align-items: center; gap: 7px; margin: 5px 0 0; color: var(--green); font-size: 14px; font-weight: 600; }
.store-status span { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.store-status.closed { color: var(--red); }

.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 50%; cursor: pointer; }
.icon-button:active { background: var(--soft); transform: scale(.97); }
.icon-button svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.delivery-notice { margin: 2px 18px 14px 103px; color: var(--muted); font-size: 13px; line-height: 1.45; }

.search-wrap { padding: 6px 18px 4px; }
.search-wrap input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 15px; padding: 0 16px; background: var(--soft); outline: none; }
.search-wrap input:focus { border-color: var(--yellow-strong); box-shadow: 0 0 0 3px rgba(255,201,40,.25); }

.category-nav { display: flex; gap: 9px; overflow-x: auto; padding: 7px 18px 15px; border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: 0; z-index: 4; background: rgba(255,255,255,.97); }
.category-nav::-webkit-scrollbar { display: none; }
.category-button { flex: none; min-height: 42px; border: 0; border-radius: 21px; padding: 0 18px; background: var(--soft); font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.category-button.selected { background: var(--yellow); font-weight: 800; }

.menu-list { padding: 4px 18px 126px; }
.menu-item { display: grid; grid-template-columns: 132px minmax(0,1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); min-height: 164px; }
.menu-photo { width: 132px; height: 132px; border-radius: 16px; overflow: hidden; background: #f0f0f0; align-self: center; }
.menu-photo img { width: 100%; height: 100%; object-fit: contain; background: #f3f3f3; }
.menu-copy { min-width: 0; display: flex; flex-direction: column; }
.menu-copy h2 { margin: 1px 0 3px; font-size: 18px; line-height: 1.35; font-weight: 800; }
.menu-option { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.menu-note { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.menu-price-row { margin-top: auto; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-price { color: var(--burgundy); font-size: 19px; font-weight: 800; }
.add-button, .quantity-button { width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-size: 28px; line-height: 1; }
.add-button { background: var(--yellow); }
.quantity-control { display: flex; align-items: center; gap: 7px; }
.quantity-control strong { min-width: 24px; text-align: center; font-size: 17px; }
.quantity-button { background: var(--soft); font-size: 23px; }
.quantity-button.plus { background: var(--yellow); }
.add-button:active, .quantity-button:active { transform: scale(.94); }

.cart-bar { position: fixed; z-index: 10; left: 50%; bottom: 0; transform: translateX(-50%); width: min(720px,100%); min-height: 88px; padding: 13px 18px calc(13px + var(--safe-bottom)); background: var(--burgundy); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: 0 -8px 24px rgba(42,0,8,.18); }
.cart-summary { display: flex; flex-direction: column; gap: 2px; }
.cart-count { font-size: 13px; opacity: .85; }
.cart-summary strong { font-size: 19px; }
.primary-button { min-width: 154px; height: 54px; border: 0; border-radius: 28px; background: var(--yellow); font-size: 17px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.primary-button svg, .submit-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.checkout-view { padding-bottom: calc(100px + var(--safe-bottom)); }
.checkout-header { min-height: 76px; display: grid; grid-template-columns: 48px 1fr 62px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 8; }
.checkout-header h1 { margin: 0; text-align: center; font-size: 21px; font-weight: 800; }
.checkout-logo { width: 62px; height: 48px; object-fit: contain; }
.checkout-content { padding: 0 18px 28px; }
.checkout-content section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.checkout-content section:last-of-type { border-bottom: 0; }
.checkout-content h2 { margin: 0 0 15px; font-size: 19px; line-height: 1.35; font-weight: 800; }
.checkout-content h2 span { color: var(--muted); font-weight: 500; }
.checkout-item { display: grid; grid-template-columns: 74px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 10px 0; }
.checkout-item img { width: 74px; height: 74px; border-radius: 13px; object-fit: contain; background: var(--soft); }
.checkout-item h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.checkout-item p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.checkout-item .item-price { color: var(--burgundy); font-weight: 800; margin-top: 5px; }
.checkout-item .quantity-control { gap: 3px; }
.checkout-item .quantity-button { width: 38px; height: 38px; }
.subtotal-row { display: flex; justify-content: space-between; padding-top: 15px; margin-top: 8px; border-top: 1px solid var(--line); font-size: 16px; }
.subtotal-row strong { color: var(--burgundy); font-size: 19px; }

.slot-list { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.slot-button { flex: none; min-height: 48px; border: 1px solid transparent; border-radius: 25px; padding: 0 17px; background: var(--soft); font-size: 14px; font-weight: 600; cursor: pointer; }
.slot-button.selected { background: var(--yellow); border-color: var(--yellow-strong); font-weight: 800; }
.slot-button:disabled { color: #999; opacity: .7; }
.no-slot { margin: 0; padding: 14px; border-radius: var(--radius-sm); background: #fff3f2; color: #8b1b13; font-size: 14px; }

.field { margin: 0 0 17px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; }
.field label em { color: var(--red); font-style: normal; }
.field label span { color: var(--muted); font-weight: 400; }
.field input, .field textarea { width: 100%; border: 1px solid #d4d5d8; border-radius: var(--radius-sm); padding: 13px 14px; background: #fff; outline: none; font-size: 16px; color: var(--text); }
.field input { height: 50px; }
.field textarea { resize: vertical; min-height: 92px; }
.field input:focus, .field textarea:focus { border-color: var(--yellow-strong); box-shadow: 0 0 0 3px rgba(255,201,40,.22); }
.field.invalid input, .field.invalid textarea { border-color: var(--red); }
.field-error { margin: 6px 0 0; color: var(--red); font-size: 12px; line-height: 1.45; }

.location-button { width: 100%; min-height: 58px; display: grid; grid-template-columns: 30px 1fr 24px; gap: 9px; align-items: center; border: 1.5px solid var(--green); border-radius: var(--radius-sm); padding: 8px 13px; background: #fff; color: var(--text); text-align: left; font-weight: 700; cursor: pointer; }
.location-button svg { width: 28px; height: 28px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.location-button .chevron { width: 21px; stroke: var(--text); }
.location-button.loading { opacity: .65; pointer-events: none; }
.location-status { margin: 9px 0 0; font-size: 13px; font-weight: 600; line-height: 1.45; }
.location-status.success { color: var(--green); }
.location-status.error { color: var(--red); }

.totals { display: grid; gap: 10px; }
.totals > div { display: flex; justify-content: space-between; gap: 20px; color: #393a40; }
.totals .grand-total { padding-top: 12px; border-top: 1px solid var(--line); color: var(--text); font-size: 21px; }
.grand-total strong:last-child { color: var(--burgundy); font-size: 24px; }
.policy-check { display: grid; grid-template-columns: 25px 1fr; gap: 10px; align-items: start; margin-top: 22px; cursor: pointer; color: #45464c; font-size: 13px; line-height: 1.5; }
.policy-check input { position: absolute; opacity: 0; }
.checkmark { width: 25px; height: 25px; border: 2px solid #c8c9cd; border-radius: 7px; display: grid; place-items: center; }
.policy-check input:checked + .checkmark { background: var(--yellow); border-color: var(--yellow); }
.policy-check input:checked + .checkmark::after { content: ""; width: 10px; height: 6px; border-left: 2px solid #111; border-bottom: 2px solid #111; transform: rotate(-45deg) translateY(-1px); }
.checkout-action { position: fixed; z-index: 9; left: 50%; bottom: 0; transform: translateX(-50%); width: min(720px,100%); padding: 12px 18px calc(12px + var(--safe-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
.submit-button { width: 100%; min-height: 58px; border: 0; border-radius: 29px; background: var(--yellow); color: #111; font-size: 18px; font-weight: 800; display: flex; justify-content: center; align-items: center; gap: 8px; cursor: pointer; }
.submit-button:disabled { background: #d7d7d9; color: #777; cursor: not-allowed; }

.center-state { min-height: 100dvh; padding: 40px 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.center-state h1 { margin: 20px 0 8px; font-size: 25px; }
.center-state p { margin: 0; max-width: 390px; color: var(--muted); line-height: 1.65; }
.secondary-button { min-height: 48px; margin-top: 22px; padding: 0 22px; border: 1px solid #c9cace; border-radius: 24px; background: #fff; font-weight: 700; cursor: pointer; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--soft); border-top-color: var(--yellow-strong); border-radius: 50%; animation: spin .8s linear infinite; }
.success-icon { width: 76px; height: 76px; border-radius: 50%; background: #e9f8f1; color: var(--green); display: grid; place-items: center; }
.success-icon svg { width: 42px; height: 42px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.success-state .submit-button { max-width: 360px; margin-top: 28px; }
.closed-logo { width: 130px; max-height: 110px; object-fit: contain; }
.empty-state { padding: 70px 24px; text-align: center; }
.empty-state h2 { margin: 0 0 6px; }
.empty-state p { color: var(--muted); }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(104px + var(--safe-bottom)); transform: translateX(-50%); width: calc(100% - 36px); max-width: 520px; padding: 13px 16px; border-radius: var(--radius-sm); background: #222; color: #fff; text-align: center; font-size: 13px; box-shadow: var(--shadow); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 620px) {
  .app-shell { box-shadow: 0 0 0 1px var(--line), 0 20px 80px rgba(0,0,0,.08); }
  .store-header { padding-left: 26px; padding-right: 26px; }
  .delivery-notice { margin-left: 111px; }
  .menu-list, .checkout-content { padding-left: 26px; padding-right: 26px; }
  .menu-item { grid-template-columns: 164px minmax(0,1fr); }
  .menu-photo { width: 164px; height: 146px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
