/* LIVEVIEW Nhà mẫu (live.html): trái = ảnh phòng + điểm thiết bị, phải = khung điện thoại chạy app */
:root { --bg: #f6f4f0; --ink: #1d1d22; --mute: #8a8a94; --pri: #3d4bf0; --card: #ffffff; --line: #e7e5e0; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
html.embed, html.embed body { background: transparent; } /* nhúng website (live.js EMBED): nền trong suốt - thấy nền trang nhúng thay cho màu --bg */
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { display: block; }
.lv { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; max-width: 1560px; margin: 0 auto; padding: 14px 28px 48px; }
.lv-main, .lv-side { min-width: 0; } /* hàng tab phòng (cuộn ngang) không kéo cột rộng hơn màn hình */

/* cột trái */
.lv-qr { position: absolute; right: 16px; bottom: 16px; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 14px; background: rgba(255, 255, 255, .94); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); color: var(--ink); text-decoration: none; font-size: 12px; line-height: 1.35; }
.lv-qr[hidden] { display: none; } .lv-qr img { width: 84px; height: 84px; display: block; } .lv-qr b { display: block; font-size: 13px; } .lv-qr-ph { display: block; margin-top: 4px; font-size: 11.5px; color: #6b7080; font-variant-numeric: tabular-nums; }
@media (max-width: 640px), (orientation: landscape) and (max-height: 500px) { .lv-qr { display: none; } } /* chỉ điện thoại (dọc / ngang) - đang cầm máy thao tác app; tablet, máy tính, TV vẫn hiện QR */

.lv-stage { position: relative; aspect-ratio: 16 / 10; border-radius: 22px; overflow: hidden; background: #3a3632; isolation: isolate; }
.lv-img { position: absolute; inset: 0; background: center / cover no-repeat; transition: background-image .4s; }
.lv-img.empty { background: radial-gradient(120% 90% at 50% 10%, #8d877f 0, #5b5650 45%, #2f2c29 100%); display: grid; place-items: center; }
.lv-img.empty span { color: rgba(255, 255, 255, .55); font-size: 15px; text-align: center; letter-spacing: .3px; } .lv-img.empty small { display: block; font-size: 12px; margin-top: 4px; opacity: .8; }
.lv-glow i { position: absolute; width: 46%; aspect-ratio: 1; transform: translate(-50%, -30%); pointer-events: none; mix-blend-mode: screen; transition: background .6s; }
.lv-dim { position: absolute; inset: 0; background: #0a0c14; pointer-events: none; transition: opacity .6s ease; }
.lv-spots { position: absolute; inset: 0; }
/* tên phòng đang xem (thay dải tab phòng - phòng chọn trong app): cao 42px + lề như dải tab cũ -> ảnh phòng ngang vành trên điện thoại (dưới nút chọn app) */
.lv-room { display: flex; align-items: center; gap: 6px; width: max-content; height: 42px; margin: 4px 0 14px; padding: 0 16px 0 14px; border-radius: 999px; background: #e6e5e2; color: var(--pri); font-size: 13px; font-weight: 500; }
.lv-room svg { width: 18px; height: 18px; flex: none; }
.lv-main { position: relative; }
.lv-stage { container-type: inline-size; } /* cỡ icon theo bề rộng ảnh (cqw) - script đặt icon tính theo cỡ ~3,7% bề rộng */
.lv-lead { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.lv-lead line { vector-effect: non-scaling-stroke; stroke: rgba(255, 255, 255, .85); stroke-width: 1.4; } .lv-lead .sh line { stroke: rgba(0, 0, 0, .35); stroke-width: 3; }
.lv-spot { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
/* điểm thiết bị = icon thiết bị (bộ icon của app - vẽ cho nền thẻ trắng, có cả sản phẩm đen như ray / khoá / loa) trên nền trắng mờ trong suốt: icon đen / trắng đều rõ,
   vẫn nhìn xuyên phần nào hình phía sau; bật = viền vàng */
.lv-spot .pl { width: clamp(18px, 3.4cqw, 40px); height: clamp(18px, 3.4cqw, 40px); border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255, 255, 255, .9); box-shadow: 0 2px 8px rgba(0, 0, 0, .28); color: #2b2f8f; font-size: 18px; line-height: 1; transition: transform .15s, box-shadow .3s, border-color .3s, background .3s; }
.lv-spot .pl img { width: 72%; height: 72%; display: block; }
.lv-spot:hover .pl { transform: scale(1.12); background: rgba(255, 255, 255, .9); } .lv-spot.on .pl { border-color: #ffc85a; box-shadow: 0 0 0 2px rgba(255, 200, 90, .55), 0 0 12px 3px rgba(255, 200, 100, .5); }
/* nhãn (tên + trạng thái): chỉ hiện khi rê chuột / chọn - luôn hiện thì đè hình thiết bị */
.lv-spot .lb { position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: rgba(20, 20, 28, .85); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; display: none; gap: 6px; z-index: 2; pointer-events: none; }
.lv-spot:hover .lb, .lv-spot:focus-visible .lb { display: flex; } .lv-spot:hover { z-index: 3; }
.lv-spot .lb em { font-style: normal; color: #ffd98a; } .lv-spot:not(.on) .lb em { color: #b8bcc8; }

/* cột phải: chọn app + khung điện thoại */
.lv-side { display: flex; flex-direction: column; align-items: center; gap: 14px; position: relative; align-self: stretch; } /* chọn app ở trên ngang tab phòng; màn rộng: điện thoại đặt tuyệt đối, vành trên / dưới ngang ảnh phòng (live.js fit) */
.lv-seg { margin: 4px 0 5px; } /* trên 4px như tab phòng; dưới 5px bù vành kim loại 5px quanh điện thoại (box-shadow) - khoảng trống nhìn thấy = 14px */
@media (min-width: 1081px), (min-width: 641px) and (orientation: landscape) {
  .lv-side { contain: size; }
  .lv-side > .lv-phone { position: absolute; top: var(--phone-top, 65px); } /* độ ưu tiên cao hơn .lv-phone (position: relative) khai báo phía sau */
  .lv-phone, .lv-seg { flex-shrink: 0; }
}
.lv-seg { display: grid; grid-template-columns: 1fr 1fr; width: 240px; max-width: 100%; padding: 4px; border-radius: 999px; background: #e6e5e2; }
.lv-seg button { height: 34px; padding: 0 12px; border-radius: 999px; font-size: 12px; color: #444; } .lv-seg button.on { background: #fff; color: var(--pri); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
/* nhúng website (live.js EMBED) + tablet nằm ngang (html.fill - live.js fit): bỏ lề rộng, ảnh phòng kéo đầy phần còn lại (cảnh 3D tự theo tỉ lệ khung), cột điện thoại vừa đúng điện thoại */
@media (min-width: 641px) {
  html.embed, html.embed body, html.fill, html.fill body { height: 100%; overflow: hidden; }
  html.embed .lv { height: 100vh; max-width: none; padding: 8px 10px 10px; gap: 12px; }
  html.embed .lv-phone { box-shadow: 0 0 0 2px #9c978f, 0 0 0 4px #6c6862, 0 0 0 5px #2a2826; } /* bỏ bóng đổ lớn: mép iframe cắt bóng thành khối xám cạnh vuông dưới điện thoại */
  html.fill .lv { height: 100svh; min-height: 0; max-width: none; padding: 8px 10px 10px; gap: 12px; } /* svh: vùng luôn thấy (thanh công cụ Safari đang hiện) */
  html:is(.embed, .fill) .lv-main { display: flex; flex-direction: column; min-height: 0; } html:is(.embed, .fill) .lv-room { margin: 0 0 8px; flex: none; }
  html:is(.embed, .fill) .lv-stage { aspect-ratio: auto; flex: 1; min-height: 0; border-radius: 16px; }
  html:is(.embed, .fill) .lv-seg { width: 100%; margin: 0 0 5px; } html:is(.embed, .fill) .lv-seg button { padding: 0 4px; font-size: clamp(9px, 1.4vw, 12px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* iPhone (khổ 393 x 852): app chạy đúng kích thước thật rồi thu nhỏ vừa khung (--k do live.js tính); thanh trạng thái, Dynamic Island, thanh Home vẽ đè lên */
.lv-phone { position: relative; width: 320px; padding: calc(6px * var(--pk, 1)); border-radius: calc(53px * var(--pk, 1)); background: #0d0d0f; box-shadow: 0 0 0 2px #9c978f, 0 0 0 4px #6c6862, 0 0 0 5px #2a2826, 0 40px 70px -25px rgba(0, 0, 0, .45); } /* viền đen mỏng 6px (kiểu iPhone đời mới) + 3 vành kim loại */
.lv-k { position: absolute; width: 4px; border-radius: 2px; background: linear-gradient(90deg, #6c6862, #a7a29a); } .lv-k.k1 { left: -7px; top: calc(120px * var(--pk, 1)); height: calc(28px * var(--pk, 1)); } .lv-k.k2 { left: -7px; top: calc(170px * var(--pk, 1)); height: calc(52px * var(--pk, 1)); }
.lv-k.k3 { left: -7px; top: calc(232px * var(--pk, 1)); height: calc(52px * var(--pk, 1)); } .lv-k.k4 { right: -7px; top: calc(190px * var(--pk, 1)); height: calc(80px * var(--pk, 1)); } /* --pk: live.js fit */
.lv-screen { position: relative; width: 100%; aspect-ratio: 393 / 852; border-radius: calc(47px * var(--pk, 1)); overflow: hidden; background: #000; }
.lv-dev { position: absolute; left: 0; top: 0; width: 393px; height: 852px; transform: scale(var(--k, .76)); transform-origin: 0 0; }
.lv-dev iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #8fbfce; display: block; }
.lv-sb { position: absolute; left: 0; right: 0; top: 0; height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 4px 30px 0 52px; color: #fff; pointer-events: none; transition: color .2s; }
.lv-sb .t { font-size: 17px; font-weight: 600; letter-spacing: -.2px; } .lv-sb .ic { display: flex; align-items: center; gap: 6px; } .lv-sb .ic svg:nth-child(1) { width: 18px; } .lv-sb .ic svg:nth-child(2) { width: 17px; } .lv-sb .ic svg:nth-child(3) { width: 27px; }
.lv-sb.dark { color: #000; }
.lv-island { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); width: 126px; height: 37px; border-radius: 20px; background: #000; pointer-events: none; }
.lv-err { text-align: center; margin: 80px 16px; color: var(--mute); }

/* màn hẹp: điện thoại xuống dưới */
@media (min-width: 641px) and (max-width: 1080px) and (orientation: landscape) {
  .lv { grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; padding: 12px 20px 24px; }
}
@media (max-width: 640px), (max-width: 1080px) and (orientation: portrait) {
  .lv { grid-template-columns: minmax(0, 1fr); padding: 0 16px 24px; }
  .lv-side { align-self: auto; }
  .lv { padding-top: 12px; gap: 16px; } /* không có dải tab phòng phía trên: chừa lề trên cho ảnh phòng */
  .lv-main { width: 100%; }
  .lv-stage { margin-inline: auto; }
  /* màn hẹp: tên phòng đè góc trên trái ảnh phòng (không chiếm thêm chiều cao) */
  .lv-main { display: grid; justify-content: center; } .lv-main > * { grid-area: 1 / 1; } /* tên phòng + ảnh phòng cùng 1 ô lưới (cột = bề rộng ảnh do live.js fit đặt) */
  .lv-room { z-index: 6; justify-self: start; align-self: start; height: 28px; margin: 10px; padding: 0 10px; font-size: 12px; color: #333; background: rgba(255, 255, 255, .85); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); pointer-events: none; }
  .lv-room svg { width: 15px; height: 15px; }
  /* Chọn app thành cột bên trái, khung điện thoại dùng phần rộng còn lại. */
  .lv-side { flex-direction: row; justify-content: center; align-items: flex-start; gap: 12px; }
  .lv-seg { order: 0; flex: 0 0 76px; width: 76px; grid-template-columns: 1fr; gap: 4px; margin: 0; border-radius: 18px; }
  .lv-seg button { height: auto; min-height: 48px; padding: 8px 6px; border-radius: 14px; line-height: 1.3; }
  /* giữ 16:10 như ảnh vẽ (svg slice) - khung khác tỉ lệ thì ảnh bị cắt, điểm thiết bị (% khung) lệch khỏi hình */
  .lv-stage { border-radius: 14px; }
  .lv-spot { gap: 2px; } .lv-spot .pl { font-size: 13px; border-width: 1px; } .lv-spot.on .pl { box-shadow: 0 0 0 1.5px rgba(255, 200, 90, .6), 0 0 7px 2px rgba(255, 200, 100, .5); }
  .lv-spot .lb { display: none; } /* màn hẹp: không có rê chuột - chạm icon = mở thiết bị trong app */
  /* Cắt 54px vùng trạng thái của app (trước khi scale), giữ nguyên vùng thao tác phía dưới. */
  .lv-phone { flex-shrink: 0; width: min(320px, calc(100% - 102px)); padding-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; box-shadow: 0 0 0 2px #9c978f, 0 0 0 4px #6c6862, 0 0 0 5px #2a2826; clip-path: inset(0 -10px -10px); }
  /* Mép mở tan vào nền để thấy khung được chủ ý cắt; không chặn thao tác app. */
  .lv-phone::after { content: ""; position: absolute; z-index: 5; top: 0; left: -8px; right: -8px; height: 20px; background: linear-gradient(to bottom, var(--bg), transparent); pointer-events: none; }
  .lv-screen { aspect-ratio: 393 / 798; border-top-left-radius: 0; border-top-right-radius: 0; }
  .lv-dev { top: calc(-54px * var(--k, .76)); }
  .lv-sb, .lv-island { display: none; }
}
/* điện thoại: viền đen khung điện thoại mỏng 3px (thay 6px); lề trên 0, dưới 3px (+ vành 5px), cách ảnh phòng 6px, dải mờ đầu khung 10px - khung phóng to lấp phần bớt ra */
@media (max-width: 640px) {
  .lv { padding-top: 0; padding-bottom: 3px; row-gap: 6px; } /* trên: ảnh phòng sát thanh trạng thái iPhone (Safari không cho trang vẽ dưới thanh trạng thái) */
  .lv-phone { padding: 0 3px 3px; }
  .lv-phone::after { height: 10px; }
}
.lv-img canvas.lv-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; } /* cảnh 3D (live-3d.js) */

/* Ảnh phòng rõ nét trong khi 3D dựng phía sau; thông báo nhỏ không chặn thao tác. */
@media (min-width: 641px) and (max-width: 1366px) and (orientation: landscape) and (any-pointer: coarse) {
  .lv { min-height: 100svh; padding-bottom: 10px; }
  .lv-phone { box-shadow: 0 0 0 2px #9c978f, 0 0 0 4px #6c6862, 0 0 0 5px #2a2826; }
}
/* Giữ QR trên TV kể cả khi viewport nhỏ hoặc remote được báo là con trỏ coarse. */
html.tv .lv-qr:not([hidden]) { display: flex; }
.lv-scene { position: absolute; inset: 0; opacity: 0; transition: opacity .35s ease; }
.lv-scene.ready { opacity: 1; }
.lv-preview { position: absolute; inset: 0; z-index: 3; opacity: 0; pointer-events: none; transition: opacity .35s ease; background: #e9e5df; }
.lv-preview.on { opacity: 1; }
.lv-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lv-preview-status { position: absolute; left: 14px; bottom: 14px; width: min(240px, calc(100% - 28px)); padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.92); color: #4c4c52; font-size: 12px; }
.lv-preview-status progress { display: block; width: 100%; height: 6px; margin-top: 7px; accent-color: var(--pri); }
.lv-stage.previewing .lv-spots { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .lv-scene, .lv-preview { transition: none; } }

/* MIỄN TRỪ TRÁCH NHIỆM (live.html #terms): phủ cả trang, liveview vẫn tải + dựng cảnh phía sau */
.lv-terms { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(20, 20, 26, .55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.lv-terms[hidden] { display: none; }
.lv-terms-box { width: min(560px, 100%); max-height: calc(100svh - 32px); display: flex; flex-direction: column; gap: 14px; padding: 24px; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.lv-terms h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.lv-terms-body { overflow-y: auto; font-size: 14.5px; line-height: 1.55; color: #3a3a42; }
.lv-terms-body p { margin: 0 0 10px; } .lv-terms-body p:last-child { margin-bottom: 0; }
.lv-terms-ok { height: 48px; border-radius: 14px; background: var(--pri); color: #fff; font-weight: 600; font-size: 15px; }
.lv-terms-ok:disabled { opacity: .45; cursor: default; } /* cảnh 3D chưa sẵn sàng */
.lv-terms-ok:focus-visible { outline: 3px solid rgba(61, 75, 240, .45); outline-offset: 3px; } /* TV: điều khiển từ xa - thấy nút đang chọn */
