/* Copyright (c) 2026 Holger Rabbach. Licensed under the MIT License. */
:root {
    --bg-color: #0d1117;
    --card-bg: rgba(33, 38, 45, 0.7);
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent-color: #58a6ff;
    --success-color: #238636;
    --warning-color: #d29922;
    --danger-color: #da3633;
    --border-color: #30363d;
    --glass-blur: blur(10px);
    --owner-color: #f1e05a;
    /* Goldish yellow for owner */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
}

#app {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Reduced for smaller screens */
    padding-top: var(--spacing-48); /* Compensate for fixed #appNav height */
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

h1 {
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--accent-color), #bc8cf2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-view {
    display: none;
}

.dashboard-view.active {
    display: block;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #161b22;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--accent-color);
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

button:hover {
    opacity: 0.9;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

button:active {
    transform: scale(0.98);
}

/* Member Card Layout */
.member-card {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    border-radius: 12px;
    margin-bottom: 0.8rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    /* Ensure it doesn't exceed container */
    overflow: hidden;
    /* Contain children */
}



/* Custom Checkbox Styling */
.member-checkbox {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    border: 2px solid var(--text-secondary);
    border-radius: 4px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.member-checkbox:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.member-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 45%;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -50%) rotate(45deg);
}

.member-checkbox:hover {
    border-color: var(--accent-color);
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
    flex-shrink: 0;
    /* Prevent squishing */
}

.member-card.owner-card {
    border-color: #ffd700;
    /* Gold */
    background: rgba(255, 215, 0, 0.05);
}

.member-checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    /* STRICT FIXED WIDTH */
    min-width: 40px;
    margin-right: 1rem;
    flex-shrink: 0;
    /* Prevent squishing */
}

/* Custom Checkbox Styling */
.member-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 0.5rem;
    /* Little extra nudge */
    overflow: hidden;
    /* Prevent text blowout */
    min-width: 0;
    /* Important for ellipsis to work in flexbox */
}

.member-email {
    font-weight: 600;
    margin-bottom: 0.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.member-display-name {
    font-size: 1.1rem;
    color: var(--accent-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 0 1 auto;
    /* Allow growth/shrink but don't force it */
}

.member-email-addr {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    /* Take up remaining space, but can shrink */
    min-width: 0;
}

.edit-name-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    /* Never hide button */
}

.edit-name-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.member-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.member-location.has-address .member-coords {
    display: none;
}

.member-distance {
    color: var(--accent-color);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* =================================================================
   PHASE 74: Dashboard light-theme overrides for Aura Sentinel
   Scoped under body.auth-view to avoid side-effects on map overlay cards
   ================================================================= */

body.auth-view .member-card {
    background: var(--color-surface);                          /* #FFFFFF — replaces --card-bg */
    border-color: var(--color-surface-container-higher);       /* #E8E8E8 — replaces --border-color */
    box-shadow: var(--shadow-sm);
}

body.auth-view .member-card.owner-card {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.08);                      /* slightly stronger on light bg */
}

body.auth-view .member-card.is-clickable:hover {
    background: var(--color-surface-container);               /* #F5F5F5 — replaces rgba(255,255,255,0.05) */
}

body.auth-view .member-display-name {
    color: var(--color-text-primary);                         /* #212121 — replaces --accent-color */
    font-size: 1.1rem;
    font-weight: 700;
}

body.auth-view .member-distance {
    color: var(--color-primary);                              /* #2196F3 — retains blue accent */
}

body.auth-view .member-location,
body.auth-view .member-email-addr {
    color: var(--color-text-secondary);                       /* #616161 — replaces --text-secondary */
}

body.auth-view .member-checkbox {
    border-color: var(--color-surface-container-higher);      /* #E8E8E8 — replaces --text-secondary */
}

body.auth-view .member-checkbox:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

#dashboardView .edit-name-btn {
    display: none;                                            /* D-04: scoped to dashboard container; map overlay keeps its own edit buttons */
}

/* Map View Styles */
.map-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 500;
    background: var(--bg-color);
}

.map-view.active {
    display: flex;
    flex-direction: column;
}

.map-header {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 95%;
    max-width: 400px;
    /* Compact width */
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
}

.map-header>* {
    pointer-events: auto;
}

/* Unified Map Card */
.map-unified-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
}

.map-card-header {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.map-card-header:hover {
    background: rgba(255, 255, 255, 0.07);
}

.map-card-body {
    max-height: 40vh;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.map-card-body.collapsed {
    max-height: 0;
}

.map-member-row {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.map-member-row:last-child {
    border-bottom: none;
}

.map-member-row.is-owner {
    background: rgba(255, 215, 0, 0.05);
}

.map-card-footer {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.avatar-small {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    flex-shrink: 0;
}

.map-overlay-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 40vh;
    overflow-y: auto;
    width: 100%;
    scrollbar-width: none;
    /* Hide scrollbar for cleaner look */
}

.map-overlay-list::-webkit-scrollbar {
    display: none;
}

.map-user-card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

.map-user-card.owner {
    border-color: #ffd700;
}

.map-user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    width: 100%;
    margin-top: 0.5rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#mapContainer {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* MapLibre Marker Styles */
.custom-marker-container {
    display: flex;
    flex-direction: column-reverse;
    /* Labels above pins */
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

.custom-marker-container img {
    pointer-events: auto;
    width: 25px;
    height: 41px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.marker-label-container,
.marker-label {
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(4px);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 100;
}

/* Leaflet specific reset for tooltips */
.leaflet-container .leaflet-tooltip.marker-label {
    background-color: rgba(13, 17, 23, 0.9) ;
    border: 1px solid var(--border-color) ;
    color: var(--accent-color) ;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) ;
    text-shadow: none ;
}

.leaflet-tooltip-bottom.marker-label::before {
    border-bottom-color: var(--border-color) ;
}

.leaflet-tooltip-top.marker-label::before {
    border-top-color: var(--border-color) ;
}

h3 {
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.member-meta {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    /* Don't squash timestamp */
    min-width: 85px;
    /* Increased to accommodate status text */
}

.battery {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.battery-low {
    color: var(--danger-color);
}

.battery-mid {
    color: var(--warning-color);
}

.battery-high {
    color: var(--success-color);
}

/* Phase 91 hotfix: neutral color for missing/invalid battery readings. */
.battery-unknown {
    color: var(--text-secondary);
}

.battery small {
    font-size: 0.7rem;
    opacity: 0.8;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.refreshing {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Toggle Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(14px);
    background-color: white;
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}



.version-tag {
    position: fixed;
    bottom: 0.5rem;
    left: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.6;
    text-decoration: none;
    transition: opacity 0.2s;
    z-index: 9999;
}

.version-tag:hover {
    opacity: 1;
}

/* Responsive Adjustments */
@media (max-width: 600px) {

    /* Move map info to bottom on mobile */
    .map-header {
        top: auto;
        bottom: 2rem;
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .map-user-info {
        align-items: center;
    }

    #closeMapBtn {
        width: 100%;
    }

    body {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    .glass-panel {
        padding: 1rem;
    }

    .member-card {
        flex-direction: row;
        /* REMAIN ROW */
        align-items: center;
        gap: 0.5rem;
        padding: 0.6rem;
    }

    .member-meta {
        text-align: right;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        width: auto;
        min-width: 85px;
        /* Give it enough space but not too much */
        border-top: none;
        padding-top: 0;
        margin-top: 0;
    }

    .member-info {
        padding-left: 0.25rem;
    }

    .member-email {
        flex-wrap: nowrap;
        /* Prevent name and email from wrapping to new row if possible */
        gap: 0.25rem;
    }

    .member-display-name {
        font-size: 1rem;
    }

    .member-email-addr {
        display: inline;
    }

    .edit-name-btn {
        margin-top: 0;
    }

    .status-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    #logoutBtn {
        width: 100%;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .member-location.has-address .member-coords {
        display: none;
    }
}

/* Sharing Modal Styles */
.duration-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}





/* Ensure button specificity */


/* Force duration button active state */


/* Force duration button active state (renamed to is-selected) */
form#shareModalForm .duration-btn.is-selected,
#shareModalBackdrop button.duration-btn.is-selected {
    background-color: var(--success-color) ;
    color: white ;
    border-color: var(--success-color) ;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-color);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    transition: opacity 0.3s, transform 0.3s;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--accent-color);
}

.toast.hiding {
    opacity: 0;
    transform: translateY(10px);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fix for MapLibre/Leaflet Controls conflicting with global button styles */
.maplibregl-popup-close-button,
.leaflet-popup-close-button {
    padding: 0 ;
    color: inherit ;
    background: transparent ;
    border: none ;
    width: auto ;
    height: auto ;
}

/* Also fix zoom controls if they are buttons */
.maplibregl-ctrl-group button,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    padding: 0 ;
    background-color: transparent ;
    color: black ;
    /* Icons usually black/dark */
}

/* Reset hover effects */
.maplibregl-popup-close-button:hover,
.maplibregl-ctrl-group button:hover {
    transform: none ;
    opacity: 1 ;
    background-color: rgba(0, 0, 0, 0.05) ;
}

/* Skeleton Loader */
#membersListSkeleton {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.skeleton-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    opacity: 0.7;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: pulse-bg 1.5s infinite;
}

.skeleton-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.skeleton-text {
    height: 12px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    animation: pulse-bg 1.5s infinite;
}

.skeleton-text.title {
    width: 60%;
    height: 16px;
}

.skeleton-text.subtitle {
    width: 40%;
}

@keyframes pulse-bg {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

.member-card.is-clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.member-card.is-clickable:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Enhanced Transitions */
.btn,
.edit-name-btn,
button {
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.btn:active,
.edit-name-btn:active,
button:active {
    transform: scale(0.98);
}

.member-card {
    transition: transform 0.2s ease, background-color 0.2s ease;
}

/* Map Card Refinements */
.map-unified-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* User Location Dot */
.user-location-dot {
    width: 16px;
    height: 16px;
    background-color: #4a90e2;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    z-index: 50;
}
/* Utility Classes for Inline Style Removal */
.mt-sm { margin-top: 0.25rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-none { margin-bottom: 0px; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.p-sm { padding: 0.75rem; }
.pt-md { padding-top: 1rem; }
.p-2rem { padding: 2rem; }
.pl-sm { padding-left: 0.5rem; }
.ml-sm { margin-left: 0.5rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-2xl { font-size: 2rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-4 { height: 1rem; }
.border-top { border-top: 1px solid var(--border-color); }
.border-left-2 { border-left: 2px solid var(--border-color); }
.border-1 { border: 1px solid var(--border-color); }
.rounded-md { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-none { border-radius: 0; }
.overflow-hidden { overflow: hidden; }
.bg-transparent { background: transparent; }
.bg-glass { background: rgba(0,0,0,0.2); }
.bg-card { background: var(--card-bg); }
.bg-accent { background: var(--accent-color); }
.bg-danger { background: var(--danger-color); }
.bg-dark { background: #161b22; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent-color); }
.text-success { color: #2AAD27; }
.text-white { color: white; }
.cursor-pointer { cursor: pointer; }
.font-bold { font-weight: bold; }
.hidden { display: none; }
.opacity-0 { opacity: 0; }
.transition-opacity { transition: opacity 0.3s; }

/* Focus visible styles for better keyboard accessibility */
button:focus-visible,
select:focus-visible,
.member-checkbox:focus-visible,
.map-card-header:focus-visible,
input:focus-visible + .slider {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.member-display-name[role="button"]:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Screen-reader-only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--bg-color);
    color: var(--text-primary);
    border: 2px solid var(--accent-color);
    border-radius: 4px;
    z-index: 9999;
}

/* Reduce motion for users with vestibular disorders */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =================================================================
   PHASE 64: AURA SENTINEL DESIGN SYSTEM & AUTH VIEWS
   Extended CSS for login, register, profile, admin, and audit-log views
   ================================================================= */

/* CSS Variables: Aura Sentinel - Light (Phase 64 Design System) */
:root {
    /* Surface & Background Colors */
    --color-surface: #FFFFFF;
    --color-surface-container: #F5F5F5;
    --color-surface-container-high: #EEEEEE;
    --color-surface-container-higher: #E8E8E8;

    /* Primary & Accent Colors */
    --color-primary: #2196F3;
    --color-primary-container: #E3F2FD;
    --color-secondary: #757575;
    --color-secondary-container: #F5F5F5;

    /* Semantic Colors */
    --color-error: #D32F2F;
    --color-error-container: #FFEBEE;
    --color-success: #388E3C;
    --color-success-container: #E8F5E9;
    --color-warning: #F57C00;
    --color-warning-container: #FFF3E0;
    --color-tertiary: #9C27B0;

    /* Text Colors */
    --color-text-primary: #212121;
    --color-text-secondary: #616161;
    --color-text-tertiary: #9E9E9E;
    --color-text-inverse: #FFFFFF;

    /* Role & Status Badge Colors */
    --color-role-admin: #D32F2F;
    --color-role-parent: #F57C00;
    --color-role-member: #388E3C;
    --color-status-active: #388E3C;
    --color-status-locked: #D32F2F;
    --color-status-deleted: #9E9E9E;

    /* Spacing Scale (8px Base) */
    --spacing-4: 4px;
    --spacing-8: 8px;
    --spacing-12: 12px;
    --spacing-16: 16px;
    --spacing-24: 24px;
    --spacing-32: 32px;
    --spacing-40: 40px;
    --spacing-48: 48px;

    /* Border Radius */
    --radius-4: 4px;
    --radius-8: 8px;
    --radius-12: 12px;
    --radius-24: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* ===== Auth Panel (replaces .glass-panel on auth views) ===== */
/* Auth views use Aura Sentinel Light; map/dashboard keep .glass-panel dark theme. */
.auth-panel {
    background: var(--color-surface);           /* #FFFFFF */
    border: 1px solid var(--color-surface-container-higher); /* #E8E8E8 */
    border-radius: var(--radius-12);            /* 12px */
    padding: var(--spacing-24);                 /* 24px */
    box-shadow: var(--shadow-md);               /* 0 2px 8px rgba(0,0,0,0.1) */
}

/* Scope dark gradient h1 away from auth views */
.auth-panel h1,
.auth-panel h2 {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
    color: var(--color-text-primary);           /* #212121 */
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
}

/* Override dark input background inside auth views */
.auth-panel input,
.auth-panel select,
.auth-panel textarea {
    background: var(--color-surface);
    color: var(--color-text-primary);
    border-color: var(--color-surface-container-higher);
}

.auth-panel input:focus,
.auth-panel select:focus,
.auth-panel textarea:focus {
    border-color: var(--color-primary);
}

/* ===== Form Group Enhancements ===== */
.form-group {
    margin-bottom: var(--spacing-16);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-8);
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-8);
    border: 2px solid var(--color-surface-container-higher);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 200ms ease-out, box-shadow 200ms ease-out;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background: var(--color-surface-container-high);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
    border-color: var(--color-surface-container-higher);
}

.form-group input::placeholder,
.form-group select::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-tertiary);
}

/* Phase 75 PROF-01: Preferences section layout */
.auth-panel .preference-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-16);
    min-height: 44px; /* accessibility: touch target */
}

.preference-label {
    flex: 1;
}

.preference-hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: var(--spacing-4);
    line-height: 1.5;
}

/* Phase 75 PROF-01: Scope .switch to Aura Sentinel light tokens inside auth-panel */
/* Without these overrides, .switch uses dark tokens (var(--card-bg) = #21262d)
   which renders as a dark toggle on the white auth-panel — Pitfall 3 from RESEARCH.md */
.auth-panel .switch .slider {
    background-color: var(--color-surface-container-higher); /* #E8E8E8 off-state track */
    border-color: var(--color-surface-container-higher);
}

.auth-panel .switch .slider:before {
    background-color: var(--color-text-secondary); /* #616161 off-state thumb */
}

.auth-panel .switch input:checked + .slider {
    background-color: var(--color-primary);   /* #2196F3 on-state track */
    border-color: var(--color-primary);
}

.auth-panel .switch input:checked + .slider:before {
    background-color: var(--color-text-inverse); /* #FFFFFF on-state thumb */
}

/* Disabled state for unsupported devices */
.auth-panel .switch input:disabled + .slider {
    opacity: 0.4;
    cursor: not-allowed;
}

.error-text {
    font-size: 12px;
    color: var(--color-error);
    display: none;
    font-weight: 500;
}

.form-group.error .error-text {
    display: block;
}

/* ===== Button Styles ===== */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-8);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    font-family: inherit;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, #1976D2 100%);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    opacity: 0.92;
    box-shadow: var(--shadow-md);
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--color-secondary-container);
    color: var(--color-text-primary);
    border: 2px solid var(--color-surface-container-higher);
}

.btn-secondary:hover {
    background: var(--color-surface-container-high);
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-danger {
    background: var(--color-error);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    opacity: 0.92;
    box-shadow: var(--shadow-md);
}

.btn-danger:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.3);
}

.btn-danger:active {
    transform: scale(0.98);
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
    min-height: 36px;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spinner-rotate 0.6s linear infinite;
}

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

/* ===== Card Styles ===== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-surface-container-higher);
    border-radius: var(--radius-12);
    padding: var(--spacing-24);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-16);
}

.card-content {
    color: var(--color-text-primary);
    line-height: 1.5;
}

/* ===== Badge Styles ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-4);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-admin {
    background: rgba(211, 47, 47, 0.1);
    color: var(--color-role-admin);
}

.badge-parent {
    background: rgba(245, 124, 0, 0.1);
    color: var(--color-role-parent);
}

.badge-member {
    background: rgba(56, 142, 60, 0.1);
    color: var(--color-role-member);
}

.badge-active {
    background: rgba(56, 142, 60, 0.1);
    color: var(--color-status-active);
}

.badge-locked {
    background: rgba(211, 47, 47, 0.1);
    color: var(--color-status-locked);
}

.badge-deleted {
    background: rgba(158, 158, 158, 0.1);
    color: var(--color-status-deleted);
    text-decoration: line-through;
}

/* ===== Modal Enhancements ===== */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active,
.modal-backdrop.hidden.active {
    display: flex;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-12);
    padding: var(--spacing-24);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-slide-up 200ms ease-out;
}

.modal-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-16);
}

.modal-content p {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-16);
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Loading Overlay (initialization.js adds/removes body.loading) ===== */
/* Use ::before pseudo-element so body layout is unaffected. */
body.loading::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(13, 17, 23, 0.95);
    z-index: 9999;
}

body.loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 4px solid rgba(139, 148, 158, 0.3);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10000;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Auth View Classes ===== */
.login-view,
.register-view,
.profile-view,
.admin-view,
.audit-log-view,
.family-view {
    display: none;
}

.login-view.active,
.register-view.active,
.profile-view.active,
.admin-view.active,
.audit-log-view.active,
.family-view.active {
    display: block;
}

/* Light page background when any auth panel is active.
   Overrides the dark --bg-color set on body so the full viewport
   looks light, not just the white card. */
body.auth-view,
body:has(.auth-panel.active) {
    background-color: var(--color-surface-container);   /* #F5F5F5 */
    color: var(--color-text-primary);                   /* #212121 */
}

/* ===== Form Container ===== */
.form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-24);
    width: 100%;
}

/* ===== Admin Container ===== */
.admin-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-24);
    width: 100%;
}

/* ===== Profile Container ===== */
.profile-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-24);
    width: 100%;
}

/* ===== Help Text ===== */
.help-text {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* ===== Nav Bar (Phase 73) ===== */
#appNav {
    display: flex;
    align-items: center;
    height: var(--spacing-48);
    padding: 0 var(--spacing-24);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-surface-container-higher);
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
}

#appNav[hidden] {
    display: none;
}

/* When nav is hidden (login/register/map), remove the top padding that compensates for its fixed height */
#appNav[hidden] ~ #app {
    padding-top: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--spacing-16);
    font-size: 14px;
    font-weight: 600;
    font-family: Manrope, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease-out, border-color 150ms ease-out;
}

.nav-link:hover {
    color: var(--color-text-primary);
}

.nav-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
    border-radius: 4px;
}

.nav-link--active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
}

.nav-link--hidden {
    display: none;
}

.nav-logout {
    margin-left: auto;
}

.nav-logout:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

@media (max-width: 480px) {
    #appNav {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--spacing-48);
        padding: var(--spacing-8) var(--spacing-16);
    }
}

/* ===== Responsive Breakpoint (600px) ===== */
@media (max-width: 600px) {
    .form-container,
    .admin-container,
    .profile-container {
        padding: var(--spacing-16);
        max-width: 100%;
    }

    .btn {
        width: 100%;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-8);
    }

    .modal-content {
        width: 95%;
        padding: var(--spacing-16);
    }

    .card {
        padding: var(--spacing-16);
    }
}

/* ===== PHASE 78: FAMILY SETTINGS ===== */

/* Shared card wrapper — extends .auth-panel for the three stacked sections */
.family-card {
    background: var(--color-surface);
    border: 1px solid var(--color-surface-container-higher);
    border-radius: var(--radius-12);
    padding: var(--spacing-24);
    box-shadow: var(--shadow-md);
    margin-block: var(--spacing-24);
}

/* Card heading (h2 inside each family-card) */
.family-card__heading {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-12);
    line-height: 1.3;
}

/* Helper/subtext below a control */
.family-card__helper {
    font-size: 14px;
    font-weight: 400;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-top: var(--spacing-4);
}

/* Admin family-picker wrapper */
.family-picker {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-8);
}

/* aria-live status span inside picker (loading / error) */
.family-picker__status {
    font-size: 14px;
    color: var(--color-text-secondary);
    min-height: 20px;
}

/* Form wrapper for URL input + buttons */
.family-url-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-12);
}

/* Right-aligned button cluster (Test + Save URL) */
.family-url-form__actions {
    display: flex;
    gap: var(--spacing-8);
    align-items: center;
    flex-wrap: wrap;
}

/* Inline test result region (green check / red X) */
.family-url-form__result {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: var(--color-surface-container);
    border-radius: var(--radius-8);
    padding: var(--spacing-8) var(--spacing-12);
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

.family-url-form__result.result--pass {
    background: var(--color-success-container);
    color: var(--color-success);
}

.family-url-form__result.result--fail {
    background: var(--color-error-container);
    color: var(--color-error);
}

/* "Last test failed — save anyway?" warn banner */
.family-url-form__warn {
    background: var(--color-warning-container);
    color: var(--color-warning);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-8);
    padding: var(--spacing-8) var(--spacing-12);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-8);
    flex-wrap: wrap;
}

/* Member list wrapper (ul) */
.family-members {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-12);
}

/* Single member row (li) */
.family-member-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-16);
    padding: var(--spacing-12);
    background: var(--color-surface-container);
    border-radius: var(--radius-8);
    flex-wrap: wrap;
}

/* Email + timestamp stack */
.family-member-row__identity {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badge wrapper */
.family-member-row__badge {
    flex-shrink: 0;
}

/* Set/Rotate key action button area */
.family-member-row__actions {
    flex-shrink: 0;
}

/* Inline editor form (revealed on click) */
.family-member-row__editor {
    display: none;
    width: 100%;
    margin-top: var(--spacing-8);
    gap: var(--spacing-8);
    align-items: center;
    flex-wrap: wrap;
}

.family-member-row__editor.editor--open {
    display: flex;
}

/* Three-state member status badges */
.badge--key-none {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-4);
    padding: var(--spacing-4) var(--spacing-8);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    background: var(--color-surface-container);
    color: var(--color-text-tertiary);
}

.badge--key-set {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-4);
    padding: var(--spacing-4) var(--spacing-8);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    background: var(--color-success-container);
    color: var(--color-success);
}

.badge--key-mismatch {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-4);
    padding: var(--spacing-4) var(--spacing-8);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    background: var(--color-warning-container);
    color: var(--color-warning);
}

/* Responsive: member rows stack below 480px */
@media (max-width: 479px) {
    .family-member-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-8);
    }

    .family-member-row__identity {
        white-space: normal;
    }

    .family-member-row__actions {
        width: 100%;
    }

    .family-member-row__actions .btn {
        width: 100%;
    }

    .family-member-row__editor {
        flex-direction: column;
    }

    .family-member-row__editor input {
        width: 100%;
    }
}
