:root {
  --tinta: #f6f4ef;
  --tinta-suave: rgba(246, 244, 239, .72);
  --vidrio: rgba(22, 24, 27, .52);
  --vidrio-fuerte: rgba(22, 24, 27, .78);
  --borde: rgba(255, 255, 255, .16);
  --acento: #d9c3a0;
  --fondo: #16181b;
  --seguro-ab: env(safe-area-inset-bottom, 0px);
  --seguro-ar: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fondo); color: var(--tinta);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#visor { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#visor.arrastrando { cursor: grabbing; }
#lienzo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#inicial { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 52%; filter: blur(2px); transform: scale(1.04); transition: opacity .8s; }
#inicial.oculto { opacity: 0; pointer-events: none; }
#puntos { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* Puntos de navegacion */
.punto { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: translate(-50%, -50%); will-change: transform; padding: 6px; }
.punto .aro { width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .95);
  background: rgba(255, 255, 255, .18); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .35); display: grid; place-items: center; position: relative; }
.punto .aro::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.punto .aro::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55); animation: pulso 2.2s ease-out infinite; }
.punto .etiqueta { font-size: 13px; font-weight: 600; letter-spacing: .01em; padding: 6px 11px; border-radius: 999px; white-space: nowrap;
  background: var(--vidrio-fuerte); border: 1px solid var(--borde); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.punto:hover .aro, .punto:focus-visible .aro { background: rgba(255, 255, 255, .35); }
.punto:focus-visible { outline: none; }
.punto:focus-visible .etiqueta { outline: 2px solid var(--acento); }
@keyframes pulso { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }

/* Cabecera */
#cabecera { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(12px + var(--seguro-ar)) 16px 0; pointer-events: none; z-index: 5; }
#cabecera::before { content: ""; position: absolute; inset: 0 0 -40px 0; background: linear-gradient(rgba(0,0,0,.42), rgba(0,0,0,0)); z-index: -1; }
.marca { display: flex; flex-direction: column; line-height: 1.15; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
.marca .modelo { font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.marca .residencial { font-size: 12.5px; color: var(--tinta-suave); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }
.acciones { pointer-events: auto; display: flex; gap: 8px; }
.icono { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--vidrio);
  border: 1px solid var(--borde); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* Nombre del ambiente */
#ambiente { position: fixed; left: 50%; top: calc(74px + var(--seguro-ar)); transform: translateX(-50%); z-index: 4; pointer-events: none; }
#ambiente span { display: inline-block; font-size: 15px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  background: var(--vidrio); border: 1px solid var(--borde); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity .35s, transform .35s; white-space: nowrap; }
#ambiente.cambio span { opacity: 0; transform: translateY(-6px); }

#ayuda { position: fixed; left: 50%; bottom: calc(110px + var(--seguro-ab)); transform: translateX(-50%); z-index: 4; pointer-events: none;
  transition: opacity .8s; width: max-content; max-width: calc(100% - 32px); }
#ayuda span { display: block; font-size: 13px; text-align: center; padding: 8px 14px; border-radius: 12px; background: var(--vidrio-fuerte); border: 1px solid var(--borde); }
#ayuda.oculto { opacity: 0; }

/* Pie: barra de ambientes */
#pie { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 0 0 calc(8px + var(--seguro-ab)); }
#pie::before { content: ""; position: absolute; inset: -60px 0 0 0; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.55)); z-index: -1; pointer-events: none; }
#barra { display: flex; align-items: center; gap: 8px; padding: 0 16px; }
.plano-btn { flex: 0 0 auto; width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 14px; background: var(--vidrio-fuerte); border: 1px solid var(--borde); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 12px; font-weight: 600; min-height: 44px; flex-direction: row; gap: 6px; padding: 0 14px; width: auto; border-radius: 999px; }
#ambientes { flex: 1 1 auto; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
#ambientes::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; scroll-snap-align: start; border-radius: 999px; padding: 0 16px; min-height: 44px; display: flex; align-items: center;
  font-size: 14px; font-weight: 600; white-space: nowrap; background: var(--vidrio-fuerte); border: 1px solid var(--borde);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.chip.activo { background: var(--acento); color: #1d1f23; border-color: var(--acento); }
#aviso { margin: 8px 16px 0; font-size: 11.5px; line-height: 1.35; color: var(--tinta-suave); text-shadow: 0 1px 6px rgba(0,0,0,.6); }

/* Hoja del plano */
#hoja { position: fixed; inset: 0; z-index: 20; }
#hoja.oculto { pointer-events: none; }
.hoja-fondo { position: absolute; inset: 0; background: rgba(0,0,0,.45); transition: opacity .3s; }
#hoja.oculto .hoja-fondo { opacity: 0; }
.hoja-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: #1d1f23; border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(18px + var(--seguro-ab)); transition: transform .32s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.4); }
#hoja.oculto .hoja-panel { transform: translateY(105%); }
.hoja-tirador { width: 44px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 4px auto 10px; }
.hoja-titulo { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hoja-titulo b { font-size: 17px; }
.hoja-titulo span { font-size: 13px; color: var(--tinta-suave); flex: 1; }
.hoja-titulo .cerrar { width: 40px; height: 40px; }
#plano svg { width: 100%; height: auto; max-height: 70vh; display: block; margin: 0 auto; stroke: none; }
#plano .zona { fill: rgba(255,255,255,.05); stroke: rgba(255,255,255,.18); stroke-width: .04; cursor: pointer; transition: fill .2s; }
#plano .zona.ext { fill: rgba(140,170,120,.08); stroke-dasharray: .15 .12; }
#plano .zona:hover { fill: rgba(217,195,160,.18); }
#plano .zona.activa { fill: rgba(217,195,160,.30); stroke: var(--acento); }
#plano .muro { fill: #e9e5dc; }
#plano .nombre { fill: var(--tinta); font-size: .36px; font-weight: 600; text-anchor: middle; pointer-events: none; }
#plano .punto-plano { fill: #fff; stroke: rgba(0,0,0,.5); stroke-width: .04; pointer-events: none; }
#plano .punto-plano.activo { fill: var(--acento); }
#plano .calle { fill: rgba(255,255,255,.35); font-size: .42px; letter-spacing: .3px; text-anchor: middle; }

#cargando { position: fixed; right: 16px; top: calc(70px + var(--seguro-ar)); z-index: 6; transition: opacity .3s; }
#cargando.oculto { opacity: 0; }
.anillo { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: gira 0.9s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.sin-js { position: fixed; inset: auto 16px 50% 16px; text-align: center; }

/* Horizontal en celular */
@media (orientation: landscape) and (max-height: 520px) {
  #cabecera { padding-top: calc(8px + var(--seguro-ar)); }
  .marca .modelo { font-size: 16px; }
  #ambiente { top: 10px; }
  #ayuda { bottom: 118px; }
  #aviso { font-size: 10.5px; margin-top: 4px; }
  #barra { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
/* Escritorio */
@media (min-width: 900px) {
  #cabecera { padding: 22px 28px 0; }
  .marca .modelo { font-size: 24px; }
  .marca .residencial { font-size: 13.5px; }
  #ambiente { top: 28px; }
  #ambiente span { font-size: 17px; padding: 10px 20px; }
  #barra { padding: 0 28px; justify-content: center; }
  #ambientes { flex: 0 1 auto; }
  #aviso { margin: 10px 28px 0; text-align: center; }
  .hoja-panel { left: auto; right: 24px; bottom: 24px; width: 440px; border-radius: 20px; }
  #hoja.oculto .hoja-panel { transform: translateY(20px); opacity: 0; }
  .hoja-panel { transition: transform .3s, opacity .3s; }
}
@media (prefers-reduced-motion: reduce) { .punto .aro::before { animation: none; } }
