* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #6d28d9;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --secondary-color: #d4a017;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --text-primary: #1e1b4b;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f3ff;
    --bg-tertiary: #ede9fe;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(109,40,217,0.08), 0 1px 3px 1px rgba(109,40,217,0.06);
    --shadow-md: 0 1px 3px 0 rgba(109,40,217,0.12), 0 4px 8px 3px rgba(109,40,217,0.08);
    --shadow-lg: 0 2px 6px 2px rgba(109,40,217,0.15), 0 8px 16px 6px rgba(109,40,217,0.10);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* ===== VIEWS ===== */
.view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--nav-height);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.view-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-primary);
}

.view-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-header h2 i {
    font-size: 18px;
}

.header-stats {
    font-size: 12px;
    color: var(--text-light);
}

.view-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
}

/* ===== SEARCH ===== */
.view-search {
    position: relative;
    margin-bottom: 8px;
}

.view-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 14px;
}

.view-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.view-search input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(109,40,217,0.12);
}

/* ===== FILTER CHIPS ===== */
.distance-chips,
.feed-distance-filters {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
    scrollbar-width: none;
    flex-shrink: 0;
}

.distance-chips::-webkit-scrollbar,
.feed-distance-filters::-webkit-scrollbar {
    display: none;
}

.feed-distance-filters {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.filter-chip {
    white-space: nowrap;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.filter-chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.filter-chip:active {
    transform: scale(0.95);
}

/* ===== MEMBER CARD ===== */
.member-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.member-card:active {
    background: var(--bg-secondary);
}

.member-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-tertiary);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.member-name .badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

.badge-pro { background: #dbeafe; color: #1d4ed8; }
.badge-ent { background: #fef3c7; color: #92400e; }
.badge-cre { background: #fce7f3; color: #9d174d; }
.badge-stu { background: #d1fae5; color: #065f46; }
.badge-tra { background: #e0e7ff; color: #3730a3; }
.badge-men { background: #ede9fe; color: #5b21b6; }
.badge-fre { background: #f0fdfa; color: #115e59; }
.badge-com { background: #fff7ed; color: #9a3412; }

.member-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.member-meta i {
    font-size: 11px;
    color: var(--primary-light);
}

.member-bio {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-distance {
    text-align: right;
    flex-shrink: 0;
    min-width: 60px;
}

.member-distance .dist-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-color);
}

.member-distance .dist-unit {
    font-size: 10px;
    color: var(--text-light);
}

/* ===== MAP ===== */
#map {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

#viewMap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--nav-height);
}

.leaflet-container {
    background: #f0ecfe !important;
    font-family: 'Nunito', -apple-system, sans-serif;
}

.leaflet-tile-pane {
    filter: contrast(1.02) saturate(0.92) brightness(1.02);
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: 12px !important;
    overflow: hidden;
    margin-right: 12px !important;
    margin-top: 60px !important;
}

.leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 18px !important;
    border: none !important;
    background: white !important;
    color: var(--primary-color) !important;
}

.leaflet-control-zoom a:first-child {
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-control-attribution {
    background: rgba(255,255,255,0.9) !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 10px !important;
    color: #999 !important;
}

.leaflet-popup { display: none !important; }

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 999;
    text-align: center;
}

.map-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.map-loading-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.map-top-bar {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 800;
}

.location-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: white;
    color: var(--primary-color);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.location-btn:active {
    transform: scale(0.92);
}

/* Map member marker */
.map-member-marker {
    background: transparent !important;
    border: none !important;
}

.map-member-dot {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(109,40,217,0.3);
    transition: transform 0.2s;
}

.map-member-dot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-member-dot:hover {
    transform: scale(1.2);
}

/* Map popup */
.member-popup {
    text-align: center;
    min-width: 140px;
}

.member-popup img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    margin-bottom: 6px;
}

.member-popup .popup-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.member-popup .popup-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== FEED ===== */
.feed-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.feed-item:active {
    background: var(--bg-secondary);
}

.feed-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-tertiary);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.feed-body {
    flex: 1;
    min-width: 0;
}

.feed-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.4;
}

.feed-text strong {
    color: var(--primary-color);
    font-weight: 700;
}

.feed-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feed-action-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    position: absolute;
    bottom: -2px;
    right: -2px;
}

.feed-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.action-joined { background: var(--success-color); }
.action-profile_update { background: var(--primary-color); }
.action-connection { background: var(--secondary-color); }
.action-location_update { background: #3b82f6; }
.action-photo_update { background: #ec4899; }

/* ===== PROFILE VIEW ===== */
.profile-header {
    text-align: center;
    padding: 24px 16px 16px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.profile-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
}

.profile-avatar-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.profile-name {
    font-size: 22px;
    font-weight: 800;
}

.profile-username {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 2px;
}

.profile-location {
    font-size: 13px;
    opacity: 0.7;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.profile-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.profile-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.profile-bio {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.profile-tag {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.profile-stat-row {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 16px;
    background: var(--bg-secondary);
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-color);
}

.profile-stat-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
}

/* Profile edit form */
.profile-form {
    padding: 16px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(109,40,217,0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(109,40,217,0.3);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

/* ===== DETAIL PANEL ===== */
.detail-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 4000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.detail-panel.open {
    display: flex;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.detail-header-title {
    font-size: 17px;
    font-weight: 700;
    flex: 1;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.back-btn:active { transform: scale(0.92); }

.detail-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-primary);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: 2000;
    box-shadow: 0 -4px 24px rgba(109,40,217,0.08);
    border-radius: 24px 24px 0 0;
    padding-bottom: var(--safe-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    gap: 2px;
}

.nav-item i {
    font-size: 20px;
    transition: var(--transition);
}

.nav-item.active {
    color: var(--primary-color);
    transform: scale(1.08);
}

.nav-item:active {
    transform: scale(0.92);
}

/* Profile image in nav */
.nav-profile-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    transition: border-color 0.2s;
}

.nav-item.active .nav-profile-img {
    border-color: var(--primary-color);
}

/* ===== AUTH SCREENS ===== */
.auth-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    min-height: 100%;
}

.auth-logo {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    text-align: center;
}

.auth-form {
    width: 100%;
    max-width: 340px;
}

.auth-form .form-group {
    margin-bottom: 12px;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.auth-error {
    color: var(--danger-color);
    font-size: 13px;
    text-align: center;
    margin-bottom: 12px;
    display: none;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    color: var(--bg-tertiary);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 280px;
    line-height: 1.4;
}

/* ===== LOADING ===== */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.loading-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ===== SKELETON ===== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-xl);
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== GENDER BADGES ===== */
.gender-male { color: #3b82f6; }
.gender-female { color: #ec4899; }
.gender-other { color: var(--text-secondary); }

/* ===== MISC ===== */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.px-16 { padding-left: 16px; padding-right: 16px; }

/* Hidden file input */
.hidden-input {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 0 !important;
}
.leaflet-popup-content {
    margin: 12px !important;
}
.leaflet-popup-tip {
    box-shadow: none !important;
}

/* ===== FEED POST CARD ===== */
.feed-post-card {
    transition: background 0.15s;
}
.feed-post-card:hover {
    background: var(--bg-secondary);
}

/* ─────────────────────────────────────────────────────────────────
   IN-APP LEGAL MODAL — Terms of Service / Privacy Policy
   Slides up from bottom on mobile, centred dialog on desktop.
   ───────────────────────────────────────────────────────────────── */
.legal-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.legal-modal.open { display: flex; }

.legal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    animation: legalFadeIn .18s ease-out;
}

.legal-modal-card {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #111);
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.22);
    animation: legalSlideUp .22s cubic-bezier(.2,.8,.2,1);
    overflow: hidden;
}

@media (min-width: 768px) {
    .legal-modal { align-items: center; }
    .legal-modal-card {
        border-radius: 18px;
        max-height: 86vh;
        animation: legalScaleIn .18s ease-out;
    }
}

.legal-modal-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #eee);
    background: var(--bg-card, #fff);
    /* iOS safe area */
    padding-top: max(16px, env(safe-area-inset-top, 0));
}
.legal-modal-head h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}
.legal-modal-close {
    background: transparent;
    border: 0;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text-secondary, #888);
    cursor: pointer;
    padding: 0 4px;
    -webkit-tap-highlight-color: transparent;
}
.legal-modal-close:hover { color: var(--text-primary, #111); }

.legal-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 22px;
    line-height: 1.7;
    font-size: .92rem;
}
.legal-modal-body h3 {
    font-size: 1rem;
    font-weight: 800;
    margin: 18px 0 6px;
    color: var(--text-primary, #111);
}
.legal-modal-body h3:first-child { margin-top: 0; }
.legal-modal-body p {
    margin: 0 0 8px;
    color: var(--text-primary, #222);
}
.legal-modal-body a {
    color: var(--primary, #6d28d9);
    text-decoration: underline;
}

.legal-modal-foot {
    flex-shrink: 0;
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border-color, #eee);
    background: var(--bg-card, #fff);
}

@keyframes legalFadeIn { from { opacity:0 } to { opacity:1 } }
@keyframes legalSlideUp {
    from { transform: translateY(100%); opacity:.4 }
    to   { transform: translateY(0);    opacity:1  }
}
@keyframes legalScaleIn {
    from { transform: scale(.96); opacity:.4 }
    to   { transform: scale(1);   opacity:1  }
}

/* ── Password reveal toggle (login + signup + edit profile) ─────── */
.pw-wrap {
    position: relative;
}
.pw-wrap input {
    /* leave room on the right for the eye button so the icon doesn't sit on top of text */
    padding-right: 42px !important;
}
.pw-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #888);
    cursor: pointer;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
}
.pw-toggle:hover    { color: var(--text-primary, #111); background: rgba(0,0,0,.04); }
.pw-toggle:active   { background: rgba(0,0,0,.08); }
.pw-toggle:focus    { outline: 2px solid var(--primary, #6d28d9); outline-offset: 1px; }

/* =================================================================
   ACTION SHEET (bottom sheet on mobile, centered on desktop)
   Used for: post / reply overflow menus (Delete | Report | Block)
   ================================================================= */
.action-sheet {
    position: fixed; inset: 0; z-index: 10001;
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity .15s ease;
}
.action-sheet.open { opacity: 1; pointer-events: auto; }
.action-sheet-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.45);
}
.action-sheet-card {
    position: relative;
    width: 100%; max-width: 480px;
    background: var(--bg-card, #fff);
    border-radius: 18px 18px 0 0;
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0));
    box-shadow: 0 -6px 28px rgba(0,0,0,.22);
    transform: translateY(100%);
    transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.action-sheet.open .action-sheet-card { transform: translateY(0); }
@media (min-width: 768px) {
    .action-sheet { align-items: center; }
    .action-sheet-card {
        border-radius: 16px;
        margin: 0 16px;
        transform: scale(.96);
    }
    .action-sheet.open .action-sheet-card { transform: scale(1); }
}
.action-sheet-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: transparent; border: 0;
    font-size: 1rem; font-weight: 600;
    color: var(--text-primary, #111);
    text-align: left; cursor: pointer;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}
.action-sheet-btn:hover  { background: var(--bg-secondary, #f4f4f5); }
.action-sheet-btn:active { background: var(--bg-tertiary, #e5e7eb); }
.action-sheet-btn i      { font-size: 1.05rem; width: 22px; text-align: center; color: var(--text-secondary); }
.action-sheet-btn.danger { color: #dc2626; }
.action-sheet-btn.danger i { color: #dc2626; }
.action-sheet-btn.cancel {
    justify-content: center;
    margin-top: 6px;
    font-weight: 800;
    color: var(--text-secondary);
}

/* =================================================================
   REPORT MODAL — reason picker
   ================================================================= */
.report-modal {
    position: fixed; inset: 0; z-index: 10002;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity .15s ease;
}
.report-modal.open { opacity: 1; pointer-events: auto; }
.report-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }

.report-modal-card {
    position: relative;
    width: 100%; max-width: 480px; max-height: 90vh;
    background: var(--bg-card, #fff);
    color: var(--text-primary, #111);
    border-radius: 16px;
    display: flex; flex-direction: column;
    box-shadow: 0 8px 30px rgba(0,0,0,.22);
    margin: 16px;
    transform: scale(.96);
    transition: transform .18s ease-out;
    overflow: hidden;
}
.report-modal.open .report-modal-card { transform: scale(1); }
@media (max-width: 640px) {
    .report-modal { align-items: flex-end; }
    .report-modal-card {
        margin: 0;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
        transform: translateY(100%);
    }
    .report-modal.open .report-modal-card { transform: translateY(0); }
}
.report-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color, #eee);
}
.report-modal-head h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.report-modal-close {
    background: transparent; border: 0; font-size: 1.6rem;
    color: var(--text-secondary, #888);
    cursor: pointer; line-height: 1; padding: 0 4px;
}
.report-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 18px;
}
.report-reasons { display: flex; flex-direction: column; gap: 2px; }
.report-reason {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    cursor: pointer;
    font-size: .95rem;
}
.report-reason:hover { background: var(--bg-secondary, #f4f4f5); }
.report-reason input[type="radio"] {
    accent-color: var(--primary, #6d28d9);
    width: 18px; height: 18px;
    flex-shrink: 0;
}
.report-modal-foot {
    display: flex; gap: 10px;
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border-color, #eee);
}
.report-modal-foot .btn { flex: 1; padding: 12px; font-weight: 800; }

/* ── Privacy map tooltips (only username on hover) ────────────── */
.map-tip {
    background: rgba(0,0,0,0.78) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 8px !important;
    padding: 4px 9px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25) !important;
}
.map-tip::before { display: none !important; } /* hide Leaflet's tip arrow */

/* =================================================================
   PROFILE ACTION FOOTER  —  Contact / Accept / Decline / Message
   ================================================================= */
.profile-action-footer {
    margin: 22px 16px 12px;
    padding: 14px 14px 8px;
    border-top: 1px solid var(--border-color);
}
.profile-action-row {
    display: flex; gap: 8px; margin-top: 12px;
    justify-content: center;
}
.btn-link-danger {
    background: transparent;
    border: 0;
    color: #dc2626;
    font-weight: 700;
    font-size: .88rem;
    cursor: pointer;
    padding: 6px 12px;
    -webkit-tap-highlight-color: transparent;
}
.btn-link-danger:hover { text-decoration: underline; }

.ct-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    border-radius: 999px;
    background: var(--bg-secondary, #f4f4f5);
    color: var(--text-secondary, #555);
    font-weight: 700;
    font-size: .92rem;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}
.ct-pill-pending { background: rgba(109,40,217,.08); color: #6d28d9; }

/* =================================================================
   CONTACT REQUESTS list (incoming + outgoing)
   ================================================================= */
.req-section-title {
    padding: 10px 16px 6px;
    font-size: .82rem; font-weight: 800;
    text-transform: uppercase;
    color: var(--text-secondary, #888);
    letter-spacing: .5px;
}
.req-row {
    display: flex; gap: 12px;
    padding: 12px 16px;
    align-items: center;
    border-bottom: 1px solid var(--border-color, #eee);
}
.req-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.req-body { flex: 1; min-width: 0; }
.req-name { font-weight: 800; font-size: .95rem; color: var(--primary-color, #6d28d9); }
.req-msg  { font-size: .88rem; color: var(--text-primary); margin-top: 2px; word-break: break-word; }
.req-when { font-size: .76rem; color: var(--text-light); margin-top: 4px; }
.req-actions { display: flex; gap: 6px; flex-shrink: 0; }
.req-actions .btn { padding: 7px 12px; font-size: .82rem; font-weight: 700; }

/* =================================================================
   1-ON-1 CHAT PANEL
   ================================================================= */
.chat-panel {
    position: fixed; inset: 0; z-index: 10003;
    background: var(--bg-primary, #fff);
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.chat-panel.open { transform: translateX(0); }
.chat-head {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top, 0));
    border-bottom: 1px solid var(--border-color, #eee);
    background: var(--bg-primary, #fff);
}
.chat-back {
    background: transparent; border: 0;
    font-size: 1.25rem; color: var(--primary-color, #6d28d9);
    cursor: pointer; padding: 4px 8px;
    -webkit-tap-highlight-color: transparent;
}
.chat-title { font-weight: 800; font-size: 1rem; }
.chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 12px;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-secondary, #fafafa);
}
.chat-bubble-row {
    display: flex; flex-direction: column;
    max-width: 78%;
    margin: 4px 0;
}
.chat-bubble-row.mine   { align-self: flex-end;   margin-left: auto;  }
.chat-bubble-row.theirs { align-self: flex-start; margin-right: auto; }
.chat-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    font-size: .93rem; line-height: 1.4;
    word-wrap: break-word;
    color: var(--text-primary);
}
.chat-bubble-row.mine .chat-bubble {
    background: var(--primary-color, #6d28d9);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.chat-bubble-row.theirs .chat-bubble {
    border-bottom-left-radius: 6px;
}
.chat-when {
    font-size: .68rem;
    color: var(--text-light);
    margin-top: 2px;
}
.chat-bubble-row.mine .chat-when   { text-align: right; }
.chat-bubble-row.theirs .chat-when { text-align: left;  }

.chat-compose {
    flex-shrink: 0;
    display: flex; gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border-color, #eee);
    background: var(--bg-primary, #fff);
}
.chat-compose input {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 22px;
    font-size: .95rem;
    outline: none;
}
.chat-send-btn {
    width: 44px; height: 44px;
    border: 0; border-radius: 50%;
    background: var(--primary-color, #6d28d9);
    color: #fff;
    cursor: pointer; flex-shrink: 0;
}
.chat-send-btn:hover { filter: brightness(1.1); }

/* =================================================================
   PROFILE VIEW REDESIGN — settings cog, hero card, sections, meta-grid
   ================================================================= */
#viewProfile .view-content,
#profileContent {
    position: relative;
}

/* Top-right cog */
.profile-settings-btn {
    position: absolute;
    top: 14px; right: 14px;
    width: 38px; height: 38px;
    border: 0; border-radius: 50%;
    background: rgba(255,255,255,.9);
    color: var(--text-primary, #111);
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, transform .12s;
}
.profile-settings-btn:hover { background: #fff; transform: rotate(30deg); }
.profile-settings-btn:active { transform: rotate(60deg); }

/* Hero card with gradient cover behind the avatar */
.profile-card {
    position: relative;
    margin: 0 0 8px;
    padding: 0 16px 18px;
    text-align: center;
}
.profile-card-cover {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 96px;
    background: linear-gradient(135deg, #6d28d9 0%, #db2777 100%);
    z-index: 0;
}
.profile-card .profile-avatar-wrap {
    position: relative;
    z-index: 1;
    margin: 36px auto 8px;
    width: 120px; height: 120px;
}
.profile-card .profile-avatar {
    width: 120px; height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
    background: #fff;
}
.profile-card .profile-avatar-edit {
    position: absolute;
    bottom: 4px; right: 4px;
    width: 36px; height: 36px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--primary-color, #6d28d9);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .92rem;
}

.profile-headline {
    position: relative; z-index: 1;
    margin-top: 6px;
}
.profile-name {
    font-weight: 900;
    font-size: 1.25rem;
    color: var(--text-primary, #111);
    display: flex; align-items: center; justify-content: center; gap: 6px;
    flex-wrap: wrap;
}
.profile-verified {
    color: #16a34a;
    font-size: 1.05rem;
}
.profile-subline {
    margin-top: 6px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    flex-wrap: wrap;
    font-size: .85rem; color: var(--text-secondary);
}
.profile-loc i { margin-right: 4px; }

.profile-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin: 16px 0 14px;
    padding: 14px 0;
    background: var(--bg-secondary, #fafafa);
    border-radius: 14px;
}
.profile-stat { text-align: center; padding: 2px 8px; border-right: 1px solid var(--border-color, #eee); }
.profile-stat:last-child { border-right: 0; }
.profile-stat-value {
    font-size: 1.05rem; font-weight: 900;
    color: var(--text-primary, #111);
}
.profile-stat-label {
    font-size: .72rem; font-weight: 700;
    color: var(--text-secondary, #888);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-top: 2px;
}

.profile-cta-row {
    display: flex; gap: 8px;
    margin-top: 12px;
}
.profile-cta-row .btn { padding: 11px 12px; font-size: .92rem; }

.profile-section {
    background: var(--bg-card, #fff);
    border-radius: 14px;
    margin: 0 14px 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.profile-section-title {
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary, #888);
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}
.profile-section-title i { font-size: .95rem; color: var(--primary-color, #6d28d9); }
.profile-bio {
    font-size: .94rem;
    line-height: 1.55;
    color: var(--text-primary, #111);
    white-space: pre-wrap;
    word-break: break-word;
}
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-tag {
    display: inline-block;
    padding: 5px 11px;
    background: rgba(109,40,217,.08);
    color: var(--primary-color, #6d28d9);
    border-radius: 999px;
    font-size: .82rem; font-weight: 700;
}

.profile-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}
.profile-meta-cell {
    background: var(--bg-secondary, #fafafa);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex; flex-direction: column;
}
.profile-meta-label {
    font-size: .72rem; font-weight: 800;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: .4px;
}
.profile-meta-value {
    font-size: .95rem; font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
    text-transform: capitalize;
}

.profile-empty-cta {
    text-align: center;
    padding: 18px 16px;
}
.profile-empty-text {
    color: var(--text-secondary);
    font-size: .92rem;
    margin-bottom: 8px;
}
.btn-link {
    background: transparent;
    border: 0;
    color: var(--primary-color, #6d28d9);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
}

/* =================================================================
   ACCOUNT SETTINGS PAGE
   ================================================================= */
.settings-header {
    display: flex; align-items: center; gap: 10px;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0));
    border-bottom: 1px solid var(--border-color, #eee);
    background: var(--bg-card, #fff);
}
.settings-back {
    background: transparent; border: 0;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 1rem;
    color: var(--primary-color, #6d28d9);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.settings-back:hover { background: var(--bg-secondary); }
.settings-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.settings-list { padding: 6px 0 24px; }
.settings-section {
    margin: 14px 0 0;
    background: var(--bg-card, #fff);
}
.settings-section-title {
    padding: 12px 18px 4px;
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-secondary, #888);
    letter-spacing: .5px;
}
.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color, #f0f0f0);
}
.settings-row-label {
    font-size: .9rem; color: var(--text-secondary);
    font-weight: 600;
}
.settings-row-value {
    font-size: .92rem; color: var(--text-primary);
    font-weight: 700;
    text-align: right;
}

.settings-link-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 15px 18px;
    background: var(--bg-card, #fff);
    border: 0;
    border-bottom: 1px solid var(--border-color, #f0f0f0);
    color: var(--text-primary, #111);
    font-size: .96rem; font-weight: 600;
    text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.settings-link-btn:hover  { background: var(--bg-secondary, #f7f7f7); }
.settings-link-btn:active { background: var(--bg-tertiary, #eef); }
.settings-link-btn > i:first-child {
    width: 22px; text-align: center;
    color: var(--text-secondary, #888);
    font-size: 1rem;
}
.settings-link-btn > span { flex: 1; }
.settings-link-btn > i:last-child {
    color: var(--text-light, #bbb);
    font-size: .85rem;
}

.settings-link-btn.settings-logout > i:first-child { color: var(--primary-color, #6d28d9); }
.settings-link-btn.settings-logout                 { color: var(--primary-color, #6d28d9); }

.settings-link-btn.settings-danger  { color: #dc2626; }
.settings-link-btn.settings-danger > i:first-child { color: #dc2626; }

.settings-footer {
    text-align: center;
    padding: 24px 16px;
    font-size: .78rem;
    color: var(--text-light);
}
