:root {
  --bg: #faf6ef;
  --bg-2: #f3ece0;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #6f655c;
  --line: #ebe2d4;
  --primary: #d62828;
  --primary-dark: #a91f1f;
  --primary-soft: #fde8e6;
  --accent: #ffd400;
  --accent-soft: #fff6c7;
  --ok: #1a8a4a;
  --ok-soft: #e3f5ea;
  --warn: #b85c00;
  --warn-soft: #fff0dd;
  --shopee: #ee4d2d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .07);
  --shadow-lg: 0 2px 4px rgba(60, 40, 20, .06), 0 18px 48px rgba(60, 40, 20, .14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 6vw, 46px); font-weight: 800; }
h2 { font-size: clamp(22px, 4vw, 30px); font-weight: 800; }
h3 { font-size: 19px; font-weight: 700; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 246, 239, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 12px; height: 62px; }
.logo { font-weight: 800; font-size: 19px; color: var(--ink); text-decoration: none; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.nav { margin-left: auto; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; text-decoration: none; color: var(--ink);
  padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
}
.nav a:hover { background: var(--bg-2); }
.nav a.active { background: var(--ink); color: #fff; }
@media (max-width: 640px) {
  .topbar-in { height: auto; padding: 10px 0; flex-wrap: wrap; row-gap: 6px; }
  .nav { margin-left: 0; width: 100%; }
  .nav a { padding: 7px 11px; font-size: 14px; background: var(--card); border: 1px solid var(--line); }
}

main { padding: 24px 16px 64px; min-height: 70vh; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; text-decoration: none;
  padding: 13px 20px; border-radius: 999px; font-weight: 700; font-size: 15.5px;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--line);
  transition: transform .12s ease, box-shadow .12s ease, background .12s;
  min-height: 46px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-shopee { background: var(--shopee); color: #fff; border-color: var(--shopee); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-2); box-shadow: none; }
.btn-sm { padding: 8px 14px; font-size: 14px; min-height: 36px; }
.btn-lg { padding: 17px 30px; font-size: 18px; min-height: 58px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--primary); border-color: #f3c3be; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.pad { padding: 20px; }
@media (min-width: 720px) { .pad { padding: 28px; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--bg-2); color: var(--ink); border: 1px solid transparent;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-red { background: var(--primary-soft); color: var(--primary-dark); }
.chip-yellow { background: var(--accent); color: var(--ink); }
.badge {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 12.5px;
  padding: 5px 10px; border-radius: 999px; box-shadow: 0 2px 0 var(--accent);
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #fff7da 55%, #ffe3dc 100%);
  border-radius: 28px; border: 1px solid var(--line);
  padding: 36px 22px; display: grid; gap: 24px;
}
@media (min-width: 860px) { .hero { grid-template-columns: 1.2fr .8fr; padding: 56px 48px; align-items: center; } }
.hero h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--accent) 62%); }
.hero p.lead { font-size: 18px; color: #4a4038; max-width: 560px; }
.hero-visual { display: grid; place-items: center; }
.pot {
  width: min(320px, 80vw); aspect-ratio: 1; border-radius: 40px;
  background: radial-gradient(circle at 30% 25%, #fff 0, #f3ece0 60%, #e9dfcf 100%);
  box-shadow: var(--shadow-lg); display: grid; place-items: center; position: relative;
  font-size: 120px;
}
.pot .float { position: absolute; background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap; }
.pot .f1 { top: 10%; left: -8%; }
.pot .f2 { top: 46%; right: -10%; }
.pot .f3 { bottom: 8%; left: 2%; }
@media (max-width: 520px) { .pot { font-size: 90px; } .pot .float { font-size: 12.5px; } .pot .f1 { left: -2%; } .pot .f2 { right: -2%; } }

.steps3 { display: grid; gap: 14px; margin: 28px 0; }
@media (min-width: 720px) { .steps3 { grid-template-columns: repeat(3, 1fr); } }
.steps3 .card { padding: 20px; }
.steps3 .num { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 800; margin-bottom: 10px; }

.trust {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--card); border: 1.5px dashed #e6c9a8; border-radius: var(--radius); padding: 18px;
}
.avatar { width: 56px; height: 56px; border-radius: 50%; flex: none; background: var(--accent); display: grid; place-items: center; font-size: 26px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 40px 0 16px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }

/* ---------- Product grid / card ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.pcard { position: relative; display: flex; flex-direction: column; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.pimg { aspect-ratio: 4/3; background: var(--bg-2); display: grid; place-items: center; overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pbody { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pbody h3 { margin: 0; font-size: 17.5px; }
.pbody h3 a { color: var(--ink); text-decoration: none; }
.price { font-weight: 800; color: var(--primary); font-size: 18px; }
.price small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.pmeta { display: flex; gap: 6px; flex-wrap: wrap; }
.pactions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.pactions .btn { flex: 1; padding: 10px 12px; min-height: 40px; font-size: 14px; }
.cmp-check { position: absolute; top: 10px; right: 10px; z-index: 2; background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.cmp-check input { accent-color: var(--primary); width: 16px; height: 16px; }

.minibars { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; font-size: 13px; }
.bar { height: 7px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 99px; }

/* ---------- Quiz ---------- */
.quiz { max-width: 760px; margin: 0 auto; }
.progress { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.progress .track { flex: 1; height: 10px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 99px; transition: width .35s ease; }
.progress .count { font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; }
.qcard { padding: 26px 20px; animation: slideIn .32s ease; }
@media (min-width: 720px) { .qcard { padding: 38px 40px; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.qicon { font-size: 40px; margin-bottom: 6px; }
.qcard h2 { margin-bottom: 6px; }
.qcard .sub { color: var(--muted); margin-bottom: 22px; }
.options { display: grid; gap: 12px; }
@media (min-width: 600px) { .options.two { grid-template-columns: 1fr 1fr; } }
.opt {
  display: flex; gap: 14px; align-items: center; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; transition: border-color .12s, background .12s, transform .12s; width: 100%;
}
.opt:hover { border-color: #d8c8b0; transform: translateY(-1px); }
.opt.on { border-color: var(--primary); background: var(--primary-soft); }
.opt .oi { font-size: 30px; width: 44px; text-align: center; flex: none; }
.opt b { display: block; font-size: 16.5px; }
.opt span.h { display: block; color: var(--muted); font-size: 13.5px; }
.opt .tick { margin-left: auto; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: #fff; font-size: 14px; }
.opt.on .tick { background: var(--primary); border-color: var(--primary); }
.opt.square .tick { border-radius: 7px; }

.qnav { display: flex; gap: 10px; margin-top: 22px; }
.qnav .btn-primary { flex: 1; }
@media (max-width: 600px) {
  .qnav { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 12px; margin: 10px -4px 0; }
}

.budget-display { font-size: clamp(24px, 6vw, 34px); font-weight: 800; text-align: center; margin: 6px 0 18px; }
.budget-display span { color: var(--primary); }
.range2 { position: relative; height: 44px; }
.range2 input[type=range] { position: absolute; left: 0; right: 0; top: 10px; width: 100%; pointer-events: none; -webkit-appearance: none; appearance: none; background: none; height: 24px; margin: 0; }
.range2 input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); box-shadow: var(--shadow); cursor: pointer; position: relative; z-index: 3; }
.range2 input[type=range]::-moz-range-thumb { pointer-events: auto; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); cursor: pointer; }
.range2 .rtrack { position: absolute; left: 0; right: 0; top: 19px; height: 8px; background: var(--bg-2); border-radius: 99px; }
.range2 .rfill { position: absolute; top: 19px; height: 8px; background: linear-gradient(90deg, var(--accent), var(--primary)); border-radius: 99px; }
.rlabels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 2px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; justify-content: center; }
.preset { cursor: pointer; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
.preset.on, .preset:hover { border-color: var(--primary); background: var(--primary-soft); }
.checkline { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; cursor: pointer; font-weight: 600; }
.checkline input { width: 20px; height: 20px; accent-color: var(--primary); }

.prio { display: grid; gap: 14px; }
.prio-row { display: grid; gap: 8px; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); }
@media (min-width: 680px) { .prio-row { grid-template-columns: 1fr 340px; align-items: center; } }
.prio-row b { font-size: 16px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--bg-2); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 4px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--muted); line-height: 1.2; }
.seg button.on { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.chips-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.chips-pick button { cursor: pointer; border: 2px solid var(--line); background: var(--card); padding: 10px 14px; border-radius: 999px; font-weight: 600; font-size: 14.5px; transition: all .12s; }
.chips-pick button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

textarea.big { width: 100%; min-height: 120px; border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 14px; font-size: 16px; resize: vertical; background: #fff; }
textarea.big:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); }

/* ---------- Results ---------- */
.res-head { text-align: center; margin: 8px auto 22px; max-width: 760px; }
.res-head .chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.winner { display: grid; gap: 0; overflow: hidden; border: 2px solid var(--primary); }
@media (min-width: 860px) { .winner { grid-template-columns: 380px 1fr; } }
.winner .pimg { aspect-ratio: auto; min-height: 260px; position: relative; }
.winner-body { padding: 22px; display: grid; gap: 14px; }
@media (min-width: 720px) { .winner-body { padding: 30px; } }
.ribbon { display: inline-block; background: var(--accent); color: var(--ink); font-weight: 800; padding: 6px 14px; border-radius: 999px; font-size: 14px; }
.match { display: flex; align-items: center; gap: 14px; }
.ring { --p: 80; width: 74px; height: 74px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--bg-2) 0); }
.ring span { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.ring.sm { width: 54px; height: 54px; } .ring.sm span { width: 42px; height: 42px; font-size: 14px; }
.reasons { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.reasons li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; }
.reasons li .i { flex: none; }
.two-col { display: grid; gap: 14px; }
@media (min-width: 720px) { .two-col { grid-template-columns: 1fr 1fr; } }
.box { border-radius: var(--radius-sm); padding: 14px 16px; }
.box h4 { margin: 0 0 6px; font-size: 15px; }
.box ul { margin: 0; padding-left: 18px; }
.box li { margin: 3px 0; font-size: 14.5px; }
.box-ok { background: var(--ok-soft); } .box-ok h4 { color: var(--ok); }
.box-warn { background: var(--warn-soft); } .box-warn h4 { color: var(--warn); }
.box-red { background: var(--primary-soft); } .box-red h4 { color: var(--primary-dark); }
.box-y { background: var(--accent-soft); }
.buy { display: flex; gap: 10px; flex-wrap: wrap; }
.buy .btn { flex: 1 1 180px; }
.disclose { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.alt-grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .alt-grid { grid-template-columns: 1fr 1fr; } }
.alt { padding: 18px; display: grid; gap: 10px; position: relative; }
.alt-top { display: flex; gap: 14px; align-items: center; }
.alt-top .thumb { width: 84px; height: 84px; border-radius: 14px; overflow: hidden; flex: none; background: var(--bg-2); }
.alt-top .thumb img, .alt-top .thumb svg { width: 100%; height: 100%; object-fit: contain; background: #fff; }

.cta-band { margin-top: 28px; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 24px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.cta-band p { margin: 0; flex: 1 1 260px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table.cmp { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 14.5px; }
table.cmp th, table.cmp td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.cmp thead th { background: var(--bg-2); position: sticky; top: 0; }
table.cmp tbody th { color: var(--muted); font-weight: 600; width: 170px; background: #fffdf9; position: sticky; left: 0; }
table.cmp tr:last-child td, table.cmp tr:last-child th { border-bottom: 0; }
td.best { background: var(--ok-soft); font-weight: 700; }
.specs { width: 100%; border-collapse: collapse; }
.specs th, .specs td { padding: 10px 0; border-bottom: 1px dashed var(--line); text-align: left; vertical-align: top; font-size: 15px; }
.specs th { width: 40%; color: var(--muted); font-weight: 600; padding-right: 12px; }

/* ---------- Catalog filters ---------- */
.filters { display: grid; gap: 12px; padding: 16px; margin-bottom: 18px; }
@media (min-width: 860px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr; align-items: end; } }
.field { display: grid; gap: 5px; }
.field label { font-weight: 600; font-size: 13.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; font-size: 15px;
}
.field textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.feat-filter { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.feat-filter button { cursor: pointer; border: 1.5px solid var(--line); background: #fff; padding: 6px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 600; }
.feat-filter button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

.cmpbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 60; background: var(--ink); color: #fff; padding: 10px 10px 10px 18px; border-radius: 999px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow-lg); width: max-content; max-width: calc(100% - 32px); }
.cmpbar .btn { min-height: 38px; padding: 8px 16px; }

/* ---------- Detail ---------- */
.detail { display: grid; gap: 20px; }
@media (min-width: 900px) { .detail { grid-template-columns: 460px 1fr; align-items: start; } .detail .sticky { position: sticky; top: 80px; } }
.detail .pimg { border-radius: var(--radius); aspect-ratio: 1; position: relative; }
.crumbs { font-size: 14px; margin-bottom: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.scoregrid { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; font-size: 14.5px; }

/* ---------- Issues ---------- */
.issue { padding: 0; overflow: hidden; }
.issue summary { cursor: pointer; padding: 16px 18px; font-weight: 700; font-size: 16.5px; list-style: none; display: flex; gap: 10px; align-items: center; }
.issue summary::-webkit-details-marker { display: none; }
.issue summary::after { content: "＋"; margin-left: auto; color: var(--muted); }
.issue[open] summary::after { content: "－"; }
.issue .ibody { padding: 0 18px 18px; display: grid; gap: 10px; }
.stack { display: grid; gap: 12px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 14px; background: #fff; }
.footer a { color: var(--ink); }
.footer .row { justify-content: space-between; }

/* ---------- Toast & Modal ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; z-index: 200; transition: transform .25s ease; max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--primary); }
.modal-bg { position: fixed; inset: 0; background: rgba(31, 26, 23, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 12px; }
.modal { background: var(--bg); border-radius: 22px; width: 100%; max-width: 860px; box-shadow: var(--shadow-lg); }
.modal-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--bg); border-bottom: 1px solid var(--line); border-radius: 22px 22px 0 0; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 18px; display: grid; gap: 16px; }
.modal-foot { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 18px; background: var(--bg); border-top: 1px solid var(--line); border-radius: 0 0 22px 22px; }
.modal-foot .btn-primary { flex: 1; }

/* ---------- Admin ---------- */
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 4px; }
.admin-tabs button { white-space: nowrap; cursor: pointer; border: 1.5px solid var(--line); background: #fff; padding: 9px 15px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.admin-tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.mode-banner { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: 14.5px; }
.mode-local { background: var(--warn-soft); color: #7a3e00; }
.mode-cloud { background: var(--ok-soft); color: #0f5c30; }
.alist { display: grid; gap: 10px; }
.aitem { display: flex; gap: 12px; align-items: center; padding: 10px 12px; }
.aitem .thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--bg-2); flex: none; }
.aitem .thumb img, .aitem .thumb svg { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.aitem .info { flex: 1; min-width: 0; }
.aitem .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aitem .acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; display: grid; place-items: center; font-size: 15px; }
.icon-btn:hover { background: var(--bg-2); }
.fgrid { display: grid; gap: 12px; }
@media (min-width: 640px) { .fgrid.c2 { grid-template-columns: 1fr 1fr; } .fgrid.c3 { grid-template-columns: 1fr 1fr 1fr; } }
.fsec { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; display: grid; gap: 12px; }
.fsec > h4 { margin: 0; font-size: 15.5px; }
.score-edit { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .score-edit { grid-template-columns: 1fr 1fr; } }
.score-edit label { display: grid; grid-template-columns: 120px 1fr 32px; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; }
.score-edit input[type=range] { accent-color: var(--primary); width: 100%; }
.score-edit output { font-weight: 800; color: var(--primary); text-align: right; }
.kv-row { display: grid; grid-template-columns: 1fr 1.6fr 36px; gap: 8px; }
.kv-row input { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; width: 100%; font-size: 14.5px; }
.feat-check { display: flex; flex-wrap: wrap; gap: 8px; }
.feat-check label { display: flex; gap: 6px; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 14px; font-weight: 600; background: #fff; }
.feat-check input { accent-color: var(--primary); }
.feat-check label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.img-edit { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.img-edit .prev { width: 110px; height: 110px; border-radius: 14px; overflow: hidden; background: var(--bg-2); flex: none; border: 1px solid var(--line); }
.img-edit .prev img, .img-edit .prev svg { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.login { max-width: 420px; margin: 40px auto; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
@media (max-width: 640px) {
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .modal-head, .modal-foot { border-radius: 0; }
  .winner .pimg { min-height: 220px; }
}

/* ---------- Rich content, video, gallery ---------- */
.rich p { margin: 0 0 .8em; }
.rich h3 { margin: 1.1em 0 .5em; }
.rich ul { margin: 0 0 .9em; padding-left: 20px; }
.rich li { margin: 4px 0; }
.rich-img { width: 100%; border-radius: var(--radius-sm); margin: 10px 0 14px; background: var(--bg-2); }
.article { max-width: 780px; margin: 0 auto; }
.video { position: relative; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden; background: #000; margin: 10px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.gallery { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.gthumb { flex: none; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); padding: 0; cursor: pointer; background: #fff; }
.gthumb.on { border-color: var(--primary); }
.gthumb img { width: 100%; height: 100%; object-fit: cover; }
.art-ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; background: linear-gradient(135deg, #fff7da, #ffe0d6); }
.big-edit { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; font-size: 15px; line-height: 1.6; background: #fff; resize: vertical; }

/* =========================================================
   TỐI ƯU ĐIỆN THOẠI & TỐC ĐỘ (v3)
   ========================================================= */
html { -webkit-tap-highlight-color: transparent; }
a, button, .opt, .preset, label { touch-action: manipulation; }
.topbar { backdrop-filter: none; background: var(--bg); }
.top-cta { display: none; }
.tabbar, .buybar { display: none; }

/* Hiệu ứng nổi chỉ dùng cho máy có chuột; điện thoại dùng hiệu ứng nhấn */
@media (hover: none) {
  .btn:hover, .pcard:hover, .opt:hover { transform: none; box-shadow: inherit; }
  .btn:hover { box-shadow: none; }
  .pcard:hover { box-shadow: var(--shadow); }
  .btn:active, .opt:active, .pcard:active, .preset:active, .chips-pick button:active { transform: scale(.97); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Danh sách dài: trình duyệt bỏ qua vẽ phần chưa cuộn tới → cuộn mượt */
.grid > .pcard, .media-grid > .media-item, .stack > .issue { content-visibility: auto; contain-intrinsic-size: auto 380px; }

/* Khung chờ lần đầu */
.skeleton { display: grid; gap: 16px; }
.sk { background: var(--bg-2); border-radius: var(--radius); min-height: 220px; animation: skp 1.2s ease-in-out infinite; }
.sk-hero { min-height: 300px; border-radius: 28px; }
.sk-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
@keyframes skp { 50% { opacity: .55; } }

/* ---------- Video (chỉ tải khi bấm) ---------- */
.vgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; }
.vbox { position: relative; aspect-ratio: 16/9; border-radius: var(--radius-sm); overflow: hidden; background: #1f1a17; }
.vbox.vert { aspect-ratio: 9/16; max-width: 340px; width: 100%; justify-self: center; }
.vbox iframe, .vbox video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.vfacade { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; color: #fff; text-decoration: none; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #4a3a30, #1f1a17 70%); }
.vfacade img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .92; }
.vplay { position: relative; width: 66px; height: 66px; border-radius: 50%; background: rgba(214, 40, 40, .95); display: grid; place-items: center; font-size: 26px; padding-left: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .15s; }
.vfacade:hover .vplay, .vfacade:active .vplay { transform: scale(1.08); }
.vsrc { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.65); padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.vtitle { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px; font-weight: 700; font-size: 14.5px; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.video-row { display: grid; gap: 6px; grid-template-columns: 1fr 36px; align-items: center; padding: 10px; border: 1.5px dashed var(--line); border-radius: 12px; background: #fff; }
.video-row input { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 15px; width: 100%; grid-column: 1; }
.video-row .vdetect { grid-column: 1; font-size: 13px; font-weight: 600; color: var(--ok); min-height: 1em; }
.video-row .icon-btn { grid-column: 2; grid-row: 1; }

/* ---------- Kho ảnh ---------- */
.dropzone { display: grid; place-items: center; gap: 6px; text-align: center; padding: 30px 16px; border: 2.5px dashed #e2cfb4; border-radius: var(--radius); background: #fffdf8; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.up-row { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 8px 12px; background: var(--bg); border-radius: 10px; }
.up-row .grow { flex: 1; min-width: 0; word-break: break-word; }
.media-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.media-item { padding: 8px; display: grid; gap: 8px; }
.mthumb { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg-2); }
.mthumb img { width: 100%; height: 100%; object-fit: cover; }
.mmeta { display: grid; min-width: 0; }
.mmeta b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-pick { padding: 4px; aspect-ratio: 1; cursor: pointer; overflow: hidden; }
.media-pick img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.media-pick:hover { outline: 3px solid var(--primary); }

/* ---------- ĐIỆN THOẠI ---------- */
@media (max-width: 768px) {
  body { font-size: 15.5px; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  main { padding: 14px 14px 32px; }
  .wrap { padding: 0 14px; }
  .topbar-in { height: 54px; padding: 0 14px; flex-wrap: nowrap; }
  .nav { display: none; }
  .top-cta { display: inline-flex; margin-left: auto; min-height: 38px; }
  body[data-route="chon-noi"] .top-cta, body[data-route="admin"] .top-cta { display: none; }
  .logo { font-size: 17.5px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(60, 40, 20, .06);
  }
  .tabbar a { display: grid; justify-items: center; gap: 1px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; border-radius: 12px; min-height: 48px; }
  .tabbar .ti { font-size: 21px; line-height: 1.2; }
  .tabbar a.active { color: var(--primary); }
  .tabbar a.active .ti { transform: translateY(-1px); }
  .tabbar .tab-main .ti { background: var(--primary); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-top: -20px; box-shadow: 0 4px 12px rgba(214, 40, 40, .35); border: 3px solid #fff; font-size: 20px; }
  .tabbar .tab-main { color: var(--primary); }
  body[data-route="chon-noi"] .tabbar, body[data-route="admin"] .tabbar { display: none; }
  body[data-route="chon-noi"], body[data-route="admin"] { padding-bottom: env(safe-area-inset-bottom); }

  /* Nút mua dính dưới màn hình ở trang sản phẩm */
  .buybar {
    display: flex; gap: 10px; align-items: center;
    position: fixed; left: 8px; right: 8px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 65;
    background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow-lg);
  }
  .buybar .bb-info { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
  .buybar b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .buybar .price { font-size: 15px; }
  .buybar .btn { min-height: 44px; padding: 10px 16px; }
  body[data-route="san-pham"] .footer { padding-bottom: 90px; }

  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .cmpbar { bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* Chữ ô nhập ≥16px để iPhone không tự phóng to */
  .field input, .field select, .field textarea, textarea.big, .kv-row input, .video-row input, .big-edit, .filters input, .filters select { font-size: 16px; }

  h1 { font-size: 27px; }
  .hero { padding: 22px 18px; border-radius: 22px; gap: 0; }
  .hero .hero-visual { display: none; }
  .hero p.lead { font-size: 16px; }
  .hero .btn-lg { width: 100%; }
  .hero .row { gap: 6px; }
  .steps3 { margin: 18px 0; gap: 10px; }
  .steps3 .card { padding: 14px 16px; display: grid; grid-template-columns: 36px 1fr; column-gap: 12px; align-items: center; }
  .steps3 .num { margin: 0; grid-row: span 2; }
  .steps3 h3 { margin: 0; font-size: 16px; }
  .section-title { margin: 28px 0 12px; }
  .section-title h2 { font-size: 21px; }

  /* Danh sách nồi: lướt ngang 2 cột cho dễ so */
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pbody { padding: 10px 10px 12px; gap: 6px; }
  .pbody h3 { font-size: 15px; }
  .price { font-size: 16px; }
  .pmeta .chip { font-size: 12px; padding: 3px 8px; }
  .minibars { font-size: 11.5px; gap: 3px 6px; }
  .pactions { flex-direction: column; gap: 6px; }
  .pactions .btn { min-height: 40px; font-size: 13.5px; padding: 8px; }
  .badge { top: 8px; left: 8px; font-size: 11px; padding: 4px 8px; }
  .pcard .pimg { order: 1; }
  .pcard .cmp-check { order: 2; position: static; box-shadow: none; border-radius: 0; background: var(--bg); font-size: 12.5px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
  .pcard .pbody { order: 3; }
  .badge { max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .filters { padding: 12px; gap: 10px; grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .filters > .field:nth-child(4) { grid-column: 1 / -1; }
  .feat-filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .feat-filter::-webkit-scrollbar { display: none; }
  .feat-filter button { white-space: nowrap; }

  .qcard { padding: 20px 16px; }
  .qicon { font-size: 34px; }
  .qcard h2 { font-size: 22px; }
  .opt { padding: 12px 14px; }
  .opt .oi { font-size: 26px; width: 36px; }
  .seg button { padding: 11px 2px; font-size: 12px; }

  .winner .pimg { aspect-ratio: 4/3; min-height: 0; }
  .winner-body { padding: 18px 16px; }
  .ring { width: 64px; height: 64px; } .ring span { width: 50px; height: 50px; font-size: 16px; }
  .buy .btn { flex: 1 1 100%; }
  .alt { padding: 14px; }
  .alt-top .thumb { width: 70px; height: 70px; }

  .detail .pimg { aspect-ratio: 4/3; }
  .pad { padding: 16px; }
  .cta-band { padding: 18px; }
  .cta-band .btn { width: 100%; }

  /* Nhiều video: lướt ngang từng cái */
  .vgrid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; }
  .vgrid::-webkit-scrollbar { display: none; }
  .vgrid > .vbox { flex: 0 0 86%; scroll-snap-align: center; }
  .vgrid > .vbox.vert { flex: 0 0 56%; max-width: none; }
  .vgrid > .vbox:only-child { flex-basis: 100%; }
  .vgrid > .vbox.vert:only-child { flex-basis: 64%; margin: 0 auto; }

  /* Quản trị trên điện thoại */
  .aitem { display: grid; grid-template-columns: 56px 1fr; gap: 10px; }
  .aitem .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .aitem .acts .btn { margin-left: auto; }
  .kv-row { grid-template-columns: 1fr 1fr 36px; }
  .modal-body { padding: 12px; }
  .fsec { padding: 12px; }
  .score-edit label { grid-template-columns: 100px 1fr 28px; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .grid { grid-template-columns: 1fr; }
}
/* Quản trị: thông báo hiện phía trên để không che nút Lưu */
body[data-route="admin"] .toast { bottom: auto; top: 14px; transform: translate(-50%, -140px); }
body[data-route="admin"] .toast.show { transform: translate(-50%, 0); }

/* =========================================================
   CHẾ ĐỘ SỬA TRỰC TIẾP
   ========================================================= */
body.editing [data-edit], body.editing [data-edit-img] { outline: 2px dashed rgba(214, 40, 40, .55); outline-offset: 2px; border-radius: 4px; cursor: text; }
body.editing [data-edit-img] { cursor: pointer; position: relative; }
body.editing [data-edit]:hover, body.editing [data-edit-img]:hover { outline-color: var(--primary); background-color: rgba(255, 212, 0, .18); }
body.editing [data-edit]:empty::before { content: "(trống — chạm để viết)"; color: var(--muted); font-style: italic; font-weight: 400; }
body.editing [data-edit-img]::after { content: "📷 Đổi ảnh"; position: absolute; right: 8px; bottom: 8px; z-index: 4; background: rgba(31, 26, 23, .82); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; pointer-events: none; }
body.editing .avatar[data-edit-img]::after { content: "📷"; right: -4px; bottom: -4px; padding: 3px 6px; }
body.editing { padding-bottom: 170px !important; }
body.editing .tabbar, body.editing .buybar { display: none !important; }
.is-hidden { opacity: .55; }
.is-hidden::before { content: "🙈 Đang ẩn với khách"; position: absolute; z-index: 5; top: 44px; left: 8px; background: var(--warn); color: #fff; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.home-block { position: relative; }
.pre { white-space: pre-line; }
.m0 { margin: 0; }
.m0b8 { margin: 0 0 8px; }
.alt-name { margin: 6px 0 2px; }
.detail-title { font-size: clamp(26px, 5vw, 36px); margin: 0; }
.page-title { font-size: clamp(26px, 5vw, 36px); }
.cover-ph { display: grid; place-items: center; min-height: 160px; background: var(--bg-2); border-radius: var(--radius-sm); color: var(--muted); margin: 10px 0; }
.pot.has-img { overflow: visible; }
.pot.has-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 40px; }

/* Khối nội dung tự thêm ở trang chủ */
.home-block { margin-top: 18px; display: grid; gap: 18px; }
@media (min-width: 760px) { .home-block.has-img { grid-template-columns: 320px 1fr; align-items: center; } }
.hb-img { aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-2); display: grid; place-items: center; }
.hb-img img { width: 100%; height: 100%; object-fit: cover; }
.hb-body { display: grid; gap: 10px; align-content: start; }
.hb-body h2 { margin: 0; }

/* Nút thêm / sửa chỉ hiện khi đang sửa */
.edit-add { display: block; width: 100%; margin: 12px 0; padding: 12px; border: 2px dashed var(--primary); background: var(--primary-soft); color: var(--primary-dark); border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; font-size: 14.5px; }
.box .edit-add { margin: 8px 0 0; padding: 8px; font-size: 13.5px; }
.edit-fab { position: absolute; top: 8px; right: 8px; z-index: 6; background: var(--ink); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 12.5px; cursor: pointer; box-shadow: var(--shadow); }
.winner .pimg .edit-fab { top: auto; bottom: 8px; left: 8px; right: auto; }
.edit-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Thanh công cụ sửa */
.editbar { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); width: min(720px, calc(100% - 16px)); background: var(--ink); color: #fff; border-radius: 18px; padding: 10px 12px; box-shadow: var(--shadow-lg); display: grid; gap: 8px; }
.editbar.mini { width: auto; left: auto; right: 14px; transform: none; padding: 0; background: none; box-shadow: none; bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (min-width: 769px) { .editbar.mini { bottom: 18px; } }
.editbar.mini .btn { box-shadow: var(--shadow-lg); }
.eb-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eb-row select { flex: 1 1 160px; min-width: 0; border-radius: 10px; border: 0; padding: 9px 10px; font-size: 14.5px; background: #fff; color: var(--ink); }
.eb-row .btn-ghost { color: #fff; }
.eb-status { font-size: 13px; font-weight: 700; }
.eb-status.ok { color: #7ee2a1; } .eb-status.warn { color: var(--accent); } .eb-status.err { color: #ff9a9a; }
.eb-hint { font-size: 12px; opacity: .75; }
@media (max-width: 480px) { .eb-hint { display: none; } .eb-row .btn-sm { padding: 7px 10px; font-size: 13px; } }

/* Khung sửa trượt từ dưới lên */
.sheet-bg { position: fixed; inset: 0; z-index: 200; background: rgba(31, 26, 23, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; background: #fff; border-radius: 22px 22px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 12px; box-shadow: var(--shadow-lg); animation: sheetUp .22s ease; max-height: 88vh; overflow-y: auto; }
@media (min-width: 769px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 2px; }
.sheet input, .sheet textarea { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; line-height: 1.5; background: #fff; }
.sheet input:focus, .sheet textarea:focus { outline: none; border-color: var(--primary); }
.sheet-actions { gap: 8px; }
.sheet-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; max-height: 180px; overflow-y: auto; }
body.editing .toast { bottom: auto; top: 14px; transform: translate(-50%, -140px); }
body.editing .toast.show { transform: translate(-50%, 0); }
.editbar .btn-sm { min-height: 34px; }
@media (max-width: 480px) { .editbar { padding: 8px 10px; gap: 6px; } .editbar .eb-row > b { font-size: 14px; } }

/* =========================================================
   v6 — MOBILE-FIRST APP EXPERIENCE
   ========================================================= */
html { scroll-padding-top: 76px; }
.ssr { display: none; }
body.no-scroll { overflow: hidden; }

/* Thanh trên: logo + ô tìm kiếm */
.top-search { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 0 16px; min-height: 42px; font-size: 14.5px; cursor: pointer; margin-left: 12px; min-width: 220px; text-align: left; }
.top-search:hover { border-color: #d8c8b0; }
.top-search .ts-ph { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; border: 0; background: var(--ink); color: #fff; font-weight: 700; border-radius: 999px; padding: 14px 20px; box-shadow: var(--shadow-lg); cursor: pointer; font-size: 15px; }
.chat-fab:hover { background: #000; }
body[data-route="admin"] .chat-fab, body.editing .chat-fab { display: none; }

/* Vuốt ngang mượt (PC hiển thị dạng lưới) */
.hscroll { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.hscroll.vids { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.hscroll.vids .vbox:not(.vert) { aspect-ratio: 16/9; }

/* Ô tìm kiếm toàn màn hình */
.search-ov { position: fixed; inset: 0; z-index: 180; background: var(--bg); display: flex; flex-direction: column; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.search-bar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid var(--line); }
.search-bar input { flex: 1; border: 2px solid var(--primary); border-radius: 999px; padding: 0 16px; min-height: 46px; font-size: 16px; background: #fff; outline: none; }
.search-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.search-inline input { width: 100%; border: 2px solid var(--primary); border-radius: 999px; padding: 0 18px; min-height: 50px; font-size: 16px; margin-bottom: 14px; background: #fff; }
.sgroup { margin: 16px 0 8px; font-size: 15px; }
.slist { display: grid; gap: 8px; }
.srow { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; color: inherit; text-decoration: none; min-height: 56px; }
.sthumb { width: 56px; height: 56px; flex: none; border-radius: 10px; overflow: hidden; background: var(--bg-2); display: block; }
.stx { flex: 1; min-width: 0; display: grid; color: inherit; text-decoration: none; }
.stx b { font-size: 15px; }
.sic { font-size: 24px; width: 40px; text-align: center; flex: none; }
.sacts { display: flex; gap: 6px; flex: none; }
.chips-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.zero b { font-size: 16px; }

/* Hỏi Triệu 1-1 */
.contact-banner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 24px 0; padding: 16px 18px; border-radius: var(--radius); background: linear-gradient(135deg, #fff7da, #ffe8e0); border: 1px solid #f1d9b8; }
.contact-banner .cb-text { flex: 1 1 220px; display: grid; gap: 2px; }
.contact-banner .cb-text span { font-size: 14px; color: #5a4d42; }
#contact-msg { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; line-height: 1.5; }
.contact-actions { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.btn-zalo { background: #0068ff; color: #fff; border-color: #0068ff; }
.btn-mess { background: #7b3fe4; color: #fff; border-color: #7b3fe4; }
.avatar.sm { width: 32px; height: 32px; font-size: 16px; display: inline-grid; vertical-align: middle; }

/* Khay video */
.vdrawer-bg { position: fixed; inset: 0; z-index: 190; background: rgba(0, 0, 0, .82); display: flex; align-items: center; justify-content: center; padding: 12px; }
.vdrawer { width: min(860px, 100%); background: #111; color: #fff; border-radius: 18px; overflow: hidden; position: relative; display: grid; animation: sheetUp .2s ease; max-height: calc(100vh - 24px); }
.vdrawer.vert { width: min(400px, 100%); }
.vd-player { position: relative; aspect-ratio: 16/9; background: #000; }
.vdrawer.vert .vd-player { aspect-ratio: 9/16; max-height: calc(100vh - 220px); }
.vd-player iframe, .vd-player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vd-close { position: absolute; top: 10px; right: 10px; z-index: 3; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; cursor: pointer; }
.vd-title { padding: 10px 14px 0; font-weight: 700; }
.vd-product { display: flex; gap: 10px; align-items: center; padding: 10px 14px; }
.vd-thumb { width: 52px; height: 52px; border-radius: 10px; overflow: hidden; flex: none; background: #222; display: block; }
.vd-info { display: grid; } .vd-info .price { font-size: 15px; }
.vd-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; padding: 0 14px 14px; }
.vd-actions .btn { min-height: 48px; }
.zoom-bg { position: fixed; inset: 0; z-index: 195; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: 12px; cursor: zoom-out; }
.zoom-bg img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; background: #fff; }
#main-img, img[data-zoom] { cursor: zoom-in; }
body.editing #main-img { cursor: pointer; }

/* So sánh */
.cmp-toggles { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; min-height: 44px; font-weight: 600; font-size: 14px; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--primary); }
.sv-head { position: sticky; top: 54px; z-index: 20; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--line); }
.sv-head-cell { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; display: grid; gap: 4px; justify-items: center; text-align: center; }
.sv-thumb { width: 64px; height: 52px; border-radius: 8px; overflow: hidden; display: block; background: var(--bg-2); }
.sv-name { font-size: 13.5px; line-height: 1.25; }
.sv-price { font-size: 14px; }
.sv-head-cell select { width: 100%; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--bg); }
.sv-nav { display: flex; align-items: center; gap: 6px; }
.sv-nav .icon-btn { width: 44px; height: 40px; font-size: 20px; }
.sv-rows { display: grid; gap: 6px; margin-top: 10px; }
.sv-row { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sv-label { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 6px 10px; background: #fffdf9; border-bottom: 1px solid var(--line); }
.sv-cells { display: grid; grid-template-columns: 1fr 1fr; }
.sv-cell { padding: 8px 10px; font-size: 14px; }
.sv-cell + .sv-cell { border-left: 1px solid var(--line); }
.sv-cell.best, td.best { background: var(--ok-soft); font-weight: 700; }
ul.cl { margin: 0; padding-left: 16px; font-weight: 400; }
.req-table td { white-space: nowrap; font-size: 13.5px; }
.req-yes { color: var(--ok); } .req-no { color: var(--primary-dark); } .req-maybe { color: var(--warn); }
.res-title { margin-top: 12px; font-size: clamp(26px, 5vw, 38px); }

/* Bài viết */
.seg-tabs { display: inline-flex; gap: 4px; background: var(--bg-2); border-radius: 999px; padding: 4px; margin: 0 0 14px; }
.seg-tabs a { text-decoration: none; color: var(--muted); font-weight: 700; padding: 10px 16px; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center; }
.seg-tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.byline { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.takeaways { background: var(--accent-soft); border-left: 5px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin: 14px 0; }
.takeaways ul { margin: 8px 0 0; padding-left: 20px; }
.toc { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 14px 0; }
.toc summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }
.toc ol { margin: 8px 0 0; padding-left: 22px; }
.toc li { margin: 6px 0; }
.article-body h2 { font-size: 22px; margin: 1.4em 0 .5em; }
.faq { margin-top: 24px; }
.faq-item { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; background: #fff; }
.faq-item summary { cursor: pointer; padding: 14px 16px; font-weight: 700; min-height: 48px; }
.faq-item > div { padding: 0 16px 14px; }
.author-box { display: flex; gap: 14px; align-items: flex-start; margin-top: 24px; padding: 16px; border: 1.5px dashed #e6c9a8; border-radius: var(--radius); }
.inline-card { max-width: 320px; margin: 14px 0; }
.inline-cmp { margin: 14px 0 4px; }

/* Quản trị câu hỏi */
.qz-item .drag { cursor: grab; font-size: 20px; color: var(--muted); padding: 0 4px; }
.qz-item.is-off { opacity: .55; }
.qz-item.drag-over { outline: 2px dashed var(--primary); }
.qz-input { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; font-size: 15px; background: #fff; }
.fx-scores, .fx-feats { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-top: 6px; }
.fx-scores label, .fx-feats label { display: flex; justify-content: space-between; gap: 6px; align-items: center; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.fx-scores select, .fx-feats select { border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; }

/* ---------- ĐIỆN THOẠI ---------- */
@media (max-width: 768px) {
  .topbar-in { gap: 10px; }
  .logo { font-size: 16px; flex: none; }
  .logo .logo-text { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
  .top-search { margin-left: 0; min-width: 0; flex: 1; min-height: 40px; padding: 0 12px; font-size: 14px; }
  .chat-fab { display: none; }
  .tabbar { display: grid !important; grid-template-columns: repeat(5, 1fr); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; align-content: center; gap: 1px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; border-radius: 12px; min-height: 52px; border: 0; background: none; font-family: inherit; line-height: 1.15; text-align: center; }
  .tabbar .ti { font-size: 21px; line-height: 1.2; position: relative; }
  .tb-badge { position: absolute; top: -4px; right: -10px; background: var(--primary); color: #fff; font-style: normal; font-size: 10px; font-weight: 800; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
  .tabbar .tab-main .ti { font-size: 19px; }
  .tabbar.actionbar { grid-template-columns: 1fr 1.25fr; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .ab-btn { display: flex !important; align-items: center; justify-content: center; gap: 6px; min-height: 50px; border-radius: 14px; font-size: 14px !important; white-space: nowrap; font-weight: 800 !important; text-decoration: none; border: 0; cursor: pointer; font-family: inherit; }
  .ab-chat { background: var(--ink) !important; color: #fff !important; }
  .ab-shopee { background: var(--shopee) !important; color: #fff !important; box-shadow: 0 4px 14px rgba(238, 77, 45, .35); }
  body[data-route="san-pham"] .footer, body[data-route="so-sanh"] .footer { padding-bottom: 24px; }

  /* Vùng chạm tối thiểu 48px */
  .btn { min-height: 48px; }
  .btn-sm { min-height: 44px; }
  .opt, .preset, .chips-pick button, .feat-filter button, .seg button, .switch, .icon-btn { min-height: 48px; }
  .icon-btn { min-width: 44px; }
  .preset { display: inline-flex; align-items: center; }
  .chips-pick button { padding: 10px 14px; }
  input, select, textarea { font-size: 16px !important; }

  /* Danh sách vuốt ngang, lộ 1 phần thẻ kế tiếp */
  .hscroll { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin: 0 -14px; padding: 2px 14px 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .hscroll::-webkit-scrollbar { display: none; }
  .hscroll > * { flex: 0 0 74%; scroll-snap-align: start; }
  .hscroll.vids > .vbox { flex: 0 0 62%; }
  .hscroll.vids > .vbox.vert { flex: 0 0 44%; }
  .hscroll .pactions { flex-direction: row; }
  .contact-banner { padding: 14px; }
  .contact-banner .btn { width: 100%; }
  .vdrawer-bg { padding: 0; align-items: flex-end; }
  .vdrawer, .vdrawer.vert { width: 100%; border-radius: 18px 18px 0 0; max-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
  .vdrawer.vert .vd-player { max-height: calc(100vh - 210px); width: auto; }
  .seg-tabs { display: flex; }
  .seg-tabs a { flex: 1; justify-content: center; }
  .cmp-toggles { flex-wrap: nowrap; gap: 6px; }
  .cmp-toggles .switch { flex: 1 1 0; font-size: 12.5px; padding: 6px 10px; line-height: 1.2; }
  .req-table td, .req-table th { font-size: 12.5px; }
  .contact-actions { grid-template-columns: 1fr; }
}
@media (min-width: 769px) {
  .tabbar { display: none !important; }
  .nav { margin-left: auto; }
}
