/* ==========================================
   Angel Finder Warm Home-like Design Tokens
   ========================================== */
:root {
    --bg-light: #faf7f2;
    --bg-card: #ffffff;
    --border-color: rgba(142, 128, 112, 0.16);
    --text-primary: #3c352d; /* Soft warm charcoal/espresso */
    --text-secondary: #7a6e60; /* Muted warm clay/earthy grey */
    --accent-amber: #d97706; /* Golden sunset amber */
    --accent-amber-glow: rgba(217, 119, 6, 0.08);
    --accent-sage: #5a6e5b; /* Peaceful sage green */
    --accent-sage-glow: rgba(90, 110, 91, 0.08);
    --accent-rose: #d69e96; /* Warm dusty rose */
    --accent-rose-glow: rgba(214, 158, 150, 0.12);
    --success: #6e8e75; /* Calming sage-success */
    --error: #c86b5d; /* Warm terracotta-red */
    --font-sans: 'Inter', sans-serif;
    --font-serif: 'Playfair Display', serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --radius: 20px; /* Softer, rounder corners */
    --radius-sm: 10px;
    --shadow: 0 10px 30px -5px rgba(122, 110, 96, 0.12), 0 2px 10px -2px rgba(122, 110, 96, 0.04);
    --shadow-hover: 0 20px 40px -10px rgba(122, 110, 96, 0.2), 0 4px 15px -2px rgba(122, 110, 96, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.warm-theme {
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(201, 139, 130, 0.14), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(79, 102, 80, 0.12), transparent 60%),
        var(--bg-light);
    background-attachment: fixed;
}

/* Ambient soft lighting overlay */
.ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% -20%, rgba(217, 119, 6, 0.08) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(122, 110, 96, 0.05);
}
::-webkit-scrollbar-thumb {
    background: rgba(122, 110, 96, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(122, 110, 96, 0.35);
}

/* Typography */
h1, h2, h3, h4 {
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #2b2520;
}

p {
    line-height: 1.6;
}

/* Buttons */
.btn {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-sage), #4b5d4c);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(90, 110, 91, 0.25);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(90, 110, 91, 0.4);
    background: linear-gradient(135deg, #4b5d4c, #3d4c3e);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(122, 110, 96, 0.05);
}
.btn-secondary:hover {
    background: #fdfcf9;
    border-color: rgba(142, 128, 112, 0.3);
    transform: translateY(-1px);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}
.btn-icon:hover {
    background: rgba(122, 110, 96, 0.08);
}

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success {
    background: var(--accent-sage-glow);
    color: var(--success);
    border: 1px solid rgba(110, 142, 117, 0.2);
}
.badge-warning {
    background: var(--accent-amber-glow);
    color: var(--accent-amber);
    border: 1px solid rgba(217, 119, 6, 0.2);
}

/* Form Controls */
.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-left: 2px;
}

.form-control {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: inset 0 1px 3px rgba(122, 110, 96, 0.03);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-sage);
    box-shadow: 0 0 0 4px rgba(90, 110, 91, 0.12), inset 0 1px 3px rgba(122, 110, 96, 0.03);
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 25px;
    background: rgba(250, 247, 242, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.header-logo h1 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 4px rgba(217, 119, 6, 0.2));
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* App Container and SPA Navigation */
.app-container {
    max-width: 620px;
    margin: 0 auto;
    padding: 24px 15px 120px 15px;
    position: relative;
    min-height: calc(100vh - 75px);
}

.app-screen {
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.app-screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen-header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.screen-header-nav h2 {
    font-size: 1.7rem;
}

/* ==========================================
   Screen: Onboarding Story (Scrapbook Look)
   ========================================== */
.onboarding-card {
    border-top: 5px solid var(--accent-rose);
    background-image: radial-gradient(circle at 100% 0%, rgba(214, 158, 150, 0.08) 0%, transparent 35%);
}

.story-header {
    margin-bottom: 18px;
}

.story-tag {
    font-size: 0.8rem;
    color: var(--accent-rose);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
}

.story-content {
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 28px;
    border-left: 3px solid var(--accent-rose);
    padding-left: 18px;
    font-size: 0.95rem;
}

.carousel-container {
    background: rgba(142, 128, 112, 0.04);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 28px;
    border: 1px solid rgba(142, 128, 112, 0.08);
}

.carousel-slides {
    min-height: 110px;
}

.carousel-slide {
    display: none;
    text-align: center;
    animation: slideIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.carousel-slide.active {
    display: block;
}

.carousel-slide h3 {
    margin-bottom: 12px;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--accent-sage);
}

.carousel-slide p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(122, 110, 96, 0.18);
    cursor: pointer;
    transition: var(--transition);
}

.dot.active {
    background: var(--accent-sage);
    width: 22px;
    border-radius: 5px;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(15px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==========================================
   Screen: Dashboard (Cozy, Grid-based)
   ========================================== */
.dashboard-welcome {
    margin-bottom: 24px;
}

.dashboard-welcome h2 {
    font-size: 2rem;
    margin-bottom: 4px;
}

.dashboard-welcome p {
    color: var(--text-secondary);
    font-size: 0.98rem;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(122, 110, 96, 0.04);
}

.stat-num {
    font-family: var(--font-serif);
    font-size: 1.7rem;
    color: var(--accent-sage);
    font-weight: 700;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 32px;
}

.menu-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.menu-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-sage);
    box-shadow: var(--shadow-hover);
}

.menu-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 6px rgba(122, 110, 96, 0.15));
}

.menu-card h3 {
    font-size: 1.1rem;
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--text-primary);
}

.menu-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Dashboard Dark Glassmorphic Grid Cards */
.glass-card {
    background: rgba(0, 0, 0, 0.45); /* Dark tint for accessibility and extreme contrast */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35);
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    cursor: pointer;
}

.glass-card:hover {
    transform: translateY(-5px);
    background: rgba(0, 0, 0, 0.52);
    border-color: rgba(255, 255, 255, 0.35);
}

.glass-card:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.6);
}

/* Icon Placeholder (Circle) */
.icon-circle {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    font-size: 32px;
    overflow: hidden;
}

.icon-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hub-profile-pic-container {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 12px auto;
    border: 3px solid var(--accent-sage);
    box-shadow: 0 4px 15px rgba(122,110,96,0.15);
}
.hub-profile-pic-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loved-one-hub-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.glass-card h2 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    font-family: var(--font-serif);
    letter-spacing: 0.5px;
}

.glass-card p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.82rem;
    margin: 0;
    line-height: 1.4;
}

.register-grave-banner-container {
    margin-top: 20px;
    margin-bottom: 24px;
}
.register-grave-banner-container .btn {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
}
.register-grave-banner-container .btn:hover {
    background: #ffffff;
    border-color: var(--accent-sage);
}

.section-header {
    margin-bottom: 18px;
    border-bottom: 1.5px solid rgba(142,128,112,0.12);
    padding-bottom: 8px;
}

.section-header h3 {
    font-size: 1.05rem;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.08em;
}

/* Graves List Layout */
.graves-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grave-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(122, 110, 96, 0.03);
}
.grave-item:hover {
    background: #fdfcf9;
    border-color: var(--accent-amber);
    transform: translateX(4px);
    box-shadow: 0 6px 20px rgba(122, 110, 96, 0.06);
}
.grave-item.selected {
    border-color: var(--accent-sage);
    background: var(--accent-sage-glow);
}

.grave-info h4 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 3px;
}

.grave-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.grave-arrow {
    color: var(--accent-amber);
    font-size: 1rem;
    transition: var(--transition);
}

.grave-item:hover .grave-arrow {
    transform: translateX(4px);
}

/* ==========================================
   Screen: Map Navigator & Pin Adjustment
   ========================================== */
.map-view-container {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}

#map {
    height: 380px;
    width: 100%;
}

/* Clean, standard bright Leaflet styling (no inversion for warm design!) */
.leaflet-container {
    background-color: var(--bg-light) !important;
}

.map-overlay-card {
    position: absolute;
    bottom: 18px;
    left: 18px;
    right: 18px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 18px;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(122, 110, 96, 0.15);
    animation: slideUp 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

.grave-info-brief {
    margin-bottom: 12px;
}

.grave-info-brief h4 {
    font-size: 1.25rem;
    color: #2b2520;
}
.grave-info-brief p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.map-overlay-actions {
    display: grid;
    grid-template-columns: 1.2fr 0.9fr 0.9fr;
    gap: 10px;
}

.grave-list-panel {
    background: #ffffff;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px;
    box-shadow: var(--shadow);
}

.grave-list-panel h3 {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-family: var(--font-sans);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Offline Mode Switch */
.offline-toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

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

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(122, 110, 96, 0.18);
    transition: .4s;
    border-radius: 34px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

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

input:checked + .slider-round:before {
    transform: translateX(22px);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(122, 110, 96, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0 12px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-rose), var(--success));
    width: 0%;
    transition: width 0.1s ease;
}

/* ==========================================
   Screen: AR Camera / Navigation
   ========================================== */
.ar-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 120px);
    min-height: 520px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #000;
}

#ar-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.ar-fallback-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #eae2d5 0%, #cfc5b3 100%);
    z-index: 1;
    overflow: hidden;
}



.ar-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 18px 15px;
    background: linear-gradient(180deg, rgba(43,37,32,0.85) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}
.ar-header .btn {
    color: white;
}
.ar-header .btn-secondary {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.2);
}

.ar-target-title {
    text-align: center;
    color: white;
}
.ar-target-title h3 {
    font-size: 1.15rem;
    color: white;
}
.ar-target-title p {
    font-size: 0.95rem;
    color: var(--accent-amber);
    font-weight: 600;
}

.ar-overlay-interface {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

/* Glowing Compass and AR Target Overlay */
.ar-compass-container {
    position: relative;
    width: 210px;
    height: 210px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ar-compass-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255,255,255,0.55);
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.1, 0.8, 0.3, 1);
}

/* Tick marks every 30° around the edge of the dial. */
.ar-compass-ring::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: repeating-conic-gradient(from -1deg, rgba(255,255,255,0.75) 0 2deg, transparent 2deg 30deg);
    -webkit-mask: radial-gradient(circle, transparent 0 calc(50% - 10px), #000 calc(50% - 9px));
    mask: radial-gradient(circle, transparent 0 calc(50% - 10px), #000 calc(50% - 9px));
}

/* Red north tick and N label: the dial turns so these always face true north. */
.ar-compass-ring::after {
    content: "";
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 12px solid #ef4444;
}
.ar-dial-n {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translate(-50%, -100%);
    font-weight: 800;
    font-size: 0.85rem;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

/* A compass needle that pivots on its centre and points at the grave. */
.ar-compass-arrow {
    position: absolute;
    inset: 16%;
    transform-origin: 50% 50%;
    transform: rotate(0deg);
    transition: transform 0.2s cubic-bezier(0.1, 0.8, 0.3, 1);
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.45));
}
.ar-compass-arrow svg { width: 100%; height: 100%; display: block; }
.ar-compass-arrow path {
    fill: var(--accent-amber);
    stroke: #fff;
    stroke-width: 4;
    stroke-linejoin: round;
    transition: fill 0.3s;
}

.ar-hud {
    position: absolute;
    bottom: 24px;
    left: 18px;
    right: 18px;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.hud-item {
    border-right: 1px solid rgba(122, 110, 96, 0.15);
}
.hud-item:last-child {
    border-right: none;
}

.hud-label {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
    font-weight: 600;
}
.hud-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.battery-warning-banner {
    position: absolute;
    top: 75px;
    left: 18px;
    right: 18px;
    background: rgba(200, 107, 93, 0.95);
    color: white;
    font-size: 0.78rem;
    padding: 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    z-index: 15;
    display: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.ar-tip {
    position: absolute;
    bottom: 100px;
    left: 18px;
    right: 18px;
    background: rgba(90, 110, 91, 0.9);
    border: 1px solid rgba(90, 110, 91, 0.3);
    color: white;
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 0.78rem;
    text-align: center;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* ==========================================
   Screen: Memorial Space (Scrapbook Aesthetics)
   ========================================== */
.memorial-hero {
    position: relative;
    height: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 24px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.memorial-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(43, 37, 32, 0.9) 100%);
    z-index: 1;
}

.memorial-profile-pic {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--accent-rose);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    margin-bottom: 10px;
    z-index: 2;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.memorial-profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.memorial-hero h1 {
    font-size: 1.85rem;
    z-index: 2;
    text-align: center;
    color: white;
}

.memorial-hero .dates {
    font-size: 0.9rem;
    color: var(--accent-rose);
    margin-bottom: 8px;
    z-index: 2;
    font-weight: 500;
}

.memorial-hero .badge {
    z-index: 2;
}

.memorial-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    border-bottom: 1.5px solid rgba(142,128,112,0.12);
    padding-bottom: 10px;
}

.mem-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: var(--transition);
    border-radius: 20px;
}
.mem-tab-btn.active {
    background: var(--accent-sage);
    color: white;
    box-shadow: 0 3px 8px rgba(90, 110, 91, 0.2);
}

.mem-tab-content {
    display: none;
}
.mem-tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* Timeline/Stories CSS */
.timeline {
    position: relative;
    padding-left: 24px;
    margin-top: 24px;
}
.timeline::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 2.5px;
    background: rgba(142, 128, 112, 0.2);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}
.timeline-item::before {
    content: "🕯️";
    position: absolute;
    left: -33px;
    top: 0;
    font-size: 0.95rem;
    background: var(--bg-light);
    padding: 1px;
}

.timeline-item h5 {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--accent-rose);
    margin-bottom: 5px;
    font-weight: 600;
}
.timeline-item p {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.timeline-card-add {
    border: 1.5px dashed rgba(142, 128, 112, 0.3);
    background: #ffffff;
}

/* Gallery CSS */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 18px;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1.5px solid var(--border-color);
    background: #f7f4ef;
    box-shadow: 0 2px 8px rgba(122, 110, 96, 0.05);
}
.gallery-item {
    padding: 0;
    cursor: pointer;
    display: block;
    width: 100%;
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}
.gallery-item:hover img {
    transform: scale(1.08);
}

.upload-zone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px dashed rgba(142, 128, 112, 0.3);
    background: #ffffff;
    border-radius: var(--radius-sm);
    padding: 30px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: var(--transition);
    text-align: center;
    box-shadow: 0 4px 10px rgba(122, 110, 96, 0.02);
}
.upload-zone:hover {
    border-color: var(--accent-sage);
    color: var(--accent-sage);
    background: var(--accent-sage-glow);
}

/* Audio Player CSS */
.audio-recorder-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1.5px solid rgba(142, 128, 112, 0.12);
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.88rem;
}

.record-timer {
    font-family: monospace;
    font-weight: bold;
    color: var(--error);
}

.audio-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
    margin-bottom: 24px;
}

.audio-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(122, 110, 96, 0.02);
}
.audio-item.active {
    border-color: var(--accent-sage);
    background: #fdfcf9;
}

/* Big round play/pause button, easy to hit with a thumb. */
.audio-play {
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--accent-sage);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(78, 103, 82, 0.25);
    transition: var(--transition);
}
.audio-play:active {
    transform: scale(0.94);
}
.audio-item.playing .audio-play {
    background: var(--accent-rose);
}

.audio-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.audio-item h4 {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.audio-duration {
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.audio-progress {
    display: none;
    height: 4px;
    margin-top: 4px;
    background: rgba(122, 110, 96, 0.12);
    border-radius: 2px;
    overflow: hidden;
}
.audio-item.active .audio-progress {
    display: block;
}
.audio-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-rose);
}

.audio-rename {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
}

.audio-rename-form {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.audio-rename-form .form-control {
    flex: 1 1 160px;
    min-width: 0;
}
.audio-item.renaming .audio-rename {
    display: none;
}

/* ==========================================
   Screen: Cleaning Service Marketplace
   ========================================== */
.cleaning-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

.clean-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
}
.clean-tab-btn.active {
    background: var(--accent-sage-glow);
    color: var(--accent-sage);
    border-color: rgba(90, 110, 91, 0.2);
}

.clean-tab-content {
    display: none;
}
.clean-tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

.cleaning-price-summary {
    font-size: 1.05rem;
    margin-top: 6px;
    margin-bottom: 18px;
    color: var(--text-secondary);
}
.cleaning-price-summary strong {
    color: var(--accent-amber);
    font-size: 1.3rem;
}

.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.job-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(122, 110, 96, 0.02);
}
.job-card.completed {
    border-left: 5px solid var(--success);
}
.job-card.active {
    border-left: 5px solid var(--accent-rose);
}
.job-card.pending {
    border-left: 5px solid var(--accent-amber);
}

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.job-header h4 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
}

.job-payout {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-amber);
}

.job-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.job-actions {
    display: flex;
    gap: 10px;
}

/* Before and After Image Comparison Slider */
.comparison-slider-container {
    position: relative;
    width: 100%;
    height: 190px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.slider-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.slider-image-before {
    z-index: 1;
}

.slider-image-after {
    z-index: 2;
    clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.slider-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2.5px;
    background: white;
    z-index: 3;
    left: 50%;
    cursor: ew-resize;
    box-shadow: 0 0 8px rgba(0,0,0,0.4);
}

.slider-divider::before {
    content: "↔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    background: white;
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.slider-labels {
    position: absolute;
    bottom: 10px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 4;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    text-shadow: 0 1.5px 4px rgba(0,0,0,0.7);
    pointer-events: none;
}

.cleaner-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    text-align: center;
    margin-top: 18px;
    border-top: 1px solid rgba(142, 128, 112, 0.12);
    padding-top: 15px;
}
.cleaner-stats div {
    display: flex;
    flex-direction: column;
}
.cleaner-stats strong {
    font-size: 1.5rem;
    color: var(--accent-sage);
}
.cleaner-stats span {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* ==========================================
   Modals
   ========================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(43, 37, 32, 0.6);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 15px;
    overflow-y: auto;
    animation: fadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

.modal-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(43, 37, 32, 0.2);
    overflow: hidden;
    animation: modalSlide 0.4s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.modal-large {
    max-width: 560px;
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.96) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1.5px solid rgba(142, 128, 112, 0.12);
    flex-shrink: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.6rem;
    cursor: pointer;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.modal-close:hover {
    background: rgba(122,110,96,0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 24px;
    border-top: 1.5px solid rgba(142, 128, 112, 0.12);
    background: #fdfcf9;
    flex-shrink: 0;
}

.coords-box {
    background: #fbfaf8;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text-primary);
}

/* QR code styling */
.qr-container-box {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    display: inline-block;
    margin: 18px auto;
    box-shadow: 0 4px 15px rgba(122,110,96,0.08);
    border: 1px solid var(--border-color);
}

#qrcode img {
    margin: 0 auto;
}

.qr-details {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.btn-group-full {
    width: 100%;
}

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

/* QR Code Scanner Simulation HUD */
.qr-scan-camera-sim {
    position: relative;
    width: 100%;
    height: 190px;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 18px;
}

.scanner-laser {
    position: absolute;
    left: 0;
    right: 0;
    height: 2.5px;
    background: var(--error);
    box-shadow: 0 0 10px var(--error);
    z-index: 10;
    animation: laserScan 2.2s linear infinite;
}

@keyframes laserScan {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

.scanner-crosshair {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 110px;
    height: 110px;
    border: 2px dashed rgba(255,255,255,0.45);
    z-index: 5;
    border-radius: 10px;
}

.presets-section {
    border-top: 1.5px solid rgba(142, 128, 112, 0.12);
    padding-top: 18px;
}

.presets-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}





















/* ==========================================
   Responsive adjustments
   ========================================== */
@media(max-width: 768px) {

}

/* ==========================================
   Accounts, sharing & data mode
   ========================================== */
.text-secondary {
    color: var(--text-secondary);
}

.device-mode-banner {
    background: var(--accent-amber-glow);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.85rem;
    padding: 8px 16px;
}

.auth-card {
    max-width: 440px;
    margin: 24px auto;
}

.auth-card h2 {
    font-family: var(--font-serif);
    margin-bottom: 8px;
}

.auth-card form {
    margin-top: 18px;
}

.auth-message {
    min-height: 1.2em;
    font-size: 0.9rem;
    margin: 4px 0 12px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent-sage);
    text-decoration: underline;
    margin-top: 10px;
    box-shadow: none;
}

.visitor-banner {
    margin: 16px 0;
    text-align: center;
}

.visitor-banner p {
    margin-bottom: 10px;
}

#share-link-input {
    font-size: 0.8rem;
    text-align: center;
}




.user-gps-pulse-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-pulse-dot {
    width: 14px;
    height: 14px;
    background: #2f7bd8;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(47, 123, 216, 0.8);
    animation: pulseGps 1.5s infinite;
}

@keyframes pulseGps {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(47, 123, 216, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(47, 123, 216, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(47, 123, 216, 0); }
}

.ar-compass-arrow.arrived path {
    fill: var(--success);
}

/* The GPS error is as big as the distance, so the direction is only a rough guide. */
.ar-compass-arrow.unsure {
    opacity: 0.45;
}

.ar-tip {
    font-size: 1rem;
    line-height: 1.4;
}

/* ==========================================
   Memories: posting state, photo viewer, toast
   ========================================== */
.timeline-item.pending { opacity: 0.6; }
.timeline-item.failed h5 { color: var(--error); }
.timeline-item.failed .btn { margin-top: 6px; }

.photo-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.photo-viewer.active { display: flex; }
.photo-viewer img {
    max-width: 92vw;
    max-height: 72vh;
    border-radius: 8px;
    object-fit: contain;
}
.photo-viewer-bar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
}
.photo-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: none;
    font-size: 2rem;
    width: 44px;
    height: 64px;
    border-radius: 8px;
    cursor: pointer;
}
.photo-viewer-nav.prev { left: 8px; }
.photo-viewer-nav.next { right: 8px; }
.photo-viewer-text {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    text-align: center;
}
.photo-viewer-text p { font-size: 1rem; margin-bottom: 4px; }
.photo-viewer-text span { font-size: 0.8rem; opacity: 0.7; }

.toast {
    position: fixed;
    left: 50%;
    top: 16px;
    transform: translate(-50%, -20px);
    background: var(--text-primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 1100;
    max-width: calc(100vw - 32px);
}
.toast.success { background: var(--accent-sage); }
.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ==========================================
   On-site search: camera marker & headstone reference
   ========================================== */
.ar-target-marker {
    position: absolute;
    z-index: 6;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-align: center;
    --ring: 80px;
}
.ar-marker-ring {
    width: var(--ring);
    height: calc(var(--ring) * 0.45);
    border: 3px dashed rgba(255, 214, 120, 0.9);
    border-radius: 50%;
    margin: 0 auto;
    box-shadow: 0 0 16px rgba(255, 214, 120, 0.5);
    animation: ar-pulse 1.6s ease-in-out infinite;
}
.ar-marker-pin {
    font-size: 2rem;
    margin-top: calc(var(--ring) * -0.45 - 30px);
    text-shadow: 0 0 8px #000;
}
.ar-marker-label {
    margin-top: calc(var(--ring) * 0.45);
    font-size: 0.75rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
@keyframes ar-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}
.ar-search-panel {
    position: absolute;
    z-index: 7;
    left: 12px;
    right: 12px;
    bottom: 76px;
    gap: 10px;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-radius: 12px;
    padding: 8px;
}
.ar-search-panel img {
    width: 96px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.ar-search-panel p { font-size: 0.8rem; opacity: 0.85; margin-top: 2px; }

/* Co-guardians */
.guardians-section {
    text-align: left;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
.guardians-section h4 { margin-bottom: 4px; }
.guardians-section .form-control { margin: 10px 0 8px; }
.guardian-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.google-logo { font-family: Arial, sans-serif; font-weight: bold; color: #5f6368; }

/* Guide without a camera: plain background behind the arrow and distance */
#ar-fallback {
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: linear-gradient(180deg, #2f3a31 0%, #1d241e 100%);
}
#ar-fallback p {
    color: #fff;
    opacity: 0.75;
    font-size: 0.85rem;
    text-align: center;
    margin: 0 24px 140px;
}

.btn-done { border-color: var(--success) !important; color: var(--success) !important; }
.btn-done::after { content: ' ✓'; }


/* ==========================================================================
   Design refresh: typography, surfaces, and phone & tablet layouts.
   Later rules here deliberately refine the ones above.
   ========================================================================== */
:root {
    --ink: #2b2520;
    --ink-2: #4e453c;
    --muted: #807365;
    --paper: #fbf8f3;
    --surface: #ffffff;
    --line: rgba(60, 53, 45, 0.10);
    --sage: #4f6650;
    --sage-600: #3e5240;
    --sage-50: #eef2ec;
    --gold: #b7791f;
    --rose: #c98b82;
    --bg-light: var(--paper);
    --text-primary: var(--ink-2);
    --text-secondary: var(--muted);
    --accent-sage: var(--sage);
    --border-color: var(--line);
    --radius: 22px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(43, 37, 32, 0.04), 0 8px 24px -8px rgba(43, 37, 32, 0.12);
    --shadow-hover: 0 2px 4px rgba(43, 37, 32, 0.05), 0 16px 36px -10px rgba(43, 37, 32, 0.2);
    --fs-xs: 0.78rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: clamp(1.08rem, 1rem + 0.4vw, 1.2rem);
    --fs-xl: clamp(1.3rem, 1.1rem + 0.9vw, 1.6rem);
    --fs-2xl: clamp(1.7rem, 1.3rem + 2vw, 2.4rem);
    --fs-display: clamp(2.1rem, 1.5rem + 3vw, 3.2rem);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { -webkit-text-size-adjust: 100%; }

body.warm-theme {
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--ink-2);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 {
    color: var(--ink);
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.015em;
    text-wrap: balance;
}
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-base); }
p { text-wrap: pretty; }
small, .text-secondary { color: var(--muted); }

/* Header */
.app-header {
    padding: calc(12px + var(--safe-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
    background: rgba(251, 248, 243, 0.85);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.header-logo { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.header-logo h1 { font-size: 1.25rem; letter-spacing: -0.01em; }
img.logo-icon { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 2px 6px rgba(43, 37, 32, 0.15); }
.device-mode-banner { font-size: var(--fs-xs); padding: 6px 16px; }

/* Page width: comfortable on phones, roomier on tablets */
.app-container {
    max-width: 640px;
    padding: 20px max(16px, env(safe-area-inset-left)) calc(96px + var(--safe-bottom));
}
@media (min-width: 768px) {
    .app-container { max-width: 920px; padding-left: 28px; padding-right: 28px; }
}
@media (min-width: 1100px) {
    .app-container { max-width: 1120px; }
}

/* Screen titles: back button, centred title, action */
.screen-header-nav {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}
.screen-header-nav h2 {
    text-align: center;
    font-size: var(--fs-xl);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.screen-header-nav .btn { white-space: nowrap; }
.btn-icon {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-2);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: var(--fs-sm);
}

/* Buttons: at least 44px tall for fingers */
.btn { min-height: 44px; font-size: var(--fs-sm); font-weight: 600; border-radius: 999px; letter-spacing: 0.005em; }
.btn-sm { min-height: 38px; padding: 8px 16px; }
.btn-primary { background: var(--sage); box-shadow: 0 6px 16px -6px rgba(62, 82, 64, 0.6); }
.btn-primary:hover { background: var(--sage-600); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn:focus-visible, .form-control:focus-visible, .mem-tab-btn:focus-visible { outline: 3px solid rgba(79, 102, 80, 0.35); outline-offset: 2px; }

/* Inputs: 16px text stops iPhones zooming in on focus */
.form-control, textarea.form-control, select.form-control {
    width: 100%;
    font-size: 16px;
    min-height: 46px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(60, 53, 45, 0.16);
    background: var(--surface);
}
textarea.form-control { min-height: 96px; resize: vertical; line-height: 1.5; }
.form-group label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); margin-bottom: 6px; display: block; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Dashboard & hub tiles: light cards with a tinted icon */
.dashboard-welcome h2 { font-size: var(--fs-display); }
.dashboard-welcome p { color: var(--muted); font-size: var(--fs-lg); }
.dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
@media (min-width: 768px) {
    .dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
}
.glass-card {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 14px;
    min-height: 168px;
}
.glass-card:hover { background: var(--surface); border-color: rgba(79, 102, 80, 0.3); box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.glass-card:active { background: var(--sage-50); transform: scale(0.98); }
.glass-card h2 { color: var(--ink); font-size: var(--fs-lg); letter-spacing: -0.01em; }
.glass-card p { color: var(--muted); font-size: var(--fs-xs); }
.icon-circle {
    width: 64px;
    height: 64px;
    background: var(--sage-50);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line), 0 6px 14px -6px rgba(43, 37, 32, 0.25);
    font-size: 28px;
    margin-bottom: 12px;
}
.loved-one-hub-card { background: var(--surface); border: 1px solid var(--line); }

/* Segmented tabs */
.memorial-nav, .cleaning-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(60, 53, 45, 0.06);
    border-radius: 999px;
    border: none;
    margin-bottom: 18px;
}
/* Equal shares of the width (flex-basis 0), and the label shrinks or wraps
   onto two lines on narrow screens such as a folding phone's cover screen. */
.mem-tab-btn, .clean-tab-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 40px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: clamp(0.78rem, 3.6vw, var(--fs-sm));
    line-height: 1.15;
    padding: 6px clamp(4px, 2vw, 10px);
    white-space: normal;
}
.mem-tab-btn.active, .clean-tab-btn.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(43, 37, 32, 0.12);
}

/* ---------- Memorial: carousel hero ---------- */
.memorial-hero {
    height: clamp(320px, 62vw, 480px);
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: radial-gradient(circle at 30% 20%, #6f8670, var(--sage-600) 70%);
    margin-bottom: 14px;
    isolation: isolate;
}
.memory-carousel { position: absolute; inset: 0; z-index: 0; }
.memory-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.2s ease;
}
.memory-slide.active { opacity: 1; }
.memory-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.04);
    transition: transform 7s ease-out;
    user-select: none;
}
.memory-slide.active img { transform: scale(1.12); }
.memorial-hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(20, 16, 12, 0.35) 0%, rgba(20, 16, 12, 0) 30%, rgba(20, 16, 12, 0.15) 55%, rgba(20, 16, 12, 0.78) 100%);
}
.memorial-hero-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    pointer-events: none;
}
.memorial-hero h1 {
    color: #fff;
    font-size: var(--fs-2xl);
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.memorial-hero .dates { color: rgba(255, 255, 255, 0.88); letter-spacing: 0.08em; font-size: var(--fs-sm); margin: 4px 0 10px; }
.memorial-profile-pic { width: 72px; height: 72px; border: 3px solid #fff; }
.memorial-hero .badge { background: rgba(255, 255, 255, 0.18); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); backdrop-filter: blur(6px); }
.memory-carousel-dots {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    justify-content: center;
    gap: 6px;
}
.mc-dot {
    width: 7px;
    height: 7px;
    padding: 0;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.55);
    transition: width 0.3s, background 0.3s;
    cursor: pointer;
}
.mc-dot.active { width: 22px; background: #fff; }
.memory-carousel-caption {
    position: absolute;
    top: 32px;
    left: 16px;
    right: 16px;
    z-index: 3;
    text-align: center;
    color: #fff;
    font-size: var(--fs-sm);
    font-style: italic;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}
.memorial-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

/* Tablet: carousel and actions on the left, tabs on the right */
@media (min-width: 900px) {
    .memorial-layout {
        display: grid;
        grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
        gap: 28px;
        align-items: start;
    }
    .memorial-side { position: sticky; top: 84px; }
    .memorial-hero { height: min(62vh, 560px); }
}

/* Timeline */
.timeline-card-add { padding: 18px; }
.timeline-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(43, 37, 32, 0.04);
}
.timeline-item h5 { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.timeline-item p { font-family: var(--font-serif); font-size: 1.05rem; color: var(--ink); margin-top: 4px; }

/* Gallery */
.gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 600px) { .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; } }
.gallery-item { border: none; border-radius: 10px; }

/* Map screen: map beside the list on tablets */
#map { height: min(58vh, 520px); }
@media (min-width: 900px) {
    #screen-saved-graves.active {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
        grid-template-rows: auto 1fr;
        column-gap: 24px;
    }
    #screen-saved-graves .screen-header-nav { grid-column: 1 / -1; }
    #screen-saved-graves #map { height: calc(100vh - 220px); min-height: 480px; }
    .map-overlay-card { left: auto; width: 380px; }
}
.map-overlay-card { border-radius: 18px; padding: 16px; }
.map-overlay-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.map-overlay-actions .btn:first-child { grid-column: 1 / -1; }
.map-overlay-actions .btn { width: 100%; }

/* Modals: bottom sheets on phones, centred cards on tablets */
@media (max-width: 599px) {
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal-card {
        max-width: none;
        border-radius: 24px 24px 0 0;
        max-height: 92vh;
        padding-bottom: var(--safe-bottom);
        animation: sheetUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card { max-width: 560px; }

/* AR guide fills the phone screen */
.ar-container { height: calc(100dvh - 90px - var(--safe-top)); border-radius: var(--radius); }

/* Onboarding */
.onboarding-card h2 { font-size: var(--fs-2xl); }
.story-content p { font-size: var(--fs-base); }

/* ---------- Full-screen memory slideshow ---------- */
.slideshow {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: #0d0b09;
    color: #fff;
    display: none;
    overflow: hidden;
    touch-action: pan-y;
}
.slideshow.active { display: block; }
.slideshow-stage, .ss-slide { position: absolute; inset: 0; }
.ss-slide {
    opacity: 0;
    transition: opacity 1.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ss-slide.active { opacity: 1; }
.ss-slide img { width: 100%; height: 100%; object-fit: contain; }
.ss-photo img { object-fit: cover; }
@media (orientation: portrait) { .ss-photo img { object-fit: contain; } }
.ss-slide.active img.kb-a { animation: kenburnsA 9s ease-out forwards; }
.ss-slide.active img.kb-b { animation: kenburnsB 9s ease-out forwards; }
.slideshow.paused .ss-slide.active img { animation-play-state: paused; }
@keyframes kenburnsA { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.12) translate(-2%, -1.5%); } }
@keyframes kenburnsB { from { transform: scale(1.12) translate(2%, 1%); } to { transform: scale(1) translate(0, 0); } }
.ss-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 80px 24px calc(96px + var(--safe-bottom));
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.75), transparent);
    font-family: var(--font-serif);
    font-size: var(--fs-xl);
    text-align: center;
}
.ss-caption small { display: block; font-family: var(--font-sans); font-size: var(--fs-xs); opacity: 0.75; margin-top: 6px; }
.ss-caption:empty { display: none; }
.ss-story { background: radial-gradient(circle at 50% 40%, #3d4a3e, #14110e 75%); padding: 32px; }
.ss-story blockquote {
    max-width: 720px;
    font-family: var(--font-serif);
    font-size: clamp(1.4rem, 1rem + 2.4vw, 2.4rem);
    line-height: 1.35;
    text-align: center;
}
.ss-story cite { display: block; margin-top: 20px; font-family: var(--font-sans); font-style: normal; font-size: var(--fs-sm); opacity: 0.75; }
.ss-title { background: #14110e; }
.ss-title-bg { position: absolute; inset: 0; object-fit: cover !important; opacity: 0.35; filter: blur(2px); }
.ss-title-text { position: relative; text-align: center; padding: 24px; }
.ss-title-text span { text-transform: uppercase; letter-spacing: 0.2em; font-size: var(--fs-xs); opacity: 0.8; }
.ss-title-text h2 { color: #fff; font-size: var(--fs-display); margin: 10px 0 6px; }
.ss-title-text p { opacity: 0.85; letter-spacing: 0.08em; }
.slideshow-progress {
    position: absolute;
    top: calc(10px + var(--safe-top));
    left: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 3;
}
.slideshow-progress span { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.slideshow-progress span i { display: block; height: 100%; width: 0; background: #fff; }
.slideshow-progress span.done i { width: 100%; }
.slideshow-progress span.current i { animation: ssProgress 6s linear forwards; }
.slideshow-progress span.current.paused i { animation-play-state: paused; }
@keyframes ssProgress { from { width: 0; } to { width: 100%; } }
.slideshow-top {
    position: absolute;
    top: calc(22px + var(--safe-top));
    left: 16px;
    right: 12px;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.slideshow-controls {
    position: absolute;
    bottom: calc(24px + var(--safe-bottom));
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    justify-content: center;
    gap: 18px;
}
.slideshow-btn {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
}
.slideshow-play { width: 60px; height: 60px; font-size: 1.1rem; background: rgba(255, 255, 255, 0.22); }
.slideshow-download {
    position: absolute;
    right: 16px;
    bottom: calc(30px + var(--safe-bottom));
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.slideshow-download .slideshow-btn { display: grid; place-items: center; }
.slideshow-download .icon { width: 22px; height: 22px; }
.slideshow-download .slideshow-btn.busy { animation: ssBusy 1.2s ease-in-out infinite; }
@keyframes ssBusy { 50% { opacity: 0.45; } }
.slideshow-download-status {
    position: absolute;
    bottom: 58px;
    right: 0;
    white-space: nowrap;
    font-size: var(--fs-xs);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

@media (prefers-reduced-motion: reduce) {
    .memory-slide img, .memory-slide.active img { transform: none; transition: none; }
    .ss-slide.active img.kb-a, .ss-slide.active img.kb-b { animation: none; }
    .memory-slide, .ss-slide { transition-duration: 0.3s; }
}

@media (max-width: 480px) {
    .clean-tab-btn { white-space: normal; line-height: 1.2; font-size: var(--fs-xs); }
    .screen-header-nav h2 { font-size: var(--fs-lg); }
}

/* Admin shortcut in the header (admins only) */
#admin-link { text-decoration: none; }

/* ==========================================================================
   Angel Finder 2026 refresh: logo, Angels dashboard, simpler hub,
   in-app directions, PIN and Face ID screens
   ========================================================================== */
:root {
    --gold-500: #c9973f;
    --gold-100: #f6ecd6;
    --sage-700: #34463a;
    --sage-100: #e3eadf;
    --error: #b4533f;
    --radius-lg: 26px;
}

.icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.2em;
}
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}
button { font: inherit; color: inherit; }

/* Logo and wordmark: "Angel" in serif, "Finder" in sage italic */
.header-logo { text-decoration: none; gap: 10px; }
.logo-mark { width: 38px; height: 38px; display: block; filter: drop-shadow(0 2px 4px rgba(52, 70, 58, 0.18)); }
.wordmark { font-family: var(--font-serif); font-size: 1.32rem; line-height: 1; letter-spacing: -0.01em; white-space: nowrap; }
.wm-angel { color: var(--ink); font-weight: 700; }
.wm-finder { color: var(--sage); font-weight: 500; font-style: italic; margin-left: 0.18em; }
.wordmark-lg { font-size: clamp(2.2rem, 1.6rem + 3vw, 3rem); }
.header-avatar {
    width: 40px; height: 40px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--sage);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.header-avatar .icon { width: 20px; height: 20px; }
body.is-locked .header-actions { visibility: hidden; }
body.is-locked .device-mode-banner { display: none !important; }

.btn .icon { width: 18px; height: 18px; }
.btn-lg { min-height: 52px; font-size: var(--fs-base); }
.btn-link { background: none; border: none; color: var(--sage); font-weight: 600; cursor: pointer; padding: 8px 4px; font-size: var(--fs-sm); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

/* Onboarding */
.onboarding-hero { text-align: center; padding: 8px 0 22px; }
.onboarding-logo { width: 104px; height: 104px; filter: drop-shadow(0 8px 18px rgba(52, 70, 58, 0.25)); animation: floatMark 6s ease-in-out infinite; }
.onboarding-tagline { color: var(--muted); font-size: var(--fs-lg); margin-top: 8px; }
@keyframes floatMark { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.carousel-slide h3 { display: flex; align-items: center; gap: 8px; color: var(--sage-600); }
.onboarding-card { border-top: none; }

/* Sign in, PIN and lock */
.auth-wrap { max-width: 420px; margin: 0 auto; text-align: center; }
.auth-logo { display: block; margin: 8px auto 14px; filter: drop-shadow(0 6px 14px rgba(52, 70, 58, 0.22)); }
.auth-card { text-align: left; padding: 26px 22px; }
.auth-card h2 { font-size: var(--fs-2xl); margin-bottom: 4px; }
.auth-card > .text-secondary { margin-bottom: 18px; }
.pin-input {
    text-align: center;
    font-size: 1.6rem !important;
    letter-spacing: 0.5em;
    padding-left: 0.5em;
    font-variant-numeric: tabular-nums;
}
.pin-input::placeholder { letter-spacing: 0.35em; color: rgba(60, 53, 45, 0.25); }
.lock-pin-form .pin-input::placeholder { letter-spacing: normal; font-size: 1rem; color: var(--muted); }
.auth-links { display: flex; justify-content: space-between; gap: 8px; margin: -6px 0 6px; flex-wrap: wrap; }
.auth-message { min-height: 1.2em; font-size: var(--fs-sm); margin: 6px 0 12px; }
#auth-biometric { margin-top: 10px; }
.lock-wrap { padding-top: 6vh; }
.lock-wrap h2 { font-size: var(--fs-2xl); }
.biometric-btn {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    margin: 26px auto 22px;
    padding: 22px 28px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(79, 102, 80, 0.25);
    background: var(--surface);
    color: var(--sage-600);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.biometric-btn .icon { width: 56px; height: 56px; stroke-width: 1.5; }
.biometric-btn:active { transform: scale(0.98); }
.lock-pin-form { display: grid; gap: 10px; }
#lock-message { color: var(--error); }

/* Dashboard: Your Angels */
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: var(--fs-xs); font-weight: 600; color: var(--gold) !important; margin-bottom: 4px; }
.dashboard-welcome { margin-bottom: 20px; }
.dashboard-welcome h2 { margin-bottom: 4px; }
.angel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}
@media (min-width: 768px) { .angel-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; } }
.glass-card.angel-card {
    font: inherit;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px 14px 18px;
    gap: 2px;
    min-height: 210px;
    justify-content: flex-start;
}
.angel-card .icon-circle {
    width: 88px; height: 88px;
    margin-bottom: 12px;
    background: var(--sage-50);
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(79, 102, 80, 0.25), 0 6px 14px -6px rgba(43, 37, 32, 0.35);
}
.angel-card .icon-circle img.placeholder-mark { width: 62%; height: 62%; object-fit: contain; }
.angel-card h2 { font-size: var(--fs-lg); margin: 0; }
.angel-card p { font-size: var(--fs-sm); margin-top: 2px; }
.angel-card-place {
    margin-top: 10px;
    font-size: var(--fs-xs);
    color: var(--sage-600);
    background: var(--sage-50);
    border-radius: 999px;
    padding: 4px 10px;
    max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.glass-card.angel-card-add {
    background: linear-gradient(160deg, rgba(79, 102, 80, 0.06), rgba(201, 151, 63, 0.08));
    border: 2px dashed rgba(79, 102, 80, 0.35);
    box-shadow: none;
    justify-content: center;
}
.angel-card-add .icon-circle { background: var(--sage); color: #fff; box-shadow: 0 8px 18px -8px rgba(52, 70, 58, 0.7); border-color: transparent; }
.angel-card-add .icon-circle .icon { width: 36px; height: 36px; }
.angel-card-add p { max-width: 18ch; }

/* Angel hub */
#screen-loved-one-hub .screen-header-nav { grid-template-columns: auto 1fr; }
.hub-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    background: linear-gradient(135deg, #fff, var(--gold-100));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.hub-hero .hub-profile-pic-container { width: 96px; height: 96px; margin: 0; flex: none; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--gold-500), 0 8px 18px -8px rgba(43, 37, 32, 0.4); }
.hub-hero-text { min-width: 0; }
.hub-hero-text h2 { font-size: var(--fs-2xl); margin-bottom: 2px; }
.hub-dates { color: var(--sage-600); font-weight: 600; letter-spacing: 0.04em; }
.hub-place { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.hub-place:empty { display: none; }

.hub-actions { display: grid; gap: 12px; }
@media (min-width: 600px) {
    .hub-actions { grid-template-columns: 1fr 1fr; gap: 16px; }
    .hub-tile-primary { grid-column: 1 / -1; }
}
.hub-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    text-align: left;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
}
.hub-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: rgba(79, 102, 80, 0.3); }
.hub-tile:active { transform: scale(0.99); }
.hub-tile-icon {
    width: 56px; height: 56px;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    background: var(--sage-50);
    color: var(--sage);
    flex: none;
}
.hub-tile-icon .icon { width: 28px; height: 28px; }
.hub-tile-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.hub-tile-title { font-family: var(--font-serif); font-size: var(--fs-xl); font-weight: 600; color: var(--ink); line-height: 1.15; }
.hub-tile-desc { font-size: var(--fs-sm); color: var(--muted); line-height: 1.4; }
.hub-tile-meta { font-size: var(--fs-xs); font-weight: 600; color: var(--gold); }
.hub-tile-meta:empty { display: none; }
.hub-tile-chevron { color: var(--muted); width: 22px; height: 22px; }
.hub-tile-primary {
    background: linear-gradient(135deg, #5d7a5f, var(--sage-700));
    border-color: transparent;
    padding: 24px 20px;
    box-shadow: 0 14px 30px -14px rgba(52, 70, 58, 0.8);
}
.hub-tile-primary .hub-tile-icon { background: rgba(255, 255, 255, 0.16); color: #fff; width: 64px; height: 64px; }
.hub-tile-primary .hub-tile-icon .icon { width: 32px; height: 32px; }
.hub-tile-primary .hub-tile-title { color: #fff; font-size: var(--fs-2xl); }
.hub-tile-primary .hub-tile-desc { color: rgba(255, 255, 255, 0.86); }
.hub-tile-primary .hub-tile-meta { color: #f3dca8; }
.hub-tile-primary .hub-tile-chevron { color: rgba(255, 255, 255, 0.8); }
.hub-tile-primary:hover { border-color: transparent; }

/* Location: in-app directions */
.grave-map-pin-icon { background: none; border: none; }
.grave-map-pin-icon img { width: 36px; height: 36px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35)); }
.guide-banner {
    position: absolute;
    top: 12px; left: 12px; right: 12px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 14px;
    border-radius: 18px;
    background: rgba(52, 70, 58, 0.96);
    color: #fff;
    box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.5);
}
.guide-banner-icon { width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, 0.14); display: flex; align-items: center; justify-content: center; flex: none; }
.guide-banner-icon .icon { width: 22px; height: 22px; }
.guide-banner-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.guide-banner-text strong { font-size: var(--fs-base); line-height: 1.3; }
.guide-banner-text span { font-size: var(--fs-xs); opacity: 0.85; }
.guide-stop { background: #fff; color: var(--sage-700); flex: none; }
.map-grave-distance { color: var(--gold) !important; font-weight: 600; margin-top: 2px; }
.map-guide-note { font-size: var(--fs-xs); color: var(--muted); margin-top: 10px; line-height: 1.4; }
.map-overlay-card.guiding .map-overlay-actions .btn:not(#map-ar-btn) { display: none; }
.map-overlay-card.guiding .map-guide-note { display: none; }
#map-route-info:empty { display: none; }
.grave-list-panel h3 { text-transform: uppercase; letter-spacing: 0.08em; }
.grave-arrow { width: 20px; height: 20px; color: var(--muted); }

/* Add Angel form */
.form-row { display: grid; gap: 0 12px; }
@media (min-width: 480px) { .form-row { grid-template-columns: 1fr 1fr; } }
.req { color: var(--error); }
.form-control.is-invalid { border-color: var(--error); box-shadow: 0 0 0 3px rgba(180, 83, 63, 0.12); }
.form-error { color: var(--error); font-size: var(--fs-sm); font-weight: 600; min-height: 1em; }
.form-error:empty { display: none; }
.upload-zone-sm { padding: 12px; margin-top: 2px; font-size: var(--fs-sm); border-style: solid; border-width: 1px; }
.add-photo-preview { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--sage); }
.add-headstone-preview { width: 100px; height: 75px; border-radius: 8px; object-fit: cover; border: 2px solid var(--sage); }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 10px; }
#modal-add-loved-one .coords-box { font-family: var(--font-sans); background: var(--sage-50); border-color: rgba(79, 102, 80, 0.2); }
#add-location-status { color: var(--muted); font-weight: 600; }

/* Account and Face ID */
.account-email { font-weight: 600; color: var(--ink); margin-bottom: 14px; word-break: break-all; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.setting-row p { font-size: var(--fs-xs); margin-top: 2px; }
.switch { flex: none; }
.modal-small { max-width: 380px; }
.offer-icon { width: 76px; height: 76px; margin: 6px auto 12px; border-radius: 22px; background: var(--sage-50); color: var(--sage); display: flex; align-items: center; justify-content: center; }
.offer-icon .icon { width: 44px; height: 44px; stroke-width: 1.5; }
#modal-biometric-offer h3 { margin-bottom: 6px; }
#modal-biometric-offer p { margin-bottom: 18px; }

.toast.info { background: var(--sage-700); }
.screen-header-nav .btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.screen-header-nav .btn-icon .icon { width: 16px; height: 16px; }

/* Location details sit under the map so the map stays clear */
.map-overlay-card {
    position: static;
    border: none;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    animation: none;
    background: var(--surface);
    padding: 16px;
}
@media (min-width: 900px) { .map-overlay-card { width: auto; } }
.map-overlay-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.map-overlay-actions .btn:first-child { grid-column: 1 / -1; min-height: 52px; font-size: var(--fs-base); }
.map-overlay-actions .btn-secondary {
    flex-direction: column;
    gap: 4px;
    border-radius: 16px;
    padding: 10px 6px;
    font-size: var(--fs-xs);
    line-height: 1.2;
    min-height: 64px;
}
.map-overlay-actions .btn-secondary .icon { width: 20px; height: 20px; color: var(--sage); }
.map-overlay-card.guiding .map-overlay-actions #map-ar-btn { grid-column: 1 / -1; flex-direction: row; min-height: 48px; font-size: var(--fs-sm); }
@media (max-width: 899px) { #screen-saved-graves #map { height: min(52vh, 480px); } }
@media (min-width: 900px) { #screen-saved-graves #map { height: calc(100vh - 420px); min-height: 380px; } }

/* AR guide: header, arrow and a bottom panel laid out top to bottom, so the
   direction hint, the headstone card and the readings never sit on each other */
.ar-container { display: flex; flex-direction: column; }
.ar-header { position: relative; flex: none; gap: 8px; padding: 12px; }
.ar-header .btn { white-space: nowrap; }
.ar-target-title { min-width: 0; flex: 1; text-align: center; }
.ar-target-title h3 { font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-power-btn { background: rgba(255, 255, 255, 0.16) !important; border: 1px solid rgba(255, 255, 255, 0.3) !important; color: #fff !important; font-size: var(--fs-xs) !important; padding: 6px 12px !important; }
.ar-overlay-interface { position: relative; inset: auto; flex: 1 1 auto; min-height: 150px; }
.ar-compass-container { width: min(210px, 32vh); height: min(210px, 32vh); }
.battery-warning-banner { top: 0; }
.ar-bottom {
    position: relative;
    z-index: 8;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 12px 12px;
}
.ar-bottom .ar-search-panel,
.ar-bottom .ar-tip,
.ar-bottom .ar-hud {
    position: static;
    left: auto; right: auto; bottom: auto;
    margin: 0;
}
.ar-bottom .ar-search-panel { background: rgba(0, 0, 0, 0.72); }
.ar-bottom .ar-tip { font-size: var(--fs-sm); padding: 10px 12px; }
.ar-bottom .ar-hud { padding: 10px; }
.ar-camera-note { color: rgba(255, 255, 255, 0.75); font-size: var(--fs-xs); text-align: center; margin: 0 8px; }
.ar-overlay-interface { min-height: 120px; }
.ar-compass-container { flex: none; width: min(210px, 28vh); height: min(210px, 28vh); }
@media (max-width: 420px) {
    .ar-header { flex-wrap: wrap; justify-content: space-between; }
    .ar-target-title { order: 3; flex-basis: 100%; }
    .ar-target-title h3 { white-space: normal; }
    .ar-bottom .ar-search-panel img { width: 72px; height: 56px; }
    .ar-bottom .ar-hud .hud-label { font-size: 0.62rem; }
}
/* Grow instead of clipping the bottom panel on short phones */
.ar-container { height: auto; min-height: calc(100dvh - 90px - var(--safe-top)); }

/* Profile and settings */
.header-avatar { position: relative; overflow: hidden; padding: 0; }
.header-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.header-avatar.has-photo .icon { visibility: hidden; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-head-text { min-width: 0; }
.profile-head-text h4 { font-family: var(--font-serif); font-size: 1.35rem; color: var(--ink); margin: 0 0 2px; overflow-wrap: anywhere; }
.profile-head-text .account-email { margin-bottom: 0; font-weight: 500; color: var(--muted); font-size: var(--fs-sm); }
.profile-head-text .btn-link { padding: 4px 0; }
.profile-avatar {
    position: relative; flex: none;
    width: 84px; height: 84px; border-radius: 999px;
    border: 2px solid var(--sage); background: var(--sage-50); color: var(--sage);
    padding: 0; cursor: pointer; overflow: visible;
}
.profile-avatar img { width: 100%; height: 100%; border-radius: 999px; object-fit: cover; display: block; }
.profile-initial { font-family: var(--font-serif); font-size: 2rem; font-weight: 700; line-height: 80px; }
.profile-avatar-edit {
    position: absolute; right: -2px; bottom: -2px;
    width: 30px; height: 30px; border-radius: 999px;
    background: var(--sage); color: #fff; border: 2px solid var(--surface);
    display: flex; align-items: center; justify-content: center;
}
.profile-avatar-edit .icon { width: 15px; height: 15px; }
.profile-avatar.is-busy { opacity: 0.55; pointer-events: none; }
.profile-avatar:focus-visible { outline: 3px solid var(--sage); outline-offset: 3px; }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.input-prefix .form-control { padding-left: 32px; }
.form-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
#profile-form .form-group { margin-bottom: 12px; }
.settings-heading { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 22px 0 6px; }
#modal-account .setting-row { margin-bottom: 0; border-bottom: none; }
.password-panel { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.password-panel summary {
    list-style: none; cursor: pointer; padding: 14px 0; font-weight: 600; color: var(--ink);
    display: flex; align-items: center; gap: 8px;
}
.password-panel summary::-webkit-details-marker { display: none; }
.password-panel summary::after { content: '›'; margin-left: auto; font-size: 1.3rem; color: var(--muted); transition: transform 0.2s; }
.password-panel[open] summary::after { transform: rotate(90deg); }
.password-panel summary .icon { width: 18px; height: 18px; color: var(--sage); }
.password-panel form { padding-bottom: 12px; }
.password-panel .form-group { margin-bottom: 10px; }
.password-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Landing buttons, PIN feedback, footer notice ---------- */
.onboarding-actions { display: flex; flex-direction: column; gap: 10px; }
.onboarding-actions .btn { margin: 0; }

.pin-feedback:empty { display: none; }
.pin-feedback { margin: 4px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.pin-feedback.good { color: var(--accent-sage); font-weight: 600; }
.pin-feedback.bad { color: var(--error); font-weight: 600; }
.form-control.is-valid { border-color: var(--accent-sage); box-shadow: 0 0 0 3px rgba(90, 110, 91, 0.14); }

.footer-notice {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 20px);
    width: min(520px, calc(100vw - 32px));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    border-radius: 16px;
    background: var(--sage-700, #34463a);
    color: #fff;
    font-size: var(--fs-sm);
    line-height: 1.35;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 1100;
}

/* The "Check your email" pop-up sits above the footer notice so its OK button can be tapped. */
#modal-check-email {
    z-index: 1200;
}
.footer-notice.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.footer-notice .icon { width: 22px; height: 22px; flex: none; }
.footer-notice span { flex: 1; }
.footer-notice-close {
    flex: none;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

/* Grave cleaning is hidden while config.js has cleaning: false */
.no-cleaning .feature-cleaning { display: none !important; }

/* Cloudflare's security check (captcha.js). Empty unless it needs a tap. */
.captcha-box {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 3000;
}

/* "Show older memories" under a memorial's timeline. */
.timeline-more {
    display: block;
    margin: 8px auto 0;
}

/* ==========================================
   Every screen size and shape: small and large Android phones, folding
   phones (narrow cover screen, square inner screen), tablets, phones on
   their side and split screen. Sizes follow the screen (%, vw, dvh) rather
   than fixed pixels; tests/e2e-screens.mjs checks each screen on each size.
   ========================================== */

/* Stay clear of camera cut-outs and curved edges on either side when the
   phone is on its side (the left and right insets differ then). */
.app-container {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}
@media (min-width: 768px) {
    .app-container {
        padding-left: max(28px, env(safe-area-inset-left));
        padding-right: max(28px, env(safe-area-inset-right));
    }
}

/* dvh is the height actually visible, without the address bar or the
   keyboard, so pop-ups and maps fit when those come and go. */
@supports (height: 100dvh) {
    body { min-height: 100dvh; }
    .modal-card { max-height: 85dvh; }
    #map { height: min(58dvh, 520px); }
}
@supports (height: 100dvh) {
    @media (max-width: 599px) { .modal-card { max-height: 92dvh; } }
    @media (max-width: 899px) { #screen-saved-graves #map { height: min(52dvh, 480px); } }
    @media (min-width: 900px) { #screen-saved-graves #map { height: calc(100dvh - 420px); } }
}

/* Short screens: a phone on its side, or the app in half of a split screen.
   The header and banner shrink and the big pictures fit the height. */
@media (max-height: 560px) {
    .app-header { padding-top: calc(6px + var(--safe-top)); padding-bottom: 6px; }
    .header-logo h1 { font-size: 1.1rem; }
    img.logo-icon, .app-header .logo-mark { width: 26px; height: 26px; }
    .device-mode-banner { padding: 3px 16px; }
    .app-container { padding-top: 12px; }
    .memorial-hero { height: clamp(200px, 70dvh, 360px); }
    .memorial-hero h1 { font-size: var(--fs-xl); }
    .memorial-hero .dates { margin: 2px 0 6px; }
    .memorial-profile-pic { width: 52px; height: 52px; }
    #map, #screen-saved-graves #map { height: max(200px, 62dvh); }
    .modal-card { max-height: 94dvh; }
}

/* Phones on their side: the memorial picture beside its tabs, like on a tablet. */
@media (max-height: 560px) and (min-width: 640px) and (orientation: landscape) {
    .memorial-layout {
        display: grid;
        grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
        gap: 20px;
        align-items: start;
    }
    .memorial-side { position: sticky; top: 8px; }
    .memorial-hero { height: clamp(220px, calc(100dvh - 110px), 360px); }
}
/* Very short (a small phone on its side): the slide caption makes way for the name. */
@media (max-height: 400px) {
    .memory-carousel-caption { display: none; }
}

/* Privacy policy and account deletion links, and the delete-account pop-up */
.legal-links { text-align: center; font-size: var(--fs-sm); margin: 14px 0 0; color: var(--text-secondary, inherit); }
.legal-links a { color: inherit; text-decoration: underline; }
.btn-danger-link { color: var(--error); }
.btn.btn-danger { background: var(--error); border-color: var(--error); color: #fff; }
.delete-list { margin: 8px 0 12px 1.2em; padding: 0; line-height: 1.45; }
.delete-list li { margin-bottom: 6px; }


/* "Create Account" / "Sign In" while waiting on the server (startAuthBusy in js/account.js). */
.btn.is-busy, .btn.is-busy:disabled { opacity: 1; cursor: progress; }
.btn-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 10px;
    vertical-align: -3px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin 0.8s linear infinite;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }
.auth-busy { display: none; margin-top: 14px; }
.auth-busy.active { display: block; animation: fadeIn 0.3s ease; }
.auth-busy-steps { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.auth-busy-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--fs-sm);
    color: var(--text-secondary, #8a7a6a);
    opacity: 0.5;
    transition: opacity 0.3s ease, color 0.3s ease;
}
.auth-busy-step.now, .auth-busy-step.done { opacity: 1; }
.auth-busy-step.now { color: var(--text-primary, #2b2b2b); font-weight: 600; }
.auth-busy-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid currentColor;
}
.auth-busy-step.now .auth-busy-dot { border-color: var(--sage); background: var(--sage); animation: busyPulse 1s ease-in-out infinite; }
.auth-busy-step.done .auth-busy-dot { border-color: var(--sage); background: var(--sage); }
@keyframes busyPulse { 50% { transform: scale(1.35); opacity: 0.6; } }
.auth-busy-bar { height: 4px; border-radius: 4px; background: rgba(62, 82, 64, 0.15); overflow: hidden; }
.auth-busy-bar span {
    display: block;
    width: 35%;
    height: 100%;
    border-radius: 4px;
    background: var(--sage);
    animation: busyBar 1.2s ease-in-out infinite;
}
@keyframes busyBar { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) {
    .btn-spinner, .auth-busy-bar span, .auth-busy-step.now .auth-busy-dot { animation-duration: 2.4s; }
}
