/* Menu khách — ưu tiên điện thoại. Ba giao diện: am-ap (ấm áp), tuoi-mat (tươi mát), toi-sang (tối sang trọng).
   Mỗi giao diện chỉ khác nhau ở biến màu/bo góc và vài quy tắc bố cục bên dưới. */
:root, [data-theme="am-ap"] {
  --bg: #faf9f6; --surface: #ffffff; --text: #1c1917; --muted: #78716c; --line: #ece9e4;
  --accent: #d9381e; --on-accent: #ffffff; --radius: 18px; --radius-sm: 12px; --chip: #ffffff;
}
[data-theme="tuoi-mat"] {
  --bg: #ffffff; --surface: #ffffff; --text: #14231b; --muted: #6b7a72; --line: #e6efe9;
  --accent: #0f6b3a; --on-accent: #ffffff; --radius: 14px; --radius-sm: 10px; --chip: #f1f7f3;
}
[data-theme="toi-sang"] {
  --bg: #1c1917; --surface: #292524; --text: #f5f5f4; --muted: #a8a29e; --line: #3a332f;
  --accent: #fbbf24; --on-accent: #1c1917; --radius: 18px; --radius-sm: 12px; --chip: #292524;
}
:root { --ok: #16a34a; --bad: #dc2626; }
/* biến suy ra phải tính ngay trên body (nơi chứa data-theme) để lấy đúng màu của giao diện */
body { --accent-d: color-mix(in srgb, var(--accent) 82%, #000); --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; padding-bottom: 96px; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 14px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- thanh thông báo ---- */
.bar { text-align: center; font-size: 13px; font-weight: 600; padding: 8px 14px; background: color-mix(in srgb, #f59e0b 22%, var(--surface)); color: var(--text); }
.bar.bad { background: var(--bad); color: #fff; }

/* ---- đầu trang ---- */
.hdr { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.hdr-in { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); background: var(--surface); }
.brand h1 { font-size: 16px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-actions { display: flex; gap: 8px; }
.homebar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600; text-decoration: none; }
.homebar.hidden { display: none; }
.homebar .ic { width: 16px; height: 16px; }
footer.ft .powered { margin-top: 6px; }
footer.ft .powered a { color: inherit; opacity: .7; text-decoration: underline; text-underline-offset: 2px; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; position: relative; text-decoration: none; color: var(--text); }
.cnt { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ---- danh mục ---- */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 6px; scrollbar-width: none; position: sticky; top: 58px; z-index: 20; background: var(--bg); }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; padding: 7px 14px; border-radius: 99px; background: var(--chip); border: 1px solid var(--line); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cat.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
[data-theme="tuoi-mat"] .cats { gap: 18px; border-bottom: 1px solid var(--line); padding: 10px 0 0; }
[data-theme="tuoi-mat"] .cat { background: none; border: 0; border-radius: 0; padding: 4px 0 10px; color: var(--muted); border-bottom: 2px solid transparent; }
[data-theme="tuoi-mat"] .cat.on { background: none; color: var(--accent); border-bottom-color: var(--accent); }

/* ---- hero (giao diện tối) ---- */
.hero { margin-top: 12px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); padding: 16px; position: relative; overflow: hidden; cursor: pointer; }
.hero small { font-weight: 700; font-size: 12px; opacity: .85; }
.hero h2 { font-size: 20px; font-weight: 800; margin: 3px 0 10px; max-width: 70%; }
.hero .btn-pill { background: var(--on-accent); color: var(--accent); border-radius: 99px; padding: 6px 14px; font-weight: 700; font-size: 13px; display: inline-block; }
.hero img { position: absolute; right: 0; top: 0; bottom: 0; width: 42%; height: 100%; object-fit: cover; opacity: .9; mask-image: linear-gradient(to right, transparent, #000 40%); -webkit-mask-image: linear-gradient(to right, transparent, #000 40%); }
[data-theme="am-ap"] .hero, [data-theme="tuoi-mat"] .hero { display: none; }

/* ---- món ---- */
.pg { display: grid; gap: 12px; padding: 12px 0 8px; }
.pg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pg-list { grid-template-columns: 1fr; gap: 0; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; cursor: pointer; display: flex; flex-direction: column; }
.pcard.out { opacity: .55; cursor: not-allowed; }
.pimg { position: relative; aspect-ratio: 4 / 3; background: var(--accent-soft); overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.pbody h3 { font-size: 14px; font-weight: 700; line-height: 1.25; }
.pdesc { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pfoot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.price { font-weight: 800; color: var(--accent); font-size: 14px; }
[data-theme="toi-sang"] .price { color: var(--accent); }
.padd { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; }
.padd .ic { width: 16px; height: 16px; stroke-width: 2.6; }
.tag { position: absolute; z-index: 1; top: 8px; left: 8px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; background: var(--accent); color: var(--on-accent); }
.tag.sold { background: var(--bad); color: #fff; left: auto; right: 8px; }

/* danh sách (tươi mát, tối sang): ảnh nhỏ bên cạnh */
.pg-list .pcard { flex-direction: row; border-radius: 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 12px 0; overflow: visible; }
.pg-list .pimg { width: 78px; height: 78px; aspect-ratio: auto; border-radius: var(--radius-sm); flex: none; }
.pg-list .pbody { padding: 0 10px 0 0; justify-content: center; }
[data-theme="tuoi-mat"] .pg-list .pcard { flex-direction: row-reverse; }
[data-theme="tuoi-mat"] .pg-list .pbody { padding: 0 0 0 0; padding-right: 12px; }
[data-theme="tuoi-mat"] .pg-list .padd { position: absolute; right: -4px; bottom: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--line); width: 26px; height: 26px; }
[data-theme="tuoi-mat"] .pg-list .pfoot { justify-content: flex-start; }
[data-theme="toi-sang"] .pg-list { gap: 8px; }
[data-theme="toi-sang"] .pg-list .pcard { background: var(--surface); border: 0; border-radius: var(--radius); padding: 9px; }
[data-theme="toi-sang"] .pg-list .pimg { width: 62px; height: 62px; }
[data-theme="toi-sang"] .pg-list .pbody { padding: 0 4px 0 12px; }
.pg-list .tag { top: 4px; left: 4px; font-size: 10px; padding: 2px 6px; }
.pg-list .tag.sold { right: auto; left: 4px; top: 4px; }
.pg-list .pimg { overflow: hidden; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 10px; }

footer.ft { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 14px; }

/* ---- thanh giỏ hàng cố định ---- */
.cartbar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; max-width: 560px; margin: 0 auto; background: var(--accent); color: var(--on-accent); border-radius: var(--radius); padding: 13px 16px; display: flex; align-items: center; gap: 10px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.cartbar .grow { flex: 1; text-align: left; }
[data-theme="tuoi-mat"] .cartbar { border-radius: 99px; left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); padding: 12px 22px; }

/* ---- sheet (bảng trượt) ---- */
.ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); color: var(--text); width: 100%; max-width: 560px; max-height: 94vh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-hd { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-hd h2 { font-size: 17px; font-weight: 800; }
.sheet-bd { overflow-y: auto; padding: 8px 16px 16px; flex: 1; }
.sheet-ft { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.xbtn { width: 34px; height: 34px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; }
.dimg { margin: -8px -16px 12px; aspect-ratio: 16 / 10; background: var(--accent-soft); position: relative; overflow: hidden; cursor: zoom-in; }
.dimg img { width: 100%; height: 100%; object-fit: cover; }
.thumbs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; }
.thumbs img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 2px solid transparent; opacity: .65; cursor: pointer; }
.thumbs img.on { border-color: var(--accent); opacity: 1; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-top: 10px; }
.sec h4 { margin: 0 0 8px; font-size: 13px; font-weight: 800; display: flex; justify-content: space-between; }
.opt { display: flex; align-items: center; justify-content: space-between; padding: 9px 4px; border-bottom: 1px solid var(--line); gap: 10px; cursor: pointer; }
.opt:last-child { border-bottom: 0; }
.opt input { accent-color: var(--accent); width: 18px; height: 18px; margin-right: 8px; }
.opt .l { display: flex; align-items: center; flex: 1; }
.opt .p { color: var(--muted); font-size: 13px; }
.chips2 { display: flex; flex-wrap: wrap; gap: 6px; }
.chips2 label { cursor: pointer; }
.chips2 input { position: absolute; opacity: 0; pointer-events: none; }
.chips2 span { display: inline-block; padding: 6px 12px; border-radius: 99px; background: var(--chip); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chips2 input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.inp { width: 100%; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.inp:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.lbl { display: block; font-size: 12px; font-weight: 800; margin: 14px 0 5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); font-weight: 800; }
.btn:hover { background: var(--accent-d); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { white-space: nowrap; background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.stepper { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
.stepper button { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.stepper b { min-width: 22px; text-align: center; }
.frow { display: flex; align-items: center; gap: 12px; }

/* ---- giỏ hàng ---- */
.line { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px; }
.line .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.line .m { font-size: 12px; color: var(--muted); margin: 3px 0 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg label { cursor: pointer; text-align: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 11px 6px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 13px; }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
[data-theme="toi-sang"] .seg input:checked + span { color: var(--text); }
.map { height: 170px; border-radius: var(--radius-sm); border: 1px solid var(--line); overflow: hidden; position: relative; margin-top: 8px; }
.gps { position: absolute; right: 8px; bottom: 8px; z-index: 500; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: 7px 12px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 5px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.sg { list-style: none; margin: 4px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 180px; overflow: auto; font-size: 13px; }
.sg li { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
/* tóm tắt đơn: như tờ bill giấy nhiệt (cùng ngôn ngữ với trang chủ) */
.sum { background: color-mix(in srgb, var(--surface) 70%, #fffdf8); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px; margin-top: 14px; font-size: 14px; }
.sum > div { display: flex; justify-content: space-between; padding: 3px 0; }
.sum > div span:last-child { font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-weight: 500; }
.sum .tot { border-top: 1px dashed var(--text); margin-top: 6px; padding-top: 9px; font-size: 17px; font-weight: 800; }
.sum .tot span:last-child { color: var(--accent); font-weight: 800; }
.rm { color: var(--bad); font-weight: 700; font-size: 12px; }

/* ---- cửa sổ giữa màn hình (thanh toán, thành công) ---- */
.ov.mid { align-items: center; padding: 16px; }
.dlg { background: var(--bg); color: var(--text); border-radius: 22px; padding: 22px 18px; width: 100%; max-width: 380px; text-align: center; animation: up .2s ease-out; }
.dlg .okc { width: 48px; height: 48px; border-radius: 50%; background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.dlg .okc .ic { width: 26px; height: 26px; stroke-width: 3; }
.dlg h3 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.qr { width: 190px; height: 190px; margin: 12px auto; background: #fff; border-radius: 14px; padding: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.qr img { width: 100%; height: 100%; object-fit: contain; }
.kv { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.kv b { text-align: right; }
.lb { background: rgba(0,0,0,.92); z-index: 200; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.lb img { max-width: 95%; max-height: 78vh; border-radius: 14px; }
.lb iframe { width: 100%; max-width: 640px; aspect-ratio: 16 / 9; border: 0; border-radius: 14px; background: #000; }
.lb p { color: #d6d3d1; font-size: 12px; margin-top: 12px; }

/* ---- máy tính: lưới rộng hơn, bảng trượt thành khung giữa/ngăn kéo ---- */
@media (min-width: 760px) {
  body { padding-bottom: 40px; }
  .pg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .pg-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  [data-theme="toi-sang"] .pg-list { column-gap: 12px; }
  .ov { align-items: center; }
  .sheet { border-radius: 22px; max-height: 90vh; }
  .cartbar { left: auto; right: 24px; bottom: 24px; width: 340px; margin: 0; max-width: none; }
  [data-theme="tuoi-mat"] .cartbar { left: auto; transform: none; right: 24px; width: max-content; }
  .hero { padding: 24px; } .hero h2 { font-size: 26px; }
}
@media (min-width: 1100px) { .pg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* địa chỉ giao hàng kiểu Grab/ShopeeFood: GPS trước, ghim cố định giữa bản đồ, kéo bản đồ để chọn */
.gpsbig { width: 100%; justify-content: center; margin-top: 8px; }
#delivery-box .map { height: 230px; }
.cpin { position: absolute; left: 50%; top: 50%; z-index: 500; width: 40px; height: 40px; margin: -40px 0 0 -20px; pointer-events: none; color: var(--accent); filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.cpin .ic { width: 40px; height: 40px; fill: var(--surface); stroke-width: 2.2; }
.pininfo { font-size: 13px; margin-top: 6px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); }
.pininfo.ok { background: #e7f6ec; color: #14532d; } .pininfo.bad { background: #fee2e2; color: #991b1b; }
.lastaddr { margin-top: 8px; }
.lastaddr button { width: 100%; text-align: left; border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--text); border-radius: var(--radius-sm); padding: 9px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.lastaddr b { display: block; }

/* khi mở giỏ hàng / chi tiết món: nền mờ đi và không cuộn được */
.ov { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overscroll-behavior: contain; }
.sheet { overscroll-behavior: contain; }
body:has(.ov:not(.hidden)) { overflow: hidden; }
