/* ===== Màu sắc: sáng/tối + 6 bảng phối màu ===== */
:root {
  --accent: #0a63c2; --accent-ink: #0a63c2; --b2: #ff9f43; --b3: #34c3a0;
  --bg: #eef2f7; --text: #0b0d10; --muted: #4a525e;
  --glass: rgba(255,255,255,0.5); --glass-strong: rgba(255,255,255,0.78);
  --border: rgba(255,255,255,0.85); --hair: rgba(15,23,42,0.08);
  --inset: inset 0 1px 0 rgba(255,255,255,0.95);
  --shadow: 0 10px 30px rgba(20,40,80,0.08);
  --shadow-strong: 0 14px 40px rgba(20,40,80,0.18);
  --placeholder: rgba(255,255,255,0.7);
  --blob-opacity: 0.32;
  --radius: 24px;
  --font: -apple-system, 'SF Pro Text', Inter, 'Noto Sans Khmer', system-ui, sans-serif;
}
html[data-theme="dark"] {
  --bg: #07090d; --text: #f4f6f9; --muted: #b3bac4;
  --glass: rgba(255,255,255,0.08); --glass-strong: rgba(30,34,42,0.72);
  --border: rgba(255,255,255,0.16); --hair: rgba(255,255,255,0.1);
  --inset: inset 0 1px 0 rgba(255,255,255,0.14);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-strong: 0 14px 40px rgba(0,0,0,0.55);
  --placeholder: rgba(255,255,255,0.1);
  --blob-opacity: 0.38;
}
html[data-palette="ocean"]  { --accent: #0a63c2; --b2: #ff9f43; --b3: #34c3a0; --soft: #64b5ff; }
html[data-palette="red"]    { --accent: #c8102e; --b2: #ff8a3d; --b3: #6b7cff; --soft: #ff6b7d; }
html[data-palette="emerald"]{ --accent: #0f8a5f; --b2: #38bdf8; --b3: #a3e635; --soft: #4ade80; }
html[data-palette="sunset"] { --accent: #c2410c; --b2: #f472b6; --b3: #facc15; --soft: #fb923c; }
html[data-palette="purple"] { --accent: #6d28d9; --b2: #22d3ee; --b3: #f472b6; --soft: #a78bfa; }
html[data-palette="gold"]   { --accent: #a16207; --b2: #64748b; --b3: #f59e0b; --soft: #fbbf24; }
html[data-theme="light"] { --accent-ink: var(--accent); }
html[data-theme="dark"]  { --accent-ink: var(--soft); }
html[lang="km"] { --font: 'Noto Sans Khmer', Inter, system-ui, sans-serif; }

/* ===== Nền tảng ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.blob { position: fixed; border-radius: 50%; filter: blur(80px); opacity: var(--blob-opacity); pointer-events: none; z-index: 0; }
.blob-1 { width: 320px; height: 320px; background: var(--accent); top: -80px; left: -90px; }
.blob-2 { width: 280px; height: 280px; background: var(--b2); top: 38%; right: -120px; opacity: calc(var(--blob-opacity) * 0.8); }
.blob-3 { width: 260px; height: 260px; background: var(--b3); bottom: 4%; left: -80px; opacity: calc(var(--blob-opacity) * 0.7); }

.glass {
  background: var(--glass); border: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--inset), var(--shadow);
}

.shell { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 14px 16px 120px; }

/* ===== Thanh trên ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--accent-ink);
  background: var(--glass); border: 1px solid var(--border); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.brand-mark svg, .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lang { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--glass); border: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.lang button { border: 0; background: transparent; border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 600; color: var(--muted); min-height: 32px; }
.lang button[aria-pressed="true"] { background: var(--glass-strong); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* ===== Ô tìm kiếm ===== */
.search { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 16px; border-radius: 999px; margin-bottom: 16px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; min-width: 0; }
.search input::placeholder { color: var(--muted); }
.search .icon { color: var(--muted); }

/* ===== Banner ===== */
.banner { border-radius: 26px; padding: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.banner-tag { font-size: 12px; font-weight: 600; color: var(--accent-ink); }
.banner-title { font-size: 21px; font-weight: 700; line-height: 1.2; letter-spacing: -0.3px; margin: 6px 0 10px; }
.banner-art { width: 96px; height: 96px; flex-shrink: 0; border-radius: 20px; display: grid; place-items: center; background: var(--placeholder); color: var(--accent-ink); }
.banner-art img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.banner-art .icon { width: 44px; height: 44px; stroke-width: 1.5; }

.btn { border: 0; border-radius: 999px; min-height: 44px; padding: 0 18px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--glass-strong); color: var(--text); border: 1px solid var(--border); }
.btn-block { width: 100%; }

/* ===== Tiêu đề mục ===== */
.section { margin-bottom: 22px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.link-btn { border: 0; background: none; color: var(--accent-ink); font-size: 13px; font-weight: 600; padding: 8px 0; }

/* ===== Chuyên mục ===== */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; }
.cat { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; color: var(--text); }
.cat-icon { width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center; color: var(--accent-ink); }
.cat-icon .icon { width: 24px; height: 24px; stroke-width: 1.8; }
.cat-name { font-size: 11.5px; font-weight: 500; text-align: center; line-height: 1.25; }
.cat[aria-pressed="true"] .cat-icon { background: var(--accent); color: #fff; border-color: transparent; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; border-radius: 999px; padding: 0 16px; min-height: 40px; font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--glass); color: var(--text);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }

/* ===== Lưới sản phẩm ===== */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { border-radius: 22px; padding: 8px; display: flex; flex-direction: column; gap: 8px; text-align: left; color: var(--text); position: relative; }
.card-open { border: 0; background: none; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 8px; color: inherit; }
.thumb { height: 108px; border-radius: 16px; background: var(--placeholder); display: grid; place-items: center; color: var(--accent-ink); position: relative; width: 100%; }
.thumb .icon { width: 36px; height: 36px; stroke-width: 1.4; opacity: 0.85; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; padding: 3px 8px; border-radius: 999px; }
.card-body { padding: 0 4px 2px; display: flex; flex-direction: column; gap: 6px; }
.card-name { font-size: 13px; font-weight: 500; line-height: 1.3; min-height: 34px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 0 4px 4px; }
.price { font-size: 16px; font-weight: 700; }
.old-price { font-size: 12px; color: var(--muted); text-decoration: line-through; margin-left: 4px; font-weight: 500; }
.add { width: 36px; height: 36px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.add .icon { width: 16px; height: 16px; stroke-width: 2.6; }

.empty { text-align: center; padding: 48px 20px; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .icon { width: 40px; height: 40px; color: var(--muted); stroke-width: 1.5; }
.empty p { margin: 0; color: var(--muted); }

/* ===== Giỏ hàng ===== */
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; margin: 4px 0 14px; }
.lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.line { border-radius: 20px; padding: 10px; display: flex; gap: 12px; align-items: center; }
.line .thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 14px; }
.line .thumb .icon { width: 26px; height: 26px; }
.line-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.line-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.stepper { display: flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px; background: var(--glass-strong); border: 1px solid var(--border); }
.stepper button { width: 34px; height: 34px; border-radius: 999px; border: 0; background: transparent; display: grid; place-items: center; }
.stepper button .icon { width: 16px; height: 16px; }
.stepper output { min-width: 22px; text-align: center; font-weight: 700; }
.summary { border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.summary-row { display: flex; justify-content: space-between; align-items: baseline; }
.summary-row strong { font-size: 22px; }
.note { font-size: 12px; color: var(--muted); }

/* ===== Hỗ trợ ===== */
.support { border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.support .icon { width: 32px; height: 32px; color: var(--accent-ink); }
.support h2 { margin: 0; font-size: 20px; }
.support p { margin: 0; color: var(--muted); }

/* ===== Thanh menu nổi ===== */
.tabbar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom)); width: min(520px, calc(100% - 32px));
  height: 64px; border-radius: 32px; padding: 0 6px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center;
  background: var(--glass-strong); border: 1px solid var(--border);
  backdrop-filter: blur(30px) saturate(200%); -webkit-backdrop-filter: blur(30px) saturate(200%);
  box-shadow: var(--inset), var(--shadow-strong);
}
.tab { height: 52px; border-radius: 26px; border: 0; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative; }
.tab .icon { width: 22px; height: 22px; stroke-width: 1.8; }
.tab[aria-current="page"] { color: var(--accent-ink); background: var(--glass); }
.tab-count { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

/* ===== Bảng chi tiết ===== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.35); }
.sheet {
  position: fixed; z-index: 31; left: 50%; transform: translateX(-50%); bottom: 0; width: min(560px, 100%);
  max-height: 88dvh; overflow-y: auto; border-radius: 28px 28px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--glass-strong); border: 1px solid var(--border); border-bottom: 0;
  backdrop-filter: blur(36px) saturate(200%); -webkit-backdrop-filter: blur(36px) saturate(200%);
  box-shadow: var(--shadow-strong); animation: up 0.22s ease-out;
}
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--hair); margin: 0 auto 12px; }
.sheet .thumb { height: 220px; border-radius: 22px; }
.sheet .thumb .icon { width: 64px; height: 64px; }
.sheet h2 { margin: 16px 0 6px; font-size: 21px; line-height: 1.25; }
.sheet .desc { color: var(--muted); margin: 10px 0 18px; }
.sheet-actions { display: flex; gap: 10px; align-items: center; }
.sheet-actions .btn { flex: 1; }
.sheet-close { position: absolute; z-index: 2; top: 18px; right: 26px; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border); background: var(--glass-strong); display: grid; place-items: center; }
.sample { display: inline-block; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px dashed var(--muted); border-radius: 999px; padding: 2px 8px; }

/* ===== Thông báo nhỏ ===== */
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 520px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .toast { transition: none; }
}
html[data-theme="dark"] .lang button[aria-pressed="true"] { background: rgba(255,255,255,0.22); }

/* ===== Đặt hàng ===== */
.checkout { display: flex; flex-direction: column; gap: 14px; }
.form-card { border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.form-card h2 { margin: 0; font-size: 16px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld span { font-size: 13px; font-weight: 600; color: var(--muted); }
.fld input, .fld textarea { width: 100%; min-height: 46px; border-radius: 14px; border: 1px solid var(--hair); background: var(--glass-strong);
  padding: 11px 14px; font: inherit; font-size: 16px; color: var(--text); outline: none; resize: vertical; }
.fld input:focus, .fld textarea:focus { border-color: var(--accent); }
.pay-list { display: flex; flex-direction: column; gap: 8px; }
.pay-opt { display: flex; gap: 12px; align-items: center; border-radius: 16px; padding: 12px 14px; cursor: pointer; }
.pay-opt input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.pay-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent) inset, var(--shadow); }
.pay-opt b { display: block; font-size: 15px; }
.pay-opt small { display: block; color: var(--muted); font-size: 13px; }
.summary-row.small { font-size: 14px; color: var(--muted); }
.form-err { color: #d1293d; font-size: 14px; font-weight: 600; min-height: 0; }
.form-err:empty { display: none; }
html[data-theme="dark"] .form-err { color: #ff7b8a; }
.done { border-radius: var(--radius); padding: 24px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.done-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.done-icon .icon { width: 32px; height: 32px; stroke-width: 2.5; }
.done h1 { margin: 6px 0 0; font-size: 20px; }
.done .code { margin: 0; color: var(--muted); }
.done .code b { color: var(--text); font-size: 18px; letter-spacing: 1px; }
.qr-card { border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; margin-bottom: 14px; }
.qr-card p { margin: 0; }
.qr { width: min(280px, 100%); border-radius: 18px; background: #fff; padding: 8px; }
.qr-card .acc { color: var(--muted); font-size: 14px; }
.qr-card label.btn { cursor: pointer; }
.ok-msg { color: var(--accent-ink); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.muted-p { color: var(--muted); text-align: center; margin: 0 8px 16px; }
