/* ── Bengala · encuentra a tu parche sin señal ────────────────────────
   Estética de concierto: oscuro profundo + luces de neón (magenta→cian).
   Móvil primero, pensado para usarse con una mano en la oscuridad.
   ------------------------------------------------------------------- */

:root {
  --bg: #0B0B14;
  --bg2: #12121F;
  --surface: #191926;
  --surface2: #21212F;
  --line: #2C2C3D;
  --text: #F3F2F8;
  --muted: #9A98AE;

  --magenta: #FF2E93;
  --violet: #A44BFF;
  --cyan: #22D3EE;
  --grad: linear-gradient(135deg, #FF2E93, #A44BFF 55%, #22D3EE);
  --glow-mag: 0 0 24px rgba(255, 46, 147, .45);

  --radius: 18px;
  --font-d: 'Sora', system-ui, sans-serif;
  --font-b: 'Inter', system-ui, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font-b);
  background: radial-gradient(1200px 600px at 50% -10%, #1A1030, var(--bg) 60%);
  color: var(--text);
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
h1, h2, h3 { font-family: var(--font-d); font-weight: 700; line-height: 1.1; }
input { font-family: inherit; }

/* ── Botones ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-d); font-weight: 600; font-size: .96rem;
  padding: .8rem 1.5rem; border-radius: 50px; border: 1.5px solid transparent;
  cursor: pointer; color: var(--text); background: var(--surface2);
  transition: transform .12s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:active { transform: scale(.96); }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--glow-mag); border: none; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:active { background: var(--surface); }

/* ── Puerta de permisos ─────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(900px 500px at 50% 0%, #241040, var(--bg) 65%);
  display: grid; place-items: center; padding: 2rem 1.5rem;
  padding-top: calc(2rem + var(--safe-top));
}
.gate.hidden { display: none; }
.gate-card { max-width: 380px; text-align: center; }
.flare { font-size: 3.5rem; filter: drop-shadow(0 0 20px rgba(255,46,147,.6)); animation: pulse 2.4s ease-in-out infinite; }
.gate h1 { font-size: 2.6rem; font-weight: 800; margin-top: .4rem; letter-spacing: -.02em; }
.tagline { color: var(--cyan); font-weight: 600; margin-bottom: 1.4rem; }
.gate-text { color: var(--muted); font-size: .96rem; margin-bottom: 1.8rem; }
.gate-text b { color: var(--text); }
.gate-note { color: var(--muted); font-size: .82rem; margin-top: 1rem; min-height: 1.2em; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.7rem + var(--safe-top)) 1.1rem .7rem;
  background: linear-gradient(180deg, rgba(11,11,20,.92), rgba(11,11,20,0));
  backdrop-filter: blur(6px);
}
.brand { font-family: var(--font-d); font-weight: 800; font-size: 1.15rem; }
.flare-sm { filter: drop-shadow(0 0 8px rgba(255,46,147,.6)); }
.status { display: flex; gap: .4rem; }
.chip {
  font-size: .74rem; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: .28rem .6rem; border-radius: 50px; white-space: nowrap;
}
.chip.ok { color: var(--cyan); border-color: rgba(34,211,238,.4); }
.chip.bad { color: var(--magenta); border-color: rgba(255,46,147,.4); }

/* ── Estructura de pantallas ────────────────────────────────────── */
.app {
  position: absolute; inset: 0;
  padding: calc(3.6rem + var(--safe-top)) 1.1rem calc(5rem + var(--safe-bot));
  overflow-y: auto;
}
.screen { display: none; animation: fade .25s ease; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── RADAR ──────────────────────────────────────────────────────── */
.radar-wrap { display: grid; place-items: center; margin: .5rem 0 1.3rem; }
.radar {
  position: relative;
  width: min(78vw, 320px); aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(164,75,255,.10), transparent 70%);
}
.ring { position: absolute; inset: 0; border: 1px solid rgba(164,75,255,.22); border-radius: 50%; }
.ring:nth-child(2) { inset: 16.6%; }
.ring:nth-child(3) { inset: 33.3%; }
.sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(34,211,238,.28) 40deg, transparent 60deg);
  animation: sweep 3.4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.me-dot {
  position: absolute; top: 50%; left: 50%; width: 16px; height: 16px;
  transform: translate(-50%,-50%); border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.18), 0 0 16px #fff;
}
.f-dot {
  position: absolute; top: 50%; left: 50%; width: 14px; height: 14px;
  border-radius: 50%; transform: translate(-50%,-50%);
  box-shadow: 0 0 12px currentColor; cursor: pointer;
  transition: left .5s ease, top .5s ease; z-index: 2;
}
.f-dot.sel { width: 20px; height: 20px; outline: 2px solid #fff; outline-offset: 2px; }
.f-dot span {
  position: absolute; top: 120%; left: 50%; transform: translateX(-50%);
  font-size: .66rem; font-weight: 600; color: var(--text); white-space: nowrap;
  background: rgba(0,0,0,.5); padding: 1px 5px; border-radius: 50px;
}

/* ── Finder (flecha grande) ─────────────────────────────────────── */
.finder {
  display: flex; align-items: center; gap: 1.2rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.1rem;
}
.finder-arrow { color: var(--magenta); filter: drop-shadow(0 0 12px rgba(255,46,147,.5)); transition: transform .3s cubic-bezier(.2,.7,.3,1); }
.finder-info { flex: 1; min-width: 0; }
.finder-name { font-family: var(--font-d); font-weight: 700; font-size: 1.2rem; }
.finder-dist { font-family: var(--font-d); font-weight: 800; font-size: 2.2rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; }
.finder-hint { color: var(--muted); font-size: .85rem; }
.finder.near .finder-arrow { color: var(--cyan); animation: pulse 1s ease-in-out infinite; }

/* ── Chips de amigos ────────────────────────────────────────────── */
.friends { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fchip {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--surface); border: 1.5px solid var(--line);
  padding: .45rem .8rem; border-radius: 50px; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.fchip.sel { border-color: var(--magenta); box-shadow: var(--glow-mag); }
.fchip .fc-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.fchip .fc-x { color: var(--muted); font-size: 1rem; margin-left: .1rem; padding: 0 .1rem; }

/* ── Estado vacío ───────────────────────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 1rem 0 2rem; }
.empty p { margin-bottom: .4rem; }
.empty-sub { font-size: .9rem; margin-bottom: 1.2rem; }
.empty-sub b { color: var(--text); }

/* ── Compartir ──────────────────────────────────────────────────── */
.share, .scan { max-width: 440px; margin: 0 auto; text-align: center; }
.share h2, .scan h2 { font-size: 1.5rem; margin-bottom: .3rem; }
.muted { color: var(--muted); font-size: .92rem; margin-bottom: 1.3rem; }
.field { display: block; text-align: left; margin-bottom: 1rem; }
.field span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }
.field input {
  width: 100%; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 12px; padding: .8rem .9rem; outline: none;
}
.field input:focus { border-color: var(--violet); }
.colors { display: flex; gap: .6rem; justify-content: center; margin-bottom: 1.4rem; }
.swatch { width: 32px; height: 32px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.sel { border-color: #fff; transform: scale(1.12); }

.qr-box { background: #fff; border-radius: var(--radius); padding: 1rem; width: fit-content; margin: 0 auto; box-shadow: var(--glow-mag); }
.qr-box svg { display: block; width: 220px; height: 220px; }
.qr-meta { color: var(--muted); font-size: .82rem; margin-top: .9rem; }

/* ── Escanear ───────────────────────────────────────────────────── */
.scan-view {
  position: relative; width: 100%; aspect-ratio: 1; max-width: 340px; margin: 0 auto 1rem;
  border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line);
}
.scan-view video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(34,211,238,.8); border-radius: 16px; box-shadow: 0 0 24px rgba(34,211,238,.4); pointer-events: none; }
.scan-status { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; min-height: 1.3em; }

/* ── Navegación inferior ────────────────────────────────────────── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(18,18,31,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-bot);
}
.nav-btn {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--muted);
  font-family: var(--font-d); font-weight: 600; font-size: .74rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .7rem 0;
}
.nav-btn span { font-size: 1.3rem; }
.nav-btn.is-active { color: var(--text); }
.nav-btn.is-active span { filter: drop-shadow(0 0 10px rgba(255,46,147,.6)); }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + var(--safe-bot)); transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  padding: .7rem 1.2rem; border-radius: 50px; font-size: .9rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 40; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .8; } }

@media (prefers-reduced-motion: reduce) {
  .sweep, .flare, .finder.near .finder-arrow { animation: none; }
}
