:root {
    --bg-app: #f4f5f8;
    --surface: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --brand-red: #ff385c;
    --border-light: #e5e7eb;
    
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-pill: 50px;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    
    --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-ui); background: var(--bg-app); color: var(--text-main); padding-bottom: calc(80px + var(--safe-bottom)); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; object-fit: cover; }
a { text-decoration: none; color: inherit; }
button, input { font: inherit; background: none; border: none; outline: none; }

/* UTILS */
.section-title { font-size: 1.35rem; font-weight: 800; padding: 0 16px; margin-bottom: 12px; letter-spacing: -0.5px; }
.scroll-track { display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 16px 16px; scrollbar-width: none; }
.scroll-track::-webkit-scrollbar { display: none; }

/* HEADER */
.app-header { position: sticky; top: 0; background: var(--bg-app); z-index: 100; padding: 12px 16px; }
.header-container { display: flex; align-items: center; gap: 12px; max-width: 800px; margin: 0 auto; }
.brand { font-size: 1.8rem; font-weight: 900; letter-spacing: -1px; }
.brand-dot { color: var(--brand-red); }
.search-bar { flex: 1; background: var(--surface); border-radius: var(--radius-pill); padding: 10px 16px; display: flex; align-items: center; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.search-bar input { width: 100%; margin-left: 8px; font-weight: 500; font-size: 0.95rem; color: var(--text-muted); }

/* MAIN CONTENT */
.main-content { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* LOCATION WIDGET */
.widget-section { padding: 0 16px; }
.location-widget { background: var(--surface); border-radius: var(--radius-xl); padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); }
.loc-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; /* Alinea todo arriba por si el título salta a dos líneas */
    gap: 12px; /* Distancia de seguridad obligatoria entre título y badge */
    margin-bottom: 16px; 
}
.loc-title { 
    font-size: 1.4rem; 
    font-weight: 800; 
    display: flex; 
    flex-wrap: wrap; /* Permite que el botón 'Cambiar' caiga elegantemente si falta espacio */
    align-items: center; 
    gap: 4px 8px; /* Separación vertical y horizontal interna */
    letter-spacing: -0.5px; 
    flex: 1; /* Ocupa todo el espacio posible empujando el badge */
}

.pin-icon { color: var(--brand-red); font-size: 1.3rem; }
.btn-change { 
    font-size: 0.9rem; 
    font-weight: normal; 
    color: var(--text-muted); 
    text-decoration: underline; 
    white-space: nowrap; /* Protege la palabra para que nunca se corte por la mitad */
    margin-left: 0; /* Reseteamos el margen anterior, ahora usamos gap */
}

.live-badge { 
    background: #fee2e2; 
    color: #dc2626; 
    font-size: 0.75rem; 
    font-weight: 800; 
    padding: 4px 10px; 
    border-radius: var(--radius-pill); 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    letter-spacing: 0.5px; 
    flex-shrink: 0; /* CRÍTICO: El escudo antimisiles. Evita que el contenedor lo aplaste. */
    margin-top: 4px; /* Pequeño ajuste óptico para alinear con la primera línea de texto */
}
.pulse { width: 6px; height: 6px; background: #dc2626; border-radius: 50%; animation: pulse 1.5s infinite; }
.loc-stats { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.stat-pill { background: var(--surface); border: 1px solid var(--border-light); padding: 8px 12px; border-radius: var(--radius-pill); font-size: 0.85rem; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); } 70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }

/* STORIES */
.story-node { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 76px; }
.story-ring { width: 76px; height: 76px; border-radius: 50%; padding: 2px; background: #d1d5db; }
.story-ring img { width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--bg-app); object-fit: cover; }
.story-label { font-size: 0.8rem; font-weight: 600; color: var(--text-main); }

/* MAP BANNER */
.banner-section { padding: 0 16px; }
.map-banner { background: #2f3640; border-radius: var(--radius-xl); padding: 20px 24px; position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; color: white; box-shadow: var(--shadow-md); }
/* Simulación de patrón de mapa con CSS */
.map-banner::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 30%; background-image: radial-gradient(#4b5563 1px, transparent 1px), radial-gradient(#4b5563 1px, transparent 1px); background-size: 20px 20px; background-position: 0 0, 10px 10px; opacity: 0.2; transform: rotate(15deg) scale(1.5); }
.banner-title { font-size: 1.4rem; font-weight: 800; line-height: 1.2; z-index: 2; }
.banner-icon { font-size: 3rem; z-index: 2; opacity: 0.9; }

/* MASONRY CARDS */
.masonry-grid { column-count: 2; column-gap: 12px; padding: 0 16px; }
.card { break-inside: avoid; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow-sm); position: relative; }
.card-img-wrap { position: relative; }
.card-img { width: 100%; object-fit: cover; }
.dist-tag { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.95); padding: 4px 8px; border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 800; letter-spacing: -0.3px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.card-body { padding: 12px; }
.card-sup { font-size: 0.7rem; font-weight: 800; color: var(--brand-red); text-transform: uppercase; margin-bottom: 2px; }
.card-title { font-size: 1rem; font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.card-sub { font-size: 0.8rem; color: var(--text-main); }
.collage { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 90px 90px; gap: 2px; }
.collage img { width: 100%; height: 100%; object-fit: cover; }
.collage img:first-child { grid-row: 1 / 3; }

/* AGENDA LOCAL */
.agenda-card { min-width: 280px; background: #1e293b; border-radius: var(--radius-xl); padding: 20px; position: relative; height: 140px; overflow: hidden; box-shadow: var(--shadow-md); display: flex; flex-direction: column; justify-content: center; }
.agenda-time { font-size: 0.75rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px; }
.agenda-title { font-size: 1.25rem; font-weight: 800; color: white; line-height: 1.3; max-width: 70%; z-index: 2; }
.agenda-ill { position: absolute; right: -10px; bottom: -10px; font-size: 5rem; z-index: 1; }

/* COMUNIDAD PREGUNTA */
.q-card { min-width: 280px; max-width: 320px; background: var(--surface); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-light); }
.q-user-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-muted); }
.q-avatar { width: 24px; height: 24px; background: #111; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; }
.q-avatar.red { background: var(--brand-red); }
.q-text { font-size: 1rem; font-weight: 800; line-height: 1.4; margin-bottom: 16px; color: var(--text-main); }
.q-footer { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; }
.q-reply { color: #0ea5e9; }
.q-count { color: #ef4444; font-weight: normal;}

/* INTENTIONS */
.intents-section { padding: 0 16px 20px 16px; }
.intent-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
.intent-pill { background: var(--surface); border: 1px solid var(--border-light); padding: 10px 16px; border-radius: var(--radius-pill); font-size: 0.9rem; font-weight: 700; color: var(--text-main); box-shadow: 0 1px 2px rgba(0,0,0,0.02); }

/* BOTTOM BAR */
.bottom-bar { position: fixed; bottom: 0; width: 100%; background: rgba(255,255,255,0.98); border-top: 1px solid var(--border-light); display: flex; justify-content: space-around; padding: 12px 0 calc(12px + var(--safe-bottom)); z-index: 1000; }
.nav-item { font-size: 1.6rem; color: var(--text-muted); display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; }
.nav-item.active { color: var(--text-main); }
.post-btn span { background: var(--brand-red); color: white; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 16px; font-weight: 300; font-size: 2rem; box-shadow: 0 4px 12px rgba(255,56,92,0.3); }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-red); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; }