:root {
  --accent: #b3261e;
  --accent-2: #e0483e;
  --glass: rgba(18, 22, 30, 0.72);
  --glass-2: rgba(30, 36, 48, 0.85);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f3f5f8;
  --muted: #a9b3c1;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1016; color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }

#pano { position: fixed; inset: 0; }
.pano-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.pano-canvas:active { cursor: grabbing; }
#fade { position: fixed; inset: 0; background: #0d1016; pointer-events: none; opacity: 1; transition: opacity .35s; z-index: 5; }
#fade.off { opacity: 0; }

/* ---------- Hotspots ---------- */
#hotspots { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.hs { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hs-link .dot { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.22); border: 3px solid #fff; display: grid; place-items: center; backdrop-filter: blur(2px); box-shadow: 0 0 0 0 rgba(255,255,255,.6); animation: pulse 2.2s infinite; transition: transform .15s; }
.hs-link .dot svg { width: 26px; height: 26px; stroke: #fff; stroke-width: 3; fill: none; }
.hs-link:hover .dot { transform: scale(1.12); background: var(--accent); }
.hs-info .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; display: grid; place-items: center; font-weight: 800; font-family: Georgia, serif; font-style: italic; font-size: 18px; transition: transform .15s; }
.hs-info:hover .dot { transform: scale(1.15); }
.hs .lbl { background: var(--glass); padding: 4px 10px; border-radius: 999px; font-size: 13px; white-space: nowrap; border: 1px solid var(--line); }
.hs-info .lbl { opacity: 0; transition: opacity .15s; }
.hs-info:hover .lbl { opacity: 1; }
.hs.route .dot { background: #1f9d55; animation: pulse-g 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.55);} 70% { box-shadow: 0 0 0 16px rgba(255,255,255,0);} 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0);} }
@keyframes pulse-g { 0% { box-shadow: 0 0 0 0 rgba(31,157,85,.8);} 70% { box-shadow: 0 0 0 20px rgba(31,157,85,0);} 100% { box-shadow: 0 0 0 0 rgba(31,157,85,0);} }

/* ---------- Brand ---------- */
#brand { position: fixed; top: 16px; left: 16px; z-index: 6; background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; backdrop-filter: blur(8px); max-width: min(380px, calc(100vw - 32px)); }
.brand-top { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .5px; }
.logo { background: var(--accent); padding: 2px 8px; border-radius: 6px; }
#tourSub { color: var(--muted); font-size: 13px; margin-top: 2px; }
#sceneTitle { font-size: 20px; font-weight: 700; margin-top: 10px; }
#sceneZone { color: var(--muted); font-size: 13px; }

/* ---------- Toolbar ---------- */
#toolbar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 9; display: flex; gap: 4px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px; backdrop-filter: blur(8px); }
#toolbar button[hidden] { display: none; }
#toolbar button { white-space: nowrap; background: none; border: 0; border-radius: 999px; padding: 8px 12px; display: flex; align-items: center; gap: 6px; font-size: 13px; }
#toolbar button:hover, #toolbar button.on { background: rgba(255,255,255,.14); }
#toolbar svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#toolbar .ai-btn { background: var(--accent); }
#toolbar .ai-btn:hover, #toolbar .ai-btn.on { background: var(--accent-2); }

/* ---------- Drawers ---------- */
.drawer { position: fixed; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 8; background: var(--glass-2); backdrop-filter: blur(10px); border: 1px solid var(--line); display: flex; flex-direction: column; transition: transform .28s ease; }
.drawer.left { left: 0; transform: translateX(-105%); }
.drawer.right { right: 0; transform: translateX(105%); }
.drawer.open { transform: none; }
.drawer-head, .card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 17px; margin: 0; }
.drawer-head small { font-weight: 400; color: var(--muted); font-size: 12px; }
.close { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); }
.close:hover { color: #fff; }
#search { margin: 12px 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: #fff; }
#menuList { overflow-y: auto; padding: 0 8px 90px; }
.zone { margin-bottom: 4px; }
.zone-name { padding: 10px 8px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); display: flex; justify-content: space-between; }
.scene-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.scene-item:hover { background: rgba(255,255,255,.08); }
.scene-item.cur { background: var(--accent); }
.empty { padding: 4px 12px 8px; font-size: 13px; color: #6f7a88; font-style: italic; }

/* ---------- Cards ---------- */
.card { position: fixed; z-index: 6; background: var(--glass-2); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px); display: none; }
.card.open { display: block; }
.card-head { padding: 10px 14px; font-weight: 600; font-size: 14px; }
#map { left: 16px; bottom: 84px; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 110px); overflow-y: auto; }
#mapBox { position: relative; margin: 10px; border-radius: 8px; overflow: hidden; background: #fff; }
#mapImg { display: block; width: 100%; }
#mapDots { position: absolute; inset: 0; }
.mdot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #1f4e79; border: 2px solid #fff; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.mdot:hover { transform: scale(1.3); }
.mdot.cur { background: var(--accent); width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.mdot .tip { position: absolute; bottom: 140%; left: 50%; transform: translateX(-50%); background: #111; color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; display: none; }
.mdot:hover .tip { display: block; }
.mcone { position: absolute; width: 0; height: 0; pointer-events: none; }
.mcone::before { content: ""; position: absolute; left: -22px; top: -44px; width: 44px; height: 44px; background: conic-gradient(from -30deg at 50% 100%, rgba(179,38,30,.55) 0 60deg, transparent 60deg); }
#mapNote { font-size: 11px; color: var(--muted); padding: 0 12px 10px; }
#info { right: 16px; top: 16px; width: min(380px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; }
#infoBody { padding: 12px 16px 16px; font-size: 14px; line-height: 1.55; }
#infoBody .tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
#infoBody .tags span { background: rgba(255,255,255,.1); padding: 2px 8px; border-radius: 999px; font-size: 12px; }

.map-tabs { display: flex; gap: 4px; }
.map-tab { background: none; border: 0; padding: 4px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.map-tab.on { background: rgba(255,255,255,.15); color: #fff; }
#mapBox[hidden], #mmWrap[hidden], #mapNote[hidden] { display: none; }
#meDot { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 2; }
#meDot[hidden] { display: none; }
#meDot .acc { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(26,115,232,.18); border: 1px solid rgba(26,115,232,.5); min-width: 16px; min-height: 16px; }
#meDot .pt, .me-dot-map { position: absolute; left: -8px; top: -8px; box-sizing: border-box; width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(26,115,232,.6); animation: me 1.8s infinite; }
@keyframes me { 0% { box-shadow: 0 0 0 0 rgba(26,115,232,.6);} 70% { box-shadow: 0 0 0 14px rgba(26,115,232,0);} 100% { box-shadow: 0 0 0 0 rgba(26,115,232,0);} }
#mmWrap { position: relative; margin: 10px; }
#mm { position: relative; height: 260px; overflow: hidden; border-radius: 8px; background: #dfe5ea; touch-action: none; cursor: grab; }
.mm-tiles img { position: absolute; width: 256px; height: 256px; user-select: none; }
.mm-marks { position: absolute; inset: 0; }
.mm-marks > * { position: absolute; }
.mm-marks > .me-dot-map { margin: -8px 0 0 -8px; }
.mm-acc { transform: translate(-50%, -50%); border-radius: 50%; background: rgba(26,115,232,.15); border: 1px solid rgba(26,115,232,.5); pointer-events: none; }
.mm-ctl { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; }
.mm-ctl button, .mm-ctl select { background: #fff; color: #222; border: 1px solid #bbb; border-radius: 6px; min-width: 32px; height: 32px; font-size: 16px; }
.mm-ctl select { font-size: 12px; }
#mmAttr { position: absolute; right: 4px; bottom: 2px; font-size: 10px; color: #333; background: rgba(255,255,255,.75); padding: 0 4px; border-radius: 3px; }
#geo { padding: 0 12px 12px; font-size: 13px; line-height: 1.5; display: flex; flex-direction: column; gap: 6px; }
#geoStatus i { color: var(--muted); }
.geo-acts { margin-top: 4px; }
.geo-acts a, .geo-acts button, #geoBtn { display: inline-block; background: #1a73e8; color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; text-decoration: none; }
#geoBtn { align-self: flex-start; }
#geoBtn.on { background: #555; }
.geo-warn { color: #ffcf70; font-size: 12px; }
#edGeo button { background: #1a73e8; color: #fff; border: 0; border-radius: 6px; padding: 2px 8px; font-size: 11px; }

/* ---------- Modal ---------- */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; }
#modal[hidden] { display: none; }
.modal-box { position: relative; background: #fff; color: #1b1f27; border-radius: var(--radius); max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 22px 24px; }
.modal-box h3 { margin: 0 0 10px; color: var(--accent); }
.modal-box img { width: 100%; border-radius: 8px; margin-bottom: 10px; }
.modal-box .close { position: absolute; top: 10px; right: 14px; color: #666; }
#modalText { line-height: 1.6; }
.modal-audio { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
#modalPlay { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 13px; }
#modalPlay[hidden] { display: none; }
#modalPlay.on { background: #333; }
.modal-audio small { color: #8a6d00; font-size: 12px; }
.head-acts { display: flex; align-items: center; gap: 8px; }
#aiSpeak { background: rgba(255,255,255,.1); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
#aiSpeak.on { background: var(--accent); }
.msg .src { margin-top: 8px; font-size: 12px; opacity: .85; }
.msg .src a { color: #ffd2cf; }
.msg .say { background: none; border: 0; color: inherit; opacity: .7; font-size: 12px; padding: 0; margin-left: 6px; text-decoration: underline; }
.msg .part { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,.2); }
.msg .part:first-child { margin-top: 0; padding-top: 0; border: 0; }

/* ---------- Chat ---------- */
#chat { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.bot { background: rgba(255,255,255,.1); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--accent); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg .acts button { background: #fff; color: #1b1f27; border: 0; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.msg .route { margin: 6px 0 0; padding-left: 18px; }
#chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 10px; }
#chips button { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; }
#chatForm { display: flex; gap: 8px; padding: 12px 12px 6px; border-top: 1px solid var(--line); }
#chatInput { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: #fff; }
#chatForm #sendBtn { background: var(--accent); border: 0; border-radius: 10px; padding: 0 16px; font-weight: 600; }

/* ---------- Editor ---------- */
#editor { position: fixed; top: 16px; right: 16px; z-index: 15; background: #fffbe6; color: #222; border: 2px solid #e0a800; border-radius: 10px; padding: 10px 12px; font-size: 12px; width: 320px; }
#editor[hidden] { display: none; }
#edOut { background: #222; color: #9fe79f; padding: 8px; border-radius: 6px; white-space: pre-wrap; max-height: 160px; overflow: auto; font-size: 11px; }
#edCopy { background: #e0a800; border: 0; border-radius: 6px; padding: 4px 10px; font-weight: 600; }
#crosshair { position: fixed; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; z-index: 4; pointer-events: none; border: 2px solid #ffde59; border-radius: 50%; }
#crosshair[hidden] { display: none; }

#toast { position: fixed; top: 20px; left: 50%; transform: translate(-50%, -80px); background: var(--glass-2); padding: 10px 16px; border-radius: 10px; z-index: 30; transition: transform .3s; font-size: 14px; border: 1px solid var(--line); }
#toast.show { transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  #toolbar { bottom: 10px; max-width: calc(100vw - 16px); overflow-x: auto; }
  #toolbar span { display: none; }
  #toolbar button { padding: 10px; }
  #brand { top: 10px; left: 10px; padding: 8px 12px; }
  #sceneTitle { font-size: 16px; margin-top: 6px; }
  #map { left: 8px; right: 8px; width: auto; bottom: 74px; }
  #info { left: 8px; right: 8px; top: auto; bottom: 74px; width: auto; max-height: 45vh; }
  .hs-link .dot { width: 46px; height: 46px; }
  #editor { width: calc(100vw - 20px); right: 10px; top: auto; bottom: 80px; }
}

/* ---------- Giọng nói ---------- */
#micBtn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.08); display: grid; place-items: center; }
#micBtn svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2; fill: none; stroke-linecap: round; }
#micBtn.on { background: var(--accent); animation: mic 1.2s infinite; }
#micBtn[disabled] { opacity: .35; cursor: not-allowed; }
@keyframes mic { 0% { box-shadow: 0 0 0 0 rgba(224,72,62,.7);} 70% { box-shadow: 0 0 0 12px rgba(224,72,62,0);} 100% { box-shadow: 0 0 0 0 rgba(224,72,62,0);} }
#listenBar { display: flex; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 8px 12px; border-radius: 10px; background: rgba(179,38,30,.25); border: 1px solid rgba(224,72,62,.5); font-size: 13px; }
#listenBar[hidden] { display: none; }
#listenText { flex: 1; font-style: italic; }
#listenStop { background: #fff; color: #222; border: 0; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.wave { display: flex; gap: 3px; align-items: center; height: 18px; }
.wave i { width: 3px; background: #fff; border-radius: 2px; animation: wv 0.9s infinite ease-in-out; }
.wave i:nth-child(2) { animation-delay: .15s } .wave i:nth-child(3) { animation-delay: .3s } .wave i:nth-child(4) { animation-delay: .45s }
@keyframes wv { 0%,100% { height: 4px } 50% { height: 18px } }
#aiHands { background: rgba(255,255,255,.1); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
#aiHands.on { background: #1f9d55; }
.msg.me .via { font-size: 11px; opacity: .75; margin-top: 4px; }
.msg.bot.speaking { outline: 2px solid rgba(255,255,255,.35); }
@media (max-width: 720px) { .head-acts button { font-size: 11px; padding: 3px 8px; } }
.head-acts button { white-space: nowrap; }
#ai .drawer-head h2 { font-size: 16px; }

#voiceRow { display: flex; align-items: center; gap: 8px; padding: 0 12px 84px; font-size: 12px; color: var(--muted); }
#voiceRow[hidden] { display: none; }
#voiceSel { flex: 1; min-width: 0; background: rgba(0,0,0,.25); color: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 12px; }
#voiceTest { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
#edScript { background: #1f4e79; color: #fff; border: 0; border-radius: 6px; padding: 4px 10px; font-weight: 600; }
