:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --ink: #1f2a1c;
  --muted: #6b7466;
  --line: #e4ded1;
  --green: #2f6b3a;
  --green-soft: #e3efe2;
  --amber: #c97a12;
  --amber-soft: #fbefd9;
  --red: #b3372c;
  --red-soft: #f9e3e0;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* กัน .chat-bar ฯลฯ ที่ตั้ง display เองไปทับ hidden */
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'Noto Sans Thai', system-ui, sans-serif; font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(76px + var(--safe-b)); }
.top { position: sticky; top: 0; z-index: 5; background: var(--green); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.top small { opacity: .85; }
.top select { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px; padding: 4px 8px; }
.top select option { color: var(--ink); }
.section { padding: 12px 16px; }
.section h2 { font-size: 17px; margin: 4px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.price { font-weight: 700; color: var(--green); white-space: nowrap; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--green); color: #fff; min-height: 48px; cursor: pointer; }
.btn:disabled { opacity: .45; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn.amber { background: var(--amber); }
.btn.red { background: var(--red); }
.btn.big { min-height: 64px; font-size: 19px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 48px; }
label.f { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
label.f .input { margin-top: 4px; color: var(--ink); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: center; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs .inner { display: flex; width: 100%; max-width: 520px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 0 12px; font-size: 13px; color: var(--muted); position: relative; }
.tabs button b { display: block; font-size: 20px; line-height: 1.1; }
.tabs button.on { color: var(--green); font-weight: 700; }
.badge { position: absolute; top: 4px; left: 55%; background: var(--red); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 6px; }
.live { position: relative; aspect-ratio: 9 / 12; max-height: 52vh; width: 100%; background: #142012; color: #cfe3cb; display: grid; place-items: center; text-align: center; }
.live .tag { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.live video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.live .tag.off { background: #4d5a49; }
.live .viewers { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.live .unmute { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); }
.live .chat { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; pointer-events: none; }
.chat-line { background: rgba(0,0,0,.5); color: #fff; font-size: 13px; padding: 3px 9px; border-radius: 10px; max-width: 90%; text-align: left; }
.chat-line b { color: #ffd98a; font-weight: 600; }
.chat-line.staff b { color: #9fe3a8; }
.chat-bar { display: flex; gap: 8px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-bar .input { min-height: 42px; padding: 8px 12px; }
.pinned { margin: 10px 16px 0; border: 2px solid var(--amber); background: var(--amber-soft); }
.live-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 10px 16px; background: #fff; }
/* ---------- หน้ารวมตลาด ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 15px; min-height: 40px; }
.chip-btn.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.chips.sub .chip-btn { font-size: 14px; min-height: 36px; padding: 6px 12px; }
.hero { padding: 14px 16px 6px; }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.tiles { display: flex; gap: 10px; overflow-x: auto; padding: 0 16px 6px; scrollbar-width: none; }
.tiles::-webkit-scrollbar { display: none; }
.tiles.grid { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
.tile { flex: none; width: 168px; border-radius: var(--radius); overflow: hidden; background: #fff; border: 1px solid var(--line); text-align: left; padding: 0; cursor: pointer; }
.tiles.grid .tile { width: auto; }
.tile .poster { position: relative; aspect-ratio: 3 / 4; display: grid; place-items: center; font-size: 56px; color: #fff; }
.tile .poster .tag { position: absolute; top: 8px; left: 8px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.tile .poster .stat { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 6px; }
.tile .poster .here { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 8px; text-align: left; line-height: 1.3; }
.tile .info { padding: 8px 10px 10px; }
.tile .info b { display: block; font-size: 14px; line-height: 1.3; }
.tile .info span { font-size: 12px; color: var(--muted); }
.mcard { display: flex; gap: 12px; align-items: flex-start; }
.mcard .cover { width: 64px; height: 64px; border-radius: 14px; background: var(--green-soft); display: grid; place-items: center; font-size: 34px; flex: none; }
.mcard h3 { margin: 0; font-size: 17px; }
.star { border: 0; background: none; font-size: 24px; color: var(--amber); padding: 4px; min-width: 44px; min-height: 44px; }
.banner { background: var(--amber-soft); border: 1px solid #f0d7a8; border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.mhead { padding: 16px; background: #fff; border-bottom: 1px solid var(--line); }
.mhead .cover { width: 72px; height: 72px; font-size: 40px; }
.back { border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 20px; border-radius: 10px; min-width: 44px; min-height: 40px; }
.here-bar { background: var(--green-soft); color: var(--green); font-weight: 600; padding: 8px 16px; font-size: 15px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 28px; font-weight: 700; flex: none; }
.menu-row { display: flex; align-items: center; gap: 12px; width: 100%; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; text-align: left; font-size: 16px; min-height: 56px; }
.menu-row:last-child { border-bottom: 0; }
.menu-row .ic { width: 28px; text-align: center; font-size: 20px; }
.menu-row .go { margin-left: auto; color: var(--muted); }
.menu { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.minbar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.minbar span { display: block; height: 100%; background: var(--amber); }
html.big-text body { font-size: 19px; }
html.big-text .muted, html.big-text .tile .info span { font-size: 16px; }
html.big-text .chip-btn { font-size: 17px; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--green-soft); display: grid; place-items: center; font-size: 26px; flex: none; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); max-height: 90dvh; overflow: auto; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); z-index: 30; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; font-size: 15px; }
.steps { display: flex; gap: 4px; margin: 8px 0; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps span.done { background: var(--green); }
.qr { width: 180px; height: 180px; margin: 10px auto; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.code { font-size: 28px; font-weight: 800; letter-spacing: 1px; }
.pin { font-size: 32px; letter-spacing: 12px; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
img.proof { width: 100%; border-radius: 10px; margin-top: 8px; }

/* หมวดสินค้า */
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 16px 8px; }
.cat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 4px; text-align: center; cursor: pointer; font: inherit; font-size: 13px; line-height: 1.25; min-height: 76px; }
.cat b { display: block; font-size: 26px; margin-bottom: 4px; }
.cat.on { border-color: var(--green); background: var(--green-soft); }
@media (min-width: 560px) { .cats { grid-template-columns: repeat(6, 1fr); } }
.cats.strip { display: flex; overflow-x: auto; scrollbar-width: none; }
.cats.strip .cat { flex: none; width: 78px; min-height: 68px; }
