/* ===== POS cafe theme ===== */
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #f7f5f2;
  --card: #fff;
  --fg: #2f2d2c;
  --muted: #9d9893;
  --line: #ede9e4;
  --accent: #c67c4e;       /* coffee */
  --accent-soft: #f6ece5;
  --r: 18px;
  --shadow: 0 2px 10px rgba(47, 45, 44, .06);
}

html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  color: var(--fg);
  background: var(--bg);
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

input:not([type=checkbox]):not([type=file]), textarea {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; /* 16px กัน iOS ซูม */
  border: 1px solid transparent; border-radius: 14px; background: var(--card); color: var(--fg);
  resize: none; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 20px 0 10px; }
.brand { padding: 0 20px 14px; }
.brand h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.brand p { margin-top: 2px; }

.search { display: flex; align-items: center; gap: 10px; margin: 0 16px 12px; padding: 0 14px;
  background: var(--card); border-radius: 14px; color: var(--muted); box-shadow: var(--shadow); }
.search input { padding: 12px 0; background: transparent; border: 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 16px; border-radius: 999px; background: var(--card); color: var(--fg);
  text-decoration: none; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow); }
.chip.on { background: var(--accent); color: #fff; }

/* ---------- product grid ---------- */
section { scroll-margin-top: 190px; }
#menu h2 { font-size: 17px; font-weight: 700; padding: 18px 20px 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px; }

.item { position: relative; display: flex; flex-direction: column; background: var(--card);
  border-radius: var(--r); padding: 8px 8px 12px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s; }
.item:active { transform: scale(.98); }
.item .thumb { width: 100%; aspect-ratio: 1; border-radius: 14px; object-fit: cover; display: block; font-size: 40px; }
.item h3 { font-size: 15px; font-weight: 600; margin: 10px 4px 0; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .desc { margin: 2px 4px 0; -webkit-line-clamp: 1; }
.item .foot { display: flex; align-items: center; justify-content: space-between; margin: auto 4px 0; padding-top: 10px; }
.item .plus { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 20px; line-height: 1; }
.qty-badge { position: absolute; top: 14px; right: 14px; min-width: 26px; height: 26px; padding: 0 7px;
  border-radius: 999px; background: var(--fg); color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center; }
.item.soldout { cursor: default; }
.item.soldout .thumb, .item.soldout h3, .item.soldout .desc { opacity: .4; }
.item.soldout .plus { display: none; }
.soldout-tag { position: absolute; top: 14px; left: 14px; padding: 4px 10px; border-radius: 999px;
  background: var(--fg); color: #fff; font-size: 12px; }

.desc { font-size: 13px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.desc.full { display: block; font-size: 14px; margin-top: 10px; }
.price { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ph { display: grid; place-items: center; background: var(--accent-soft); color: #dfbfa8; font-weight: 700; }

/* ---------- cart bar ---------- */
.cart-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 536px; margin: 0 auto; z-index: 6; display: flex; align-items: center; gap: 12px;
  height: 58px; padding: 0 20px; border: 0; border-radius: 18px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 600; box-shadow: 0 10px 24px rgba(198, 124, 78, .35); }
.cart-bar .badge { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: #fff;
  color: var(--accent); display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.cart-bar #total { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- bottom sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; }
.backdrop { position: absolute; inset: 0; background: rgba(30, 26, 22, .45); opacity: 0; transition: opacity .25s; }
.panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: var(--bg);
  border-radius: 24px 24px 0 0; overflow: hidden; transform: translateY(100%); transition: transform .25s ease-out; }
.sheet.open .backdrop { opacity: 1; }
.sheet.open .panel { transform: none; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.pad { padding: 20px; }
.x { position: absolute; top: 12px; right: 12px; z-index: 1; width: 36px; height: 36px; border: 0;
  border-radius: 50%; background: rgba(255, 255, 255, .92); font-size: 22px; line-height: 1; box-shadow: var(--shadow); }

.hero { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; font-size: 72px; }
.hero.ph { aspect-ratio: 16 / 8; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.title { font-size: 21px; font-weight: 700; }
.title-row .price { font-size: 19px; color: var(--accent); }

.field { margin-top: 22px; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.label .muted { font-weight: 400; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { min-height: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font-size: 14px; }
.seg button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.sheet-foot { display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card);
  box-shadow: 0 -4px 16px rgba(47, 45, 44, .05); }
.primary { flex: 1; min-height: 54px; border: 0; border-radius: 16px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; }
.primary:disabled { opacity: .5; }

.stepper { display: flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 14px; padding: 4px; }
.stepper button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--card); font-size: 20px; }
.stepper span { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper.sm button { width: 32px; height: 32px; font-size: 18px; }
.stepper.sm span { min-width: 24px; }

.line { display: flex; gap: 12px; align-items: center; padding: 12px; margin-top: 10px;
  background: var(--card); border-radius: 16px; }
.mini { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; font-size: 20px; }
.grow { flex: 1; min-width: 0; }
.line .name { font-weight: 600; }
.line .price { font-size: 14px; margin-top: 4px; }
.total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* placeholder ต้องเป็น grid เสมอ (ชนะ display:block ของ .thumb/.hero) */
.ph { display: grid !important; }

/* ไอคอน SVG ให้อยู่กลางปุ่มพอดี */
.plus, .stepper button, .x { display: grid; place-items: center; padding: 0; }
.plus svg, .stepper button svg, .x svg { display: block; pointer-events: none; }
.plus svg { width: 18px; height: 18px; }
.stepper.sm button svg { width: 16px; height: 16px; }

/* ราคาเพิ่มของตัวเลือก */
.seg button { line-height: 1.3; padding: 8px; }
.seg button small { font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.seg button.on small { color: var(--accent); }
