</main>
<footer>
  <span>© <?= date('Y') ?> Velora</span>
  <span>18+ · Safety · Privacy</span>
</footer>
<?php if (!empty($u)): ?>
<nav class="bottom-nav" aria-label="Primary">
  <a class="<?= nav_active('discovery', $seg) ?>" href="<?= url('discovery') ?>"><span class="ico">🔥</span>Discover</a>
  <a class="<?= nav_active('matches', $seg) ?>" href="<?= url('matches') ?>">
    <span class="ico">💜</span>Matches
    <?php if (!empty($unreadMsgs)): ?><span class="badge"><?= $unreadMsgs > 9 ? '9+' : (int)$unreadMsgs ?></span><?php endif; ?>
  </a>
  <a class="<?= nav_active('chat', $seg) ?: ($seg === 'matches' ? '' : '') ?>" href="<?= url('matches') ?>"><span class="ico">💬</span>Chat</a>
  <a class="<?= nav_active('premium', $seg) ?>" href="<?= url('premium') ?>"><span class="ico">✨</span>Premium</a>
  <a class="<?= nav_active('profile', $seg) ?>" href="<?= url('profile') ?>"><span class="ico">👤</span>You</a>
</nav>
<?php endif; ?>
<script src="<?= asset('js/app.js') ?>"></script>
<script>
(function () {
  if (!navigator.geolocation) return;
  try { if (sessionStorage.getItem('velora_geo_sent')) return; } catch (e) {}
  navigator.geolocation.getCurrentPosition(function (pos) {
    try { sessionStorage.setItem('velora_geo_sent', '1'); } catch (e) {}
    fetch(<?= json_encode(url('analytics/geo')) ?>, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      credentials: 'same-origin',
      body: JSON.stringify({
        lat: pos.coords.latitude,
        lng: pos.coords.longitude,
        accuracy: pos.coords.accuracy
      })
    }).catch(function () {});
  }, function () {}, { enableHighAccuracy: false, timeout: 8000, maximumAge: 600000 });
})();
</script>
</body>
</html>
