:root {
  --ink: #16181a;
  --ink-2: #5d6266;
  --paper: #f6f4ef;
  --card: rgba(252, 251, 248, 0.94);
  --line: rgba(22, 24, 26, 0.12);
  --accent: #1f8f3a;
  --accent-2: #a3c644;
  /* Bộ font BBO TECH: Anton tiêu đề · Squada One con số · Montserrat nội dung */
  --display: 'Anton', Impact, sans-serif;
  --brand: 'Squada One', Impact, sans-serif;
  --sans: 'Montserrat', system-ui, sans-serif;
  /* Anton có dấu tiếng Việt chữ hoa rất cao; dưới ~1.25 dấu dòng dưới đè dòng trên */
  --display-leading: 1.3;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(20, 22, 24, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- Thanh trên cùng ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-name { font-family: var(--display); font-size: 22px; font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-sub { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-2); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); backdrop-filter: blur(10px);
  font-size: 13px; font-weight: 500; text-decoration: none;
}
.chip:hover { border-color: var(--ink); }
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cart-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.cart-count[hidden] { display: none; }

/* ---------- Dấu thương hiệu BBO ---------- */
.made-by {
  position: fixed; left: 16px; bottom: 14px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 8px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2);
  text-decoration: none;
}
.made-by img { height: 22px; width: auto; display: block; }

.cur { font-family: var(--sans); font-size: 0.6em; font-weight: 600; margin-left: 0.2em; vertical-align: 0.1em; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 76px; z-index: 50;
  transform: translate(-50%, 20px); opacity: 0;
  padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 13px;
  transition: opacity .25s, transform .25s; pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--ink); background: transparent;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn svg { width: 18px; height: 18px; }

/* =========================================================
   PHÒNG TRƯNG BÀY
   ========================================================= */
.gallery-page { overflow: hidden; touch-action: none; }
#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; outline: none; }
#scene.can-pick { cursor: pointer; }

.hint {
  position: fixed; left: 50%; bottom: 22px; z-index: 15; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(22, 24, 26, 0.72); color: #fff; font-size: 12px; letter-spacing: 0.02em;
  transition: opacity .6s; white-space: nowrap; pointer-events: none;
}
.hint.hide { opacity: 0; }

.label {
  position: fixed; z-index: 14; pointer-events: none;
  transform: translate(-50%, -100%);
  padding: 6px 12px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--line);
  font-family: var(--display); font-size: 15px; font-weight: 400; letter-spacing: 0.02em; white-space: nowrap;
  opacity: 0; transition: opacity .15s;
}
.label.show { opacity: 1; }

/* Bảng thông tin tác phẩm */
.panel {
  position: fixed; z-index: 25; right: 20px; top: 50%;
  width: min(380px, calc(100vw - 32px));
  transform: translate(calc(100% + 40px), -50%);
  padding: 26px 26px 22px; border-radius: var(--radius);
  background: var(--card); backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}
.panel.open { transform: translate(0, -50%); }
.panel-close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: transparent; font-size: 22px; line-height: 1;
}
.panel-close:hover { background: rgba(0, 0, 0, .06); }
.panel-kicker { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.panel h2 { font-family: var(--display); font-size: 28px; line-height: var(--display-leading); font-weight: 400; margin: 6px 0 2px; }
.panel .orig { font-style: italic; font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
.panel dl { margin: 14px 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.panel dt { color: var(--ink-2); }
.panel dd { margin: 0; }
.panel .note { font-size: 12px; color: var(--ink-2); line-height: 1.5; margin: 0 0 14px; }
.panel .price { font-family: var(--brand); font-size: 28px; font-weight: 400; margin: 6px 0 16px; }
.panel .price small { font-family: var(--sans); font-size: 11px; font-weight: 500; color: var(--ink-2); margin-left: 8px; }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-actions .btn { padding: 0 12px; font-size: 13px; }
.panel-nav { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.panel-nav button { border: 0; background: none; font-size: 12px; color: var(--ink-2); padding: 6px 0; }
.panel-nav button:hover { color: var(--ink); }

/* Màn hình tải */
.loader {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; background: var(--paper);
  transition: opacity .8s .2s, visibility 0s 1s;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader-inner { width: min(360px, 80vw); text-align: center; }
.loader h1 { font-family: var(--display); font-weight: 400; font-size: 46px; line-height: var(--display-leading); margin: 0 0 4px; letter-spacing: .04em; text-transform: uppercase; }
.loader p { font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 28px; }
.bar { height: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s; }
.loader .pct { margin-top: 12px; font-family: var(--brand); font-size: 18px; color: var(--ink-2); }
.loader .enter { margin-top: 26px; opacity: 0; pointer-events: none; transition: opacity .4s; }
.loader.ready .enter { opacity: 1; pointer-events: auto; }

/* Thông số debug */
.stats {
  position: fixed; right: 12px; bottom: 12px; z-index: 30;
  padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, .75); color: #9f9;
  font: 11px/1.45 ui-monospace, Consolas, monospace; white-space: pre; pointer-events: none;
}

@media (max-width: 720px) {
  .topbar { padding: 10px 12px; }
  .brand-name { font-size: 19px; }
  .brand-sub { display: none; }
  .chip { height: 36px; padding: 0 12px; font-size: 12px; }
  .chip .txt { display: none; }
  .panel {
    top: auto; bottom: 0; right: 0; left: 0; width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(105%);
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 72vh; overflow: auto;
  }
  .panel.open { transform: translateY(0); }
  .panel h2 { font-size: 24px; }
  .panel dl { margin: 10px 0; }
  .made-by { bottom: auto; top: 58px; left: 12px; padding: 4px 8px; }
  .made-by span { display: none; }
  .made-by img { height: 18px; }
  .hint { white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 32px); }
}

/* =========================================================
   TRANG SẢN PHẨM
   ========================================================= */
.product-page { min-height: 100%; }
.product {
  max-width: 1200px; margin: 0 auto; padding: 84px 24px 60px;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; align-items: start;
}
.viewer-wrap {
  position: sticky; top: 84px;
  aspect-ratio: 1 / 1; border-radius: var(--radius);
  background: radial-gradient(120% 90% at 50% 30%, #ffffff 0%, #ebe8e1 100%);
  border: 1px solid var(--line); overflow: hidden;
}
model-viewer { width: 100%; height: 100%; --poster-color: transparent; --progress-bar-color: var(--ink); }
.viewer-tools {
  position: absolute; left: 14px; right: 14px; bottom: 14px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; pointer-events: none;
}
.viewer-tools > * { pointer-events: auto; }
.viewer-hint { font-size: 11px; color: var(--ink-2); background: var(--card); padding: 6px 10px; border-radius: 8px; }
.ar-btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 20px; border-radius: 999px; border: 0;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.ar-btn svg { width: 20px; height: 20px; }
.ar-btn[hidden] { display: none; }

.info .kicker { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.info h1 { font-family: var(--display); font-size: clamp(30px, 3.4vw, 46px); line-height: var(--display-leading); font-weight: 400; margin: 8px 0 4px; }
.info .orig { font-style: italic; font-size: 15px; color: var(--ink-2); margin: 0 0 6px; }
.info .artist { font-size: 14px; color: var(--ink-2); margin: 0 0 22px; }
.info .price { font-family: var(--brand); font-size: 36px; font-weight: 400; margin: 0 0 2px; }
.info .price-note { font-size: 12px; color: var(--ink-2); margin: 0 0 24px; }
.info .buy { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.specs { border-top: 1px solid var(--line); }
.specs div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.specs dt { color: var(--ink-2); }
.specs dd { margin: 0; }
.info .note { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin-top: 18px; }

.ar-tip {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 10px;
  background: #eef6e4; border-left: 3px solid var(--accent);
  font-size: 13px; line-height: 1.6; color: var(--ink);
}
.ar-prompt {
  position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%);
  max-width: 80%; padding: 12px 18px; border-radius: 999px;
  background: rgba(22, 24, 26, 0.78); color: #fff; font-size: 14px; text-align: center;
}

.ar-box {
  margin-top: 26px; padding: 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff;
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center;
}
.ar-box[hidden] { display: none; }
.ar-box .qr { width: 112px; height: 112px; }
.ar-box .qr svg, .ar-box .qr img { width: 100%; height: 100%; display: block; }
.ar-box h3 { margin: 0 0 6px; font-size: 15px; }
.ar-box p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.ar-box.warn { grid-template-columns: 1fr; background: #fff8e6; border-color: #f0dca8; }

.others { max-width: 1200px; margin: 0 auto; padding: 0 24px 80px; }
.others h2 { font-family: var(--display); font-weight: 400; font-size: 26px; line-height: var(--display-leading); margin: 0 0 14px; }
.others-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.others-list a {
  display: block; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  text-decoration: none; font-size: 13px;
}
.others-list a:hover { border-color: var(--ink); }
.others-list strong { display: block; font-family: var(--display); font-size: 16px; font-weight: 400; line-height: var(--display-leading); margin-bottom: 4px; }
.others-list span { font-family: var(--brand); font-size: 17px; }

@media (max-width: 860px) {
  .product { grid-template-columns: 1fr; gap: 24px; padding: 68px 16px 40px; }
  .viewer-wrap { position: relative; top: 0; aspect-ratio: 4 / 5; }
  .viewer-tools { justify-content: center; }
  .viewer-hint { display: none; }
  .specs div { grid-template-columns: 110px 1fr; }
  .others { padding: 0 16px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
