:root {
  --ink: #121212;
  --ink-2: #1d1d1b;
  --ink-3: #2a2a27;
  --ink-line: #3a3a37;
  --paper: #f2f0e9;
  --card: #fffffd;
  --soft: #f7f6f2;
  --press: #ecebe5;
  --lime: #c8f031;
  --lime-ink: #1b2600;
  --on-ink: #fbfaf5;
  --on-ink-2: #d8d6cf;
  --muted: #66655f;
  --line: #dcd8cc;
  --danger: #b4321a;
  --danger-bg: #fbe9e5;
  --ok: #3c6b00;
  --code-bg: #e9f7c4;
  --draft: #f5c542;
  --draft-ink: #3a2a00;
  --scrim: rgba(12, 12, 11, .55);
  --shadow: rgba(0, 0, 0, .22);
  --radius: 14px;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --bar-h: 26px;
  --top-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
body {
  margin: 0; overflow-x: clip; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, [role="button"], .variants label {
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.btn, .stepper button, .variants span, .cart-btn, .copy, .x, .back {
  transition: transform 120ms cubic-bezier(.2, .8, .2, 1), background-color 120ms, filter 120ms;
}
.btn:active, .cart-btn:active, .copy:active { transform: scale(.97); }
.btn-lime:active { filter: brightness(.92); }
.stepper button:active, .x:active, .back:active { background: var(--press); }
.variants label:active span { transform: scale(.96); }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.draft-bar {
  height: var(--bar-h); line-height: var(--bar-h); padding: 0 16px;
  background: var(--draft); color: var(--draft-ink); font-size: 12.5px; font-weight: 500;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Thanh trên */
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: var(--ink); color: var(--on-ink);
}
.brand {
  font-family: var(--display); font-weight: 800; font-style: italic;
  font-size: 26px; line-height: 1; color: var(--on-ink); text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--lime); }
.brand-sm { font-size: 22px; }
.cart-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 0 6px 0 14px; border-radius: 999px; border: 1px solid var(--ink-line);
  background: transparent; color: var(--on-ink); font-weight: 500; font-size: 15px;
}
.count {
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 999px;
  background: var(--lime); color: var(--lime-ink); font-weight: 600; font-size: 13px;
  display: inline-grid; place-items: center;
}

/* Ô giới thiệu nhỏ: điện thoại là một dải mảnh dưới thanh trên */
.intro { background: var(--ink); color: var(--on-ink-2); padding: 0 16px 10px; }
.intro p { margin: 0; }
.intro-title { display: none; }
.intro-code { font-size: 14px; line-height: 1.4; }
.code-chip {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  background: var(--lime); color: var(--lime-ink); font-weight: 600;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px; border-radius: 999px; border: 0;
  font-weight: 600; font-size: 16px; text-decoration: none;
}
.btn-lime { background: var(--lime); color: var(--lime-ink); }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Hàng: điện thoại là danh sách gọn (9 món từ 23/11: dòng thu gọn để gần như vừa một màn hình) */
.shop { padding: 10px 12px 24px; }
.grid {
  display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.grid-msg { margin: 12px 4px 0; font-size: 14px; }
.grid-msg:empty { display: none; }

.card {
  display: grid; min-width: 0;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  grid-template-areas:
    "media name  act"
    "media opts  act"
    "media price act";
  column-gap: 12px; row-gap: 0; align-items: center;
  padding: 4px 10px; border-bottom: 1px solid var(--line);
}
.card:last-child { border-bottom: 0; }
.media {
  grid-area: media; align-self: center; position: relative;
  width: 60px; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: var(--card);
}
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 6px; background: var(--ph, var(--ink-3)); color: var(--on-ink);
}
.ph strong { display: none; }
.ph b { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1; }

.name {
  grid-area: name; margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.size { font-weight: 400; color: var(--muted); font-size: 13px; white-space: nowrap; }

.variants { grid-area: opts; display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 3px 0 0; min-width: 0; }
.variants legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.variants label { position: relative; max-width: 100%; }
.variants input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.variants span {
  display: inline-flex; align-items: center; min-height: 30px; max-width: 100%; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 16px; font-size: 13px; font-weight: 500; line-height: 1.2;
}
.variants input:checked + span { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.variants input:focus-visible + span { outline: 3px solid var(--lime); outline-offset: 2px; }

.price {
  font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pr { grid-area: price; margin-top: 2px; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.act { grid-area: act; justify-self: end; align-self: center; }
.add { min-height: 40px; min-width: 84px; padding: 0 12px; font-size: 14px; white-space: nowrap; }

.stepper {
  display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  background: var(--card);
}
.stepper button {
  width: 44px; height: 44px; border: 0; background: transparent; font-size: 20px; line-height: 1;
}
.stepper output { min-width: 28px; text-align: center; font-weight: 600; }
.act .stepper button { width: 32px; height: 38px; }
.act .stepper output { min-width: 22px; }

/* Khung chờ khi đang tải hàng */
.skel { min-height: 76px; }
.skel .media { background: var(--press); }

/* Ngăn kéo giỏ hàng */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
.drawer {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--paper); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px var(--shadow);
}
.drawer-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; flex: 1; text-wrap: balance; font-family: var(--display); font-weight: 800; text-transform: uppercase; font-size: 26px; line-height: 1; }
.x, .back { width: 44px; height: 44px; border: 0; border-radius: 999px; background: transparent; font-size: 28px; line-height: 1; }
.drawer-body {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(18px + var(--safe-b));
}

.line { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--ph, var(--press)); display: grid; place-items: center; }
.thumb > * { grid-area: 1 / 1; }
.thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--soft); position: relative; z-index: 1; }
.thumb b { font-family: var(--display); font-weight: 800; color: var(--on-ink); font-size: 20px; }
.line-name {
  font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.line-meta { color: var(--muted); font-size: 13px; }
.line-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.line-right .stepper button { width: 36px; height: 36px; font-size: 18px; }
.line-sum { font-weight: 600; font-size: 15px; white-space: nowrap; }

.empty { text-align: center; padding: 28px 8px; color: var(--muted); }

.code-row { display: flex; gap: 8px; margin: 16px 0 6px; }
.code-row input { flex: 1; min-width: 0; text-transform: uppercase; }
.code-row .btn { min-height: 48px; padding: 0 16px; }

.totals { margin: 14px 0 16px; display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { padding-top: 10px; border-top: 1px dashed var(--line); font-weight: 600; font-size: 18px; }
.totals .grand span:last-child { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1; }
.disc { color: var(--ok); }
.note-ship { font-size: 13px; color: var(--muted); margin: 0 0 14px; }

/* Biểu mẫu */
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 14px; font-weight: 500; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.err { color: var(--danger); font-size: 13px; min-height: 0; }
.err:empty { display: none; }
.row-2 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-err { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }
.form-err:empty { display: none; }

/* Xong đơn */
.done-head { text-align: center; padding: 6px 0 12px; }
.done-head .tick {
  width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 999px; background: var(--lime); color: var(--lime-ink);
  display: grid; place-items: center; font-size: 28px; font-weight: 700;
}
.done-head h3 { margin: 0 0 4px; font-size: 20px; }
.paybox { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.qr { width: 220px; height: 220px; margin: 0 auto; border-radius: 12px; background: var(--soft); display: grid; place-items: center; text-align: center; padding: 16px; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); }
.qr img { width: 100%; height: 100%; object-fit: contain; }
.kv { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.kv span { min-width: 0; }
.kv b { font-weight: 600; text-align: right; white-space: nowrap; flex-shrink: 0; }
.copy { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; font-weight: 500; }
.dry { margin-top: 14px; font-size: 13px; }
.dry summary { cursor: pointer; font-weight: 500; min-height: 44px; display: flex; align-items: center; }
.dry pre { margin: 8px 0 0; padding: 12px; background: var(--ink); color: var(--code-bg); border-radius: 10px; font-size: 12px; line-height: 1.5; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); z-index: 60; transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { background: var(--ink-2); color: var(--on-ink-2); padding: 24px 16px calc(24px + var(--safe-b)); font-size: 14px; }
.foot p { max-width: 1400px; margin: 8px auto 0; }
.foot .brand { max-width: 1400px; margin: 0 auto; }
.foot a { color: var(--on-ink); text-underline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .btn-lime:hover { filter: brightness(.95); }
  .btn-ink:hover { background: var(--ink-3); }
  .cart-btn:hover { border-color: var(--lime); }
  .variants span:hover { border-color: var(--ink); }
}

/* Điện thoại hẹp (360-379px): thu ảnh và nút để tên, giá, loại hàng nằm gọn một dòng */
@media (max-width: 379px) {
  .card { grid-template-columns: 52px minmax(0, 1fr) auto; column-gap: 10px; padding: 4px 8px; }
  .media { width: 52px; }
  .add { min-width: 72px; padding: 0 10px; }
  .variants span { padding: 3px 8px; font-size: 12.5px; }
  .act .stepper button { width: 28px; }
}

@media (min-width: 640px) {
  .row-2 { grid-template-columns: 1fr 1fr; }
}

/* Máy tính bảng: ô giới thiệu nhỏ bên trái, danh sách bên phải */
@media (min-width: 720px) {
  :root { --top-h: 60px; }
  .top { padding-inline: 24px; }
  .layout {
    display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px;
    max-width: 1400px; margin: 0 auto; padding: 16px 24px 32px;
  }
  .intro {
    align-self: start; position: sticky; top: calc(var(--top-h) + 16px);
    display: grid; gap: 14px; padding: 18px 16px; border-radius: var(--radius);
  }
  .intro-title {
    display: block; color: var(--on-ink); font-family: var(--display); font-weight: 800;
    text-transform: uppercase; font-size: 30px; line-height: 1.02; text-wrap: balance;
  }
  .intro-code { font-size: 14px; }
  .shop { padding: 0; }
  .card { grid-template-columns: 76px minmax(0, 1fr) auto; padding: 10px 14px; column-gap: 14px; }
  .name { font-size: 15.5px; }
  .media { width: 76px; }
}

/* Máy tính (từ 960px): ô giới thiệu cao bên trái, giỏ hàng mở bên phải */
@media (min-width: 960px) {
  .layout {
    grid-template-columns: 210px minmax(0, 1fr);
    min-height: calc(100dvh - var(--bar-h) - var(--top-h));
  }
  .intro { position: relative; top: auto; overflow: hidden; align-self: stretch; align-content: start; }
  .intro::after {
    content: "1"; position: absolute; right: -8px; bottom: -.2em; z-index: 0; pointer-events: none;
    font-family: var(--display); font-weight: 800; font-style: italic; font-size: 260px; line-height: 1;
    color: var(--ink-3);
  }
  .intro p { position: relative; z-index: 1; }
  .intro-title { font-size: 34px; }
  .drawer {
    left: auto; top: 0; bottom: 0; width: 440px; max-height: none; border-radius: 0;
    box-shadow: -10px 0 40px var(--shadow);
  }
}

/* 960-1199px (laptop nhỏ, máy tính bảng nằm ngang): danh sách 2 cột, 9 món vừa một màn hình */
@media (min-width: 960px) and (max-width: 1199px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start;
    gap: 10px; background: transparent; border: 0; border-radius: 0; overflow: visible;
  }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
  .card:last-child { border-bottom: 1px solid var(--line); }
  .skel { min-height: 96px; }
}

/* Từ 1200px: 9 món chia 3 x 3 thẻ ngang (ảnh trái, chữ phải), vừa một màn hình laptop 768px trở lên */
@media (min-width: 1200px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(auto, 1fr);
    gap: 12px; background: transparent; border: 0; border-radius: 0; overflow: visible;
    min-height: calc(100dvh - var(--bar-h) - var(--top-h) - 48px);
  }
  .card {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "media name"
      "media opts"
      "media ."
      "media price"
      "media act";
    column-gap: 14px; row-gap: 6px; padding: 12px; align-items: start;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .variants, .pr { margin: 0; }
  .card:last-child { border-bottom: 1px solid var(--line); }
  .act { justify-self: start; }
  .media { width: 100%; height: 100%; min-height: 120px; aspect-ratio: auto; align-self: stretch; }
  .ph { place-items: end start; padding: 12px; }
  .ph strong {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font-family: var(--display); font-weight: 800; text-transform: uppercase;
    font-size: clamp(18px, 1.7vw, 28px); line-height: 1.02; padding-top: .1em; overflow-wrap: anywhere;
  }
  .ph b { display: none; }
  .name { font-size: 16px; }
  .price { font-size: 22px; }
  .skel { min-height: 0; }
}
@media (min-width: 1280px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .price { font-size: 26px; }
  .intro-title { font-size: 40px; }
}
