/* Hồng Hạc City · "Tranh Đông Hồ × giấy điệp × hồng hạc"
   giấy điệp (ánh vỏ sò), đỏ son, vàng hoè, chàm, lá tre, hồng hạc, mực than
   Bevan (chữ khắc mộc bản) · Gelasio nghiêng (lời đề tranh) · Maven Pro (giao diện) */
:root {
  --giay: #efe6d2; --giay2: #e6d9bd; --son: #b8322a; --son2: #8f2019; --hoe: #e0a526;
  --cham: #26405e; --la: #2f6b4f; --hac: #e07a83; --muc: #1f1a17; --nau: #7a4a2a;
  --sh: 0 6px 18px rgba(31, 26, 23, .32);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-l: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--muc); color: var(--muc); font: 15px/1.45 'Maven Pro', system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.i { width: 22px; height: 22px; display: block; }
#pano { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#pano:active { cursor: grabbing; }

/* giấy điệp: nền kem + hạt điệp lấp lánh */
.paper {
  background-color: var(--giay);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .55) 0 1px, transparent 1.6px),
    radial-gradient(circle at 70% 60%, rgba(214, 196, 255, .35) 0 1px, transparent 1.6px),
    radial-gradient(circle at 40% 80%, rgba(255, 240, 200, .6) 0 .8px, transparent 1.4px),
    linear-gradient(115deg, rgba(255, 255, 255, .25), rgba(230, 217, 189, .35) 40%, rgba(255, 250, 235, .3) 60%, rgba(220, 205, 175, .3));
  background-size: 7px 7px, 11px 11px, 5px 5px, 100% 100%;
}

/* ================= MÀN CHÀO ================= */
.ld { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; transition: opacity .8s, transform .8s; }
.ld { background-color: var(--giay);
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.55) 0 1px, transparent 1.6px), radial-gradient(circle at 70% 60%, rgba(214,196,255,.35) 0 1px, transparent 1.6px), radial-gradient(circle at 40% 80%, rgba(255,240,200,.6) 0 .8px, transparent 1.4px), radial-gradient(ellipse at 50% 40%, #f7f0df, #e3d4b4 85%);
  background-size: 7px 7px, 11px 11px, 5px 5px, 100% 100%; }
.ld.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.ld-in { display: flex; align-items: center; gap: clamp(18px, 4vw, 56px); max-width: 980px; width: 100%; }
.ld-art { margin: 0; flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.frame { position: relative; height: min(64vh, 400px); aspect-ratio: 200 / 240; background: #f6eedb; border: 3px solid var(--muc); outline: 7px solid var(--son); outline-offset: 0; box-shadow: 0 0 0 10px var(--giay2), 0 0 0 12px var(--muc), 0 18px 40px rgba(60, 30, 10, .25); }
.frame .lay { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transform: translate(4px, -3px) scale(1.03); transition: opacity .55s ease, transform .55s cubic-bezier(.2, 1.4, .4, 1); }
.frame .lay.on { opacity: 1; transform: none; }
.frame .lay.l3 { mix-blend-mode: multiply; }
.cart { position: absolute; left: 8px; top: 8px; padding: 6px 5px; background: var(--son); color: var(--giay); font: 11px/1.15 'Bevan', serif; text-align: center; letter-spacing: .04em; border: 1.5px solid var(--muc); opacity: 0; transition: opacity .5s; }
.frame.done .cart { opacity: 1; }
.ld-art figcaption { font: italic 500 13px 'Gelasio', serif; color: var(--nau); margin-top: 10px; }
.ld-txt { flex: 1; min-width: 0; }
.ld-kick { margin: 0 0 4px; font: 700 12px 'Maven Pro'; letter-spacing: .22em; text-transform: uppercase; color: var(--son); }
.ld-title { margin: 0; font: 400 clamp(36px, 6.4vw, 66px)/1.02 'Bevan', serif; color: var(--muc); letter-spacing: -.01em; }
.ld-title em { font-style: normal; color: var(--hac); -webkit-text-stroke: 1.5px var(--muc); }
.ld-desc { margin: 10px 0 14px; max-width: 34em; font: italic 500 16px/1.45 'Gelasio', serif; color: #4a3a2c; }
.ld-bar { height: 6px; max-width: 420px; background: rgba(31, 26, 23, .12); border: 1px solid rgba(31, 26, 23, .35); }
.ld-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--son) 0 12px, var(--son2) 12px 14px); transition: width .25s; }
.ld-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 16px; }
.start { position: relative; padding: 13px 26px; background: var(--son); color: #fff6e6; font: 400 18px 'Bevan', serif; letter-spacing: .03em; border: 2px solid var(--muc); box-shadow: 4px 4px 0 var(--muc); transition: transform .15s, box-shadow .15s, opacity .3s; }
.start:not(:disabled):hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--muc); }
.start:not(:disabled):active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--muc); }
.start:disabled { opacity: .55; cursor: wait; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muc); }
.switch b { color: var(--son); }
.sw-track { width: 46px; height: 26px; border: 2px solid var(--muc); background: #d9ccb0; position: relative; transition: background .2s; }
.sw-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: var(--muc); transition: transform .2s, background .2s; }
.switch[aria-checked="true"] .sw-track { background: var(--hoe); }
.switch[aria-checked="true"] .sw-knob { transform: translateX(20px); background: var(--son); }
.ld-note { margin: 16px 0 0; font-size: 12px; color: #7d6a55; max-width: 36em; }

@media (max-height: 480px) and (orientation: landscape) {
  .frame { height: min(70vh, 280px); box-shadow: 0 0 0 6px var(--giay2), 0 0 0 8px var(--muc); outline-width: 5px; }
  .ld-art figcaption { margin-top: 6px; font-size: 12px; }
  .ld-title { font-size: 40px; }
  .ld-desc { margin: 6px 0 10px; font-size: 14px; }
  .ld-ctl { margin-top: 10px; }
  .start { padding: 10px 20px; font-size: 16px; }
  .ld-note { margin-top: 8px; font-size: 11px; }
}
@media (orientation: portrait) and (max-width: 700px) {
  .ld-in { flex-direction: column; text-align: center; gap: 22px; }
  .frame { height: min(38vh, 300px); }
  .ld-bar { margin: 0 auto; }
  .ld-ctl { justify-content: center; }
  .ld-desc, .ld-note { margin-left: auto; margin-right: auto; }
  .ld-title { font-size: 44px; }
}

/* ================= BẢNG TÊN CẢNH (nhãn đề tranh) ================= */
.plate { position: fixed; z-index: 10; top: max(12px, env(safe-area-inset-top)); left: calc(12px + var(--safe-l)); display: flex; align-items: stretch; max-width: min(560px, calc(100vw - 90px)); background: var(--giay); border: 2px solid var(--muc); box-shadow: var(--sh); }
.pl-seal { flex: none; display: grid; place-items: center; width: 46px; background: var(--son); color: var(--giay); font: 15px 'Bevan', serif; border-right: 2px solid var(--muc); letter-spacing: .02em; }
.pl-txt { padding: 6px 12px 7px; min-width: 0; }
.pl-txt small { display: block; font: italic 500 12.5px 'Gelasio', serif; color: var(--son); }
.pl-txt h2 { margin: 0; font: 400 18px/1.2 'Bevan', serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-nav { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-left: 1.5px dashed rgba(31, 26, 23, .35); }
.pl-nav small { font: 700 12px 'Maven Pro'; min-width: 34px; text-align: center; color: var(--nau); }
.pb { width: 32px; height: 32px; display: grid; place-items: center; }
.pb:hover { color: var(--son); }
.pb .i { width: 19px; height: 19px; }

/* ================= CÔNG CỤ: dấu son tròn ================= */
.tools { position: fixed; z-index: 10; right: calc(12px + var(--safe-r)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; }
.tb { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--son); color: var(--giay); border: 2px solid var(--muc); box-shadow: 0 0 0 2px var(--giay), var(--sh); transition: transform .15s, background .2s; }
.tb:hover { transform: rotate(-8deg) scale(1.06); }
.tb.on { background: var(--hoe); color: var(--muc); }
.tb.off { background: #8a7d6d; color: #e9e0cc; }
.tb .i { width: 21px; height: 21px; }

/* ================= THANG TẦNG SH12 ================= */
.floors { position: fixed; z-index: 10; left: calc(12px + var(--safe-l)); top: calc(max(12px, env(safe-area-inset-top)) + 70px); display: flex; flex-direction: column; background: var(--giay); border: 2px solid var(--muc); box-shadow: var(--sh); }
.floors::before { content: 'Tầng'; display: block; padding: 4px 0; text-align: center; font: italic 500 12px 'Gelasio', serif; color: var(--giay); background: var(--muc); }
.floors button { width: 52px; padding: 7px 0; font: 15px 'Bevan', serif; border-top: 1px solid rgba(31, 26, 23, .25); }
.floors button small { display: block; font: 500 10px 'Maven Pro'; color: var(--nau); }
.floors button.on { background: var(--son); color: var(--giay); }
.floors button.on small { color: #f3d7c8; }

/* ================= DOCK: các tờ khu + dải tranh ================= */
.dock { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; padding: 0 calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.dock > * { pointer-events: auto; }
.tabs { display: flex; gap: 6px; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 6px 2px 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; position: relative; padding: 9px 14px 7px; background: var(--giay); border: 2px solid var(--muc); box-shadow: 3px 3px 0 rgba(31, 26, 23, .55); text-align: left; transition: transform .15s; }
.tab::before { content: ''; position: absolute; left: -2px; right: -2px; top: -6px; height: 6px; background: var(--c); border: 2px solid var(--muc); border-bottom: 0; }
.tab b { display: block; font: 400 14px 'Bevan', serif; white-space: nowrap; }
.tab small { display: block; font: 500 11px 'Maven Pro'; color: var(--nau); }
.tab:hover { transform: translateY(-2px); }
.tab.on { background: var(--c); color: #fff8ea; transform: translateY(-4px); }
.tab.on small { color: rgba(255, 248, 234, .85); }
.tab.on.light { color: var(--muc); }
.tab.on.light small { color: rgba(31, 26, 23, .7); }
.strip { display: flex; gap: 10px; max-width: min(100%, 1100px); overflow-x: auto; padding: 10px; background: rgba(31, 26, 23, .78); border: 2px solid var(--muc); scrollbar-width: thin; scrollbar-color: var(--son) transparent; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.card { flex: none; width: 132px; padding: 5px 5px 4px; background: var(--giay); border: 1.5px solid var(--muc); text-align: left; transition: transform .15s; }
.card img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border: 1px solid var(--muc); background: #cbbd9f; }
.card span { display: block; margin-top: 3px; font: 500 12px/1.2 'Maven Pro'; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:hover { transform: translateY(-3px); }
.card.on { background: var(--son); color: var(--giay); }
.chip { flex: none; padding: 8px 14px; background: var(--giay); border: 1.5px solid var(--muc); font: 500 13px 'Maven Pro'; white-space: nowrap; }
.chip.on { background: var(--son); color: var(--giay); }

/* ================= ĐIỂM NÓNG ================= */
.hs-layer { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.hs { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; }
/* chuyển cảnh: con dấu tròn chân hạc + nhãn giấy */
.hs-go { display: flex; flex-direction: column; align-items: center; margin: -24px 0 0 -24px; width: 48px; }
.hs-go .mk { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: rgba(239, 230, 210, .92); color: var(--son); border: 2.5px solid var(--muc); box-shadow: 0 0 0 4px rgba(184, 50, 42, .55), var(--sh); animation: pulse 2.4s infinite; }
.hs-go .mk .i { width: 26px; height: 26px; }
.hs-go .lb { margin-top: 7px; padding: 3px 9px; background: var(--muc); color: var(--giay); font: 500 12.5px 'Maven Pro'; white-space: nowrap; }
.hs-go:hover .mk { background: var(--son); color: var(--giay); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(184, 50, 42, .55), var(--sh); } 50% { box-shadow: 0 0 0 10px rgba(184, 50, 42, 0), var(--sh); } }
/* tiện ích có ảnh: nhãn son đầu nhọn */
.hs-pin { display: flex; align-items: center; gap: 6px; margin: -15px 0 0 -12px; padding: 4px 10px 4px 5px; background: var(--son); color: #fff6e6; border: 1.5px solid var(--muc); box-shadow: var(--sh); font: 700 12.5px 'Maven Pro'; white-space: nowrap; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
.hs-pin .mk { width: 22px; height: 22px; display: grid; place-items: center; background: var(--hoe); color: var(--muc); border: 1px solid var(--muc); }
.hs-pin .mk .i { width: 15px; height: 15px; }
.hs-pin:hover { background: var(--son2); }
.hs-pin::after { content: ''; position: absolute; left: 6px; bottom: -8px; border: 5px solid transparent; border-top: 4px solid var(--muc); }
/* địa danh, công trình (không có ảnh): chấm mực + chữ đề */
.hs-lbl { pointer-events: none; display: flex; align-items: center; gap: 5px; margin: -6px 0 0 -6px; font: 700 12px 'Maven Pro'; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .85), 0 0 8px rgba(0, 0, 0, .5); white-space: nowrap; }
.hs-lbl::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--hoe); border: 2px solid var(--muc); flex: none; }
.hs-lbl.plan { font-weight: 500; font-style: italic; color: #f4e7c8; }
.hs-lbl.plan::before { background: var(--giay); }
body.touch .hs-lbl { font-size: 11px; }

/* ================= BẢNG TRƯỢT ================= */
.sheet { position: fixed; z-index: 30; right: calc(68px + var(--safe-r)); top: max(12px, env(safe-area-inset-top)); bottom: 12px; width: min(420px, calc(100vw - 92px)); overflow-y: auto; padding: 22px 22px 20px; border: 2px solid var(--muc); outline: 5px solid var(--son); outline-offset: -9px; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); animation: shIn .3s ease; }
.sheet { background-color: var(--giay); background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.55) 0 1px, transparent 1.6px), radial-gradient(circle at 70% 60%, rgba(214,196,255,.35) 0 1px, transparent 1.6px); background-size: 7px 7px, 11px 11px; }
@keyframes shIn { from { opacity: 0; transform: translateX(16px); } }
.sh-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; display: grid; place-items: center; background: var(--muc); color: var(--giay); border-radius: 50%; }
.sh-kick { margin: 4px 0 2px; font: italic 500 13px 'Gelasio', serif; color: var(--son); }
.sheet h2 { margin: 0 40px 10px 0; font: 400 22px/1.2 'Bevan', serif; }
.sheet h3 { margin: 16px 0 8px; font: 400 15px 'Bevan', serif; display: flex; align-items: center; gap: 8px; }
.sheet h3 i { width: 14px; height: 14px; background: var(--c); border: 1.5px solid var(--muc); }
.sheet p { margin: 0 0 10px; }
.sc-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.sc-list button { width: 100%; padding: 4px; background: #fbf6ea; border: 1.5px solid var(--muc); text-align: left; }
.sc-list img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.sc-list span { display: block; margin-top: 3px; font: 500 12px/1.2 'Maven Pro'; }
.sc-list .on { background: var(--son); color: var(--giay); }
.share { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.qr { background: #fff; padding: 8px; border: 2px solid var(--muc); }
.qr img { display: block; }
.url { font-size: 12px; word-break: break-all; color: var(--nau); margin-bottom: 8px; }
.ck { display: flex; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 10px; }
.btn { display: block; width: 100%; margin-bottom: 8px; padding: 9px 14px; background: var(--son); color: var(--giay); border: 2px solid var(--muc); font-weight: 700; }
.btn.ghost { background: transparent; color: var(--muc); }

/* ================= CUỘN TRANH (gallery) ================= */
.gal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 14px; background: rgba(20, 15, 12, .86); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.gal-in { position: relative; width: min(1000px, 100%); max-height: 100%; display: flex; flex-direction: column; align-items: center; }
.gal-kick { margin: 0 0 8px; font: 400 18px 'Bevan', serif; color: var(--giay); text-align: center; padding: 0 44px; }
.gal-mat { position: relative; padding: 10px; background: var(--giay); border: 2px solid var(--muc); outline: 4px solid var(--son); outline-offset: -8px; max-width: 100%; }
.gal-mat img { display: block; max-width: 100%; max-height: calc(100vh - 170px); max-height: calc(100dvh - 170px); object-fit: contain; border: 1.5px solid var(--muc); background: #2b241f; }
.gal-nv { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--son); color: var(--giay); border: 2px solid var(--muc); }
.gal-nv.prev { left: -8px; } .gal-nv.next { right: -8px; }
.gal-cap { margin: 10px 0 6px; color: var(--giay); font: italic 500 15px 'Gelasio', serif; text-align: center; }
.gal-cap small { font: 500 12px 'Maven Pro'; color: #c9b99a; margin-left: 6px; }
.gal-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.gal-dots button { width: 10px; height: 10px; border: 1.5px solid var(--giay); transform: rotate(45deg); }
.gal-dots button.on { background: var(--hoe); }
.gal-x { position: absolute; top: -2px; right: 0; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--giay); color: var(--muc); z-index: 2; }
@media (max-height: 480px) { .gal-mat img { max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); } .gal-kick { font-size: 15px; margin-bottom: 4px; } .gal-cap { margin: 4px 0; font-size: 13px; } }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 120px; transform: translate(-50%, 20px); padding: 9px 16px; background: var(--muc); color: var(--giay); border: 1.5px solid var(--hoe); font-size: 14px; opacity: 0; pointer-events: none; transition: .3s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* điện thoại */
@media (max-width: 700px) {
  .plate { max-width: calc(100vw - 76px); }
  .pl-seal { width: 36px; font-size: 12px; }
  .pl-txt h2 { font-size: 15px; }
  .pl-nav small { display: none; }
  .pb { width: 28px; }
  .tb { width: 40px; height: 40px; }
  .tools { gap: 6px; }
  .tab { padding: 7px 10px 5px; } .tab b { font-size: 12.5px; } .tab small { font-size: 10px; }
  .card { width: 108px; }
  .sheet { right: 8px; left: 8px; width: auto; top: auto; max-height: 72vh; bottom: 8px; }
  .floors { top: calc(max(12px, env(safe-area-inset-top)) + 62px); }
  .floors button { width: 44px; padding: 5px 0; font-size: 13px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .tools { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; width: 210px; gap: 5px; }
  .tb { width: 36px; height: 36px; } .tb .i { width: 18px; height: 18px; }
  .floors { top: calc(max(12px, env(safe-area-inset-top)) + 54px); flex-direction: row; }
  .floors::before { display: none; }
  .floors button { width: 46px; padding: 4px 0; border-top: 0; border-left: 1px solid rgba(31,26,23,.25); }
  .strip { padding: 6px; } .card { width: 96px; } .card span { font-size: 11px; }
  .tab { padding: 6px 10px 4px; } .tab small { display: none; }
  .sheet { top: 8px; bottom: 8px; right: 60px; }
  .plate { max-width: calc(100vw - 240px); }
}
