:root {
  --bg: #14161a;
  --panel: rgba(20, 22, 26, 0.82);
  --panel-solid: #1b1e23;
  --line: rgba(255, 255, 255, 0.10);
  --text: #f3f1ec;
  --muted: #a7a9ae;
  --accent: #e9e2d0;
  --disponible: #4fa37a;
  --separado: #d6a548;
  --vendido: #8b8f97;
  --radius: 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif; overflow: hidden;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
#map { position: fixed; inset: 0; width: 100vw; height: 100dvh; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: transparent; font-weight: 600; font-size: 15px; text-decoration: none;
  transition: transform .15s ease, background .15s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #16181c; border-color: transparent; }
.btn-ghost { background: rgba(255,255,255,.06); color: var(--text); }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 16px; }

/* Intro */
.intro { position: fixed; inset: 0; z-index: 30; display: grid; place-items: end center;
  padding: 24px calc(16px + var(--sar)) calc(28px + var(--sab)) calc(16px + var(--sal));
  background: linear-gradient(180deg, rgba(20,22,26,0) 30%, rgba(20,22,26,.92) 78%);
  transition: opacity .6s ease; }
.intro.fade { opacity: 0; pointer-events: none; }
.intro-card { width: 100%; max-width: 440px; text-align: left; }
.intro h1 { font-size: clamp(34px, 9vw, 48px); line-height: 1.02; margin: 6px 0 12px; letter-spacing: -0.02em; }
.intro-sub { color: var(--muted); font-size: 16px; line-height: 1.45; margin: 0 0 22px; }
.intro .btn { width: 100%; }
.intro-note { color: var(--muted); font-size: 12px; margin: 12px 0 0; text-align: center; }
.kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 600; color: var(--accent); margin: 0; }

/* Barra superior */
.top { position: fixed; z-index: 10; top: calc(10px + var(--sat)); left: calc(12px + var(--sal)); right: calc(12px + var(--sar));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.brand { align-self: flex-start; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 14px; padding: 9px 14px; display: flex; flex-direction: column; pointer-events: auto; }
.brand strong { font-size: 15px; }
.brand span { font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; pointer-events: auto; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 12.5px; color: var(--text); }
.chip .n { font-weight: 700; }
.chip[aria-pressed="false"] { opacity: .45; }
.chip[aria-pressed="false"] .dot { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.disponible { background: var(--disponible); color: var(--disponible); }
.dot.separado { background: var(--separado); color: var(--separado); }
.dot.vendido { background: var(--vendido); color: var(--vendido); }

/* Controles */
.tools { position: fixed; z-index: 10; right: calc(12px + var(--sar)); bottom: calc(18px + var(--sab));
  display: flex; flex-direction: column; gap: 8px; transition: transform .3s ease, opacity .3s ease; }
.tool { width: 58px; min-height: 58px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 500; }
.tool:active { transform: scale(.95); }
body.sheet-open .tools { opacity: 0; pointer-events: none; }

.hint { position: fixed; z-index: 9; left: 50%; transform: translateX(-50%); bottom: calc(44px + var(--sab));
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; white-space: nowrap; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }

.tooltip { position: fixed; z-index: 12; pointer-events: none; background: var(--panel-solid); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 12px; font-size: 13px; opacity: 0; transform: translate(-50%, calc(-100% - 14px));
  transition: opacity .12s ease; white-space: nowrap; }
.tooltip.on { opacity: 1; }
.tooltip b { display: block; font-size: 14px; }
.tooltip .st { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

/* Ficha (bottom sheet en móvil, panel en escritorio) */
.sheet { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; background: var(--panel-solid);
  border-top-left-radius: 22px; border-top-right-radius: 22px; border: 1px solid var(--line); border-bottom: 0;
  padding: 10px calc(18px + var(--sar)) calc(18px + var(--sab)) calc(18px + var(--sal));
  transform: translateY(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  max-height: 86dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; box-shadow: 0 -12px 40px rgba(0,0,0,.35); }
.sheet.open { transform: translateY(0); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.22); margin: 0 auto 10px; }
.close { position: absolute; top: 12px; right: calc(12px + var(--sar)); width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.07); display: grid; place-items: center; }
.ficha-head h2, .sheet h2 { margin: 8px 0 2px; font-size: 26px; letter-spacing: -0.01em; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; line-height: 1.45; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px;
  border-radius: 999px; background: rgba(79,163,122,.16); color: var(--disponible); }
.badge.separado { background: rgba(214,165,72,.16); color: var(--separado); }
.badge.vendido { background: rgba(139,143,151,.18); color: #c3c6cc; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 10px; }
.stats div { background: rgba(255,255,255,.05); border-radius: 14px; padding: 12px; }
.stats dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stats dd { margin: 4px 0 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.stats div { min-width: 0; }
.actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 14px; }
.actions .btn { width: 100%; padding: 0 10px; }

/* Formulario */
form label { display: block; font-size: 13px; color: var(--muted); margin-top: 14px; }
form input[name="nombre"], .phone { width: 100%; margin-top: 6px; min-height: 50px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); font: inherit; font-size: 16px; padding: 0 14px; }
.phone { display: flex; align-items: center; gap: 10px; padding: 0 0 0 14px; }
.phone span { color: var(--muted); font-size: 16px; }
.phone input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; height: 48px; outline: none; }
form input:focus, .phone:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 14px 0 0; }
legend { font-size: 13px; color: var(--muted); padding: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); font-size: 15px; font-weight: 500; }
.seg input:checked + span { background: var(--accent); color: #16181c; border-color: transparent; font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { color: #e48a7b; font-size: 13px; min-height: 18px; margin: 10px 0 0; }

.ok { text-align: center; padding: 8px 0 4px; }
.ok .btn { width: 100%; margin-top: 12px; }
.check { width: 60px; height: 60px; border-radius: 50%; background: rgba(79,163,122,.16); color: var(--disponible);
  display: grid; place-items: center; margin: 6px auto 4px; }
.check svg { width: 30px; height: 30px; stroke-width: 2.4; }
.demo-note { margin-top: 14px; }

/* Ayuda */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  width: 100%; max-width: 380px; }
.modal-card h2 { margin: 0 0 12px; font-size: 20px; }
.modal-card ul { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; font-size: 15px; }
.modal-card li { display: flex; align-items: center; gap: 10px; }
.modal-card .btn { width: 100%; margin-top: 16px; }

/* Marcadores de áreas comunes */
.amenity { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }

.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { margin-bottom: var(--sab); }

/* Escritorio */
@media (min-width: 900px) {
  .top { flex-direction: row; align-items: center; justify-content: space-between; }
  .sheet { left: auto; top: calc(16px + var(--sat)); right: 16px; bottom: auto; width: 380px; border-radius: 22px;
    border-bottom: 1px solid var(--line); transform: translateX(calc(100% + 30px)); max-height: calc(100dvh - 32px); padding: 22px; }
  .sheet.open { transform: translateX(0); }
  .grab { display: none; }
  .top { right: 410px; }
  body:not(.sheet-open) .top { right: 16px; }
  body.sheet-open .tools { opacity: 1; pointer-events: auto; right: 412px; }
  .intro { place-items: center start; padding-left: 7vw;
    background: linear-gradient(90deg, rgba(20,22,26,.9) 0%, rgba(20,22,26,.55) 40%, rgba(20,22,26,0) 70%); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

body.far .amenity { display: none; }
.intro ~ .maplibregl-ctrl-bottom-left { display: none; }
body:has(.intro:not(.hidden)) .maplibregl-ctrl-bottom-left { visibility: hidden; }
@media (max-width: 899px) { .hint { left: calc(12px + var(--sal)); transform: none; right: 84px; text-align: center; white-space: normal; } }
