:root {
  --brand: #1E5B8C;
  --ink: #15212E;
  --muted: #5B6878;
  --glass: rgba(255, 255, 255, 0.9);
  --glass-line: rgba(21, 33, 46, 0.1);
  --shadow: 0 10px 30px rgba(10, 20, 35, 0.22);
  --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Newsreader", Georgia, "Times New Roman", serif;
  --gap: 14px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1520; color: var(--ink); font: 15px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

#pano { position: fixed; inset: 0; }

/* Marca */
.brandbar {
  position: fixed; top: calc(var(--gap) + env(safe-area-inset-top, 0px)); left: var(--gap);
  display: flex; align-items: center; gap: 12px; max-width: min(460px, calc(100% - 2 * var(--gap)));
  padding: 8px 16px 8px 8px; background: var(--glass); border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand-logo { height: 42px; max-width: 120px; object-fit: contain; border-radius: 8px; }
.brandbar:not(:has(.brand-logo:not([hidden]))) { padding-left: 16px; }
.tour-title { margin: 0; font: 500 21px/1.15 var(--display); letter-spacing: -0.01em; }
.tour-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tour-sub:empty { display: none; }

/* Barra de recorrido */
.scenebar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 4px; padding: 5px; background: var(--glass); border-radius: 999px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); max-width: calc(100% - 2 * var(--gap));
}
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 999px; background: transparent; }
.icon-btn:hover { background: rgba(21, 33, 46, 0.07); }
.scene-title { border: 0; background: transparent; padding: 4px 14px; display: flex; flex-direction: column; align-items: center; min-width: 170px; max-width: 320px; }
.scene-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.scene-count { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Herramientas */
.tools { position: fixed; right: var(--gap); bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; }
.tool { width: 46px; height: 46px; border: 0; border-radius: 14px; background: var(--glass); box-shadow: var(--shadow); display: grid; place-items: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tool:hover, .tool[aria-pressed="true"], .tool.active { background: var(--brand); color: #fff; }

/* Agente */
.agent-chip {
  position: fixed; left: var(--gap); bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 10px; padding: 9px 16px 9px 12px; border-radius: 999px;
  background: var(--brand); color: #fff; text-decoration: none; box-shadow: var(--shadow);
}
.agent-chip svg { width: 24px; height: 24px; }
.agent-text { display: flex; flex-direction: column; line-height: 1.2; font-size: 12px; }
.agent-text strong { font-size: 14px; font-weight: 600; }

/* Hotspots */
.hs-link { position: relative; width: 58px; height: 58px; margin: -29px 0 0 -29px; border: 0; padding: 0; background: none; }
.hs-ring {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: color-mix(in srgb, var(--brand) 72%, transparent); border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); transform: perspective(200px) rotateX(38deg); transition: transform .2s ease;
}
.hs-ring svg { width: 26px; height: 26px; stroke-width: 2.4; }
.hs-link:hover .hs-ring, .hs-link:focus-visible .hs-ring { transform: perspective(200px) rotateX(0) scale(1.08); }
.hs-label {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap;
  padding: 5px 11px; border-radius: 999px; background: rgba(15, 25, 38, 0.86); color: #fff; font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.hs-link:hover .hs-label, .hs-link:focus-visible .hs-label { opacity: 1; }
@media (hover: none) { .hs-label { opacity: 1; } }

.hs-info { position: relative; margin: -20px 0 0 -20px; }
.hs-info-btn { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #fff; background: rgba(15, 25, 38, 0.72); color: #fff; font: 600 18px/1 var(--display); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); }
.hs-info.open .hs-info-btn { background: var(--brand); }
.hs-card {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); width: 260px;
  padding: 14px 16px; border-radius: 14px; background: #fff; color: var(--ink); box-shadow: var(--shadow); display: none; text-align: left;
}
.hs-info.open .hs-card { display: block; }
.hs-card h3 { margin: 0 0 4px; font: 500 18px/1.2 var(--display); }
.hs-card p { margin: 0; font-size: 14px; color: var(--muted); white-space: pre-line; }

/* Paneles */
.panel {
  position: fixed; top: var(--gap); right: calc(var(--gap) + 58px); bottom: var(--gap); width: min(380px, calc(100% - 100px));
  display: flex; flex-direction: column; background: rgba(255, 255, 255, 0.96); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 20px; }
.panel-head h2 { margin: 0; font: 500 22px/1.2 var(--display); }
.panel-body { overflow: auto; padding: 4px 20px 20px; }
.group-name { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.group-name:first-child { margin-top: 4px; }
.room-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.room { border: 0; padding: 0; background: none; text-align: left; border-radius: 12px; }
.room-thumb { display: block; aspect-ratio: 4 / 3; border-radius: 12px; background-color: #d7dde4; background-size: 100% 600%; background-position: 0 40%; outline: 3px solid transparent; outline-offset: -3px; }
.room.current .room-thumb { outline-color: var(--brand); }
.room-name { display: block; margin-top: 5px; font-size: 13.5px; font-weight: 500; line-height: 1.25; }

.plan-wrap { position: relative; }
.plan-img { display: block; width: 100%; border-radius: 10px; }
.plan-pin { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid #fff; background: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.35); padding: 0; }
.plan-pin.current { background: var(--brand); width: 24px; height: 24px; margin: -12px 0 0 -12px; }
.hint { color: var(--muted); font-size: 13px; }

.info .price { margin: 4px 0 2px; font: 500 30px/1.1 var(--display); color: var(--brand); }
.info .op { color: var(--muted); font-size: 13px; }
.specs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 16px 0; background: var(--glass-line); border-radius: 12px; overflow: hidden; }
.spec { background: #fff; padding: 10px 8px; text-align: center; }
.spec b { display: block; font-size: 18px; font-weight: 600; }
.spec span { font-size: 12px; color: var(--muted); }
.desc { white-space: pre-line; margin: 0 0 18px; }
.agent-card { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--glass-line); }
.agent-card .who { flex: 1 0 100%; }
.agent-card .who b { display: block; }
.agent-card .who span { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--glass-line); background: #fff; text-decoration: none; color: var(--ink); font-weight: 500; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn svg { width: 18px; height: 18px; }

.credit { position: fixed; right: calc(var(--gap) + 58px); bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px) + 2px); margin: 0; font-size: 11px; color: rgba(255,255,255,.8); text-shadow: 0 1px 3px rgba(0,0,0,.6); }

.splash { position: fixed; inset: 0; display: grid; place-items: center; background: #0d1520; color: #fff; transition: opacity .6s ease; z-index: 10; }
.splash.gone { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-logo { max-height: 70px; max-width: 200px; margin-bottom: 14px; }
.splash-title { font: 500 26px/1.2 var(--display); margin: 0 0 18px; }
.loader { display: inline-block; width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  :root { --gap: 10px; }
  .brandbar { padding: 6px 12px 6px 6px; }
  .brand-logo { height: 34px; }
  .tour-title { font-size: 17px; }
  .scenebar { bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px) + 58px); }
  .scene-title { min-width: 0; }
  .agent-text span { display: none; }
  .agent-chip { padding: 10px 14px; }
  .tools { flex-direction: row; }
  .tool { width: 44px; height: 44px; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72vh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .credit { right: var(--gap); bottom: auto; top: calc(var(--gap) + env(safe-area-inset-top, 0px) + 64px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- v2: funciones tipo Kuula ---- */
.tool .on-off.on { display: none; }
.tool[aria-pressed="true"] .on-off.on { display: block; }
.tool[aria-pressed="true"] .on-off.off { display: none; }

.hs-text { margin: 0; transform: translate(-50%, -50%); padding: 6px 13px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none; }
.nadir { border-radius: 50%; display: grid; place-items: center; pointer-events: none; overflow: hidden; }
.nadir img { position: absolute; left: 18%; top: 18%; width: 64%; height: 64%; object-fit: contain; }

.card-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(8, 15, 25, 0.45); }
.card { position: relative; width: min(420px, 100%); max-height: calc(100% - 20px); overflow: auto; background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.card-close { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.9); }
.card-img { display: block; width: 100%; max-height: 300px; object-fit: cover; }
.card-body { padding: 18px 22px 22px; }
.card-body h3 { margin: 0 32px 6px 0; font: 500 23px/1.2 var(--display); }
.card-text { margin: 0 0 14px; color: var(--muted); white-space: pre-line; }
.card-text:empty { display: none; }

.vtoast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 30; padding: 12px 18px; border-radius: 12px; background: rgba(15, 25, 38, 0.92); color: #fff; font-weight: 500; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

/* Modo MLS: sin marca ni contacto del agente */
.mls .agent-chip, .mls .credit, .mls .agent-card, .mls .brand-logo, .mls .splash-logo { display: none !important; }

@media (max-width: 720px) {
  .tools { flex-direction: column; bottom: calc(var(--gap) + env(safe-area-inset-bottom, 0px) + 58px); }
  .scenebar { left: var(--gap); right: calc(var(--gap) + 52px); transform: none; justify-content: space-between; max-width: none; }
  .scene-title { flex: 1; min-width: 0; padding: 4px 6px; }
  .scene-count { font-size: 11px; }
}
@media (max-width: 720px) and (max-height: 640px) { .tool { width: 40px; height: 40px; } .tools { gap: 6px; } }
