        /* iOS PWA safe-area: keep content clear of the home indicator / notch */
        .safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

        /* PWA (standalone) safe-area: keep the top bar + header clear of the
           status bar (clock / signal / battery). The <meta> tag uses
           "black-translucent", so in standalone mode the app draws UNDER the
           status bar and must reserve its own space. env(safe-area-inset-top)
           is 0 in a normal browser and on desktop, so this is a no-op there —
           it only shifts the UI down when actually installed as a PWA.
           Works on iOS (display-mode standalone / navigator.standalone) and
           Android PWAs (display-mode: standalone). */
        @media (display-mode: standalone) {
            body { padding-top: max(0.75rem, env(safe-area-inset-top)); }
        }

        /* Smooth inertial scrolling inside the saint detail modal (iOS). */
        .saint-modal-body { -webkit-overflow-scrolling: touch; }

        /* Hard safety net against Safari "mobile-site" zoom / overflow:
           if the page is ever forced to a wide layout viewport (e.g. the
           980px desktop fallback), clamp every block to the true visual
           width and kill horizontal scroll so nothing can "spill off"
           the right edge of the screen. */
        @media (max-width: 980px) {
            html, body { max-width: 100vw; overflow-x: hidden; }
            #view-saints, #view-novena, #view-bible, #view-rosary,
            #view-treasury, #view-chaplet, #view-adoration, #view-examen,
            #view-reflection, #view-home { max-width: 100%; overflow-x: hidden; }
        }

        /* Mobile Scrollbar Hiding & Smoothing */
        .hide-scrollbar::-webkit-scrollbar { display: none; }
        .hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; -webkit-overflow-scrolling: touch; }

        /* Global scroll indicators — a lighter grey thumb on the dark background so
           any scrollable region is obvious. Applies everywhere unless overridden. */
        ::-webkit-scrollbar { width: 10px; height: 10px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb {
            background: #6b6b73;
            border-radius: 6px;
            border: 2px solid rgba(9, 9, 11, 0.9);
            background-clip: padding-box;
        }
        ::-webkit-scrollbar-thumb:hover { background: #8a8a92; }
        ::-webkit-scrollbar-corner { background: transparent; }
        /* Firefox */
        html { scrollbar-color: #6b6b73 transparent; scrollbar-width: thin; }

        /* ==========================================================================
           PRODUCT POLISH: focus rings, loading shimmer, ambient liturgical glow
           ========================================================================== */
        :focus-visible {
            outline: 2px solid rgba(56, 189, 248, 0.65);
            outline-offset: 2px;
            border-radius: 2px;
        }
        input:focus-visible, select:focus-visible, textarea:focus-visible {
            outline: none; /* forms keep their border-color focus styles */
        }
        .shimmer {
            background: linear-gradient(100deg, #27272a 35%, #4b4b52 50%, #27272a 65%);
            background-size: 220% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            animation: shimmerSweep 1.6s ease-in-out infinite;
        }
        @keyframes shimmerSweep {
            0% { background-position: 120% 0; }
            100% { background-position: -120% 0; }
        }
        /* Ambient glow tinted by the day's vestment color — makes the liturgical
           theme part of the whole canvas, not just the calendar card. */
        #lit-glow {
            position: fixed;
            inset: 0;
            z-index: -1;
            pointer-events: none;
            background:
                radial-gradient(70% 45% at 50% -10%, rgba(var(--lit-accent-rgb, 232, 220, 180), 0.14), transparent 70%),
                radial-gradient(50% 35% at 85% 110%, rgba(var(--lit-accent-rgb, 232, 220, 180), 0.07), transparent 70%);
            opacity: 0;
            transition: opacity 1.2s ease;
        }
        .has-lit-theme #lit-glow { opacity: 1; }

        /* Thin visible scrollbar for overflowing text blocks */
        .thin-scrollbar::-webkit-scrollbar { width: 6px; }
        .thin-scrollbar::-webkit-scrollbar-track { background: transparent; }
        .thin-scrollbar::-webkit-scrollbar-thumb { background: #6b6b73; border-radius: 6px; }
        .thin-scrollbar::-webkit-scrollbar-thumb:hover { background: #8a8a92; }
        
        .bead-active { box-shadow: 0 0 12px rgba(255,255,255,0.8); }
        .tab-btn.active { border-bottom: 2px solid #38bdf8; color: #f4f4f5; }
        .filter-btn.active { background-color: #27272a; color: #22d3ee; border-color: #52525b; }
        ::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.5; cursor: pointer; }
        .modal-enter { animation: fadeIn 0.2s ease-out forwards; }
        @keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
        .adoration-overlay { background: radial-gradient(circle, transparent 20%, #09090b 90%); }

        /* Fullscreen Video Fallback (Mobile/iOS) */
        .video-fullscreen-active {
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            z-index: 99999 !important;
            border-radius: 0 !important;
            border: none !important;
            margin: 0 !important;
            padding: 0 !important;
        }

        /* ==========================================================================
           LITURGICAL THEMING  (variables set per-day by applyLiturgicalTheme())
           ========================================================================== */
        #lit-topbar {
            /* Static (not fixed): the accent hairline scrolls along with the page. */
            width: 100%; height: 3px; z-index: 60;
            background: #27272a; transition: background .7s ease, box-shadow .7s ease;
            pointer-events: none;
        }
        .has-lit-theme #lit-topbar {
            background: var(--lit-accent, #e8dcb4);
            box-shadow: 0 0 14px 0 rgba(var(--lit-accent-rgb, 232,220,180), .55);
        }
        #lit-card { position: relative; }
        .has-lit-theme #lit-card .lit-section-label { color: var(--lit-accent, #e8dcb4); }
        .tab-btn.active { border-bottom: 2px solid var(--lit-accent, #38bdf8); color: #f4f4f5; }

        /* Tab strip scroll-edge fades — visible only when there is content to scroll to */
        .tab-fade {
            position: absolute;
            top: 0;
            bottom: -1px; /* extend over the 1px border-b for a clean fade across the row */
            width: 48px;
            pointer-events: none;
            z-index: 10;
            opacity: 0;
            transition: opacity 0.2s ease;
        }
        .tab-fade-left { left: 0; background: linear-gradient(to right, #09090b 20%, transparent); }
        .tab-fade-right { right: 0; background: linear-gradient(to left, #09090b 20%, transparent); }

        /* Anchor the footer flush to the bottom edge (the body has p-3 sm:p-6 padding). */
        .footer-flush { margin-bottom: -0.75rem; }
        @media (min-width: 640px) { .footer-flush { margin-bottom: -1.5rem; } }

        /* ==========================================================================
           MOTION POLISH
           ========================================================================== */
        @media (prefers-reduced-motion: no-preference) {
            .view-enter { animation: viewIn .28s cubic-bezier(.2,.8,.2,1) both; }
            @keyframes viewIn {
                from { opacity: 0; transform: translateY(10px); }
                to   { opacity: 1; transform: translateY(0); }
            }
            .stagger > * { animation: cardIn .45s cubic-bezier(.2,.8,.2,1) both; }
            .stagger > *:nth-child(2) { animation-delay: .08s; }
            @keyframes cardIn {
                from { opacity: 0; transform: translateY(14px); }
                to   { opacity: 1; transform: translateY(0); }
            }
            .bead-active {
                box-shadow: 0 0 10px rgba(255,255,255,.75), 0 0 0 1px rgba(255,255,255,.4);
                animation: beadPulse 2.2s ease-in-out infinite;
            }
            @keyframes beadPulse {
                0%,100% { box-shadow: 0 0 8px rgba(255,255,255,.5), 0 0 0 1px rgba(255,255,255,.3); }
                50%     { box-shadow: 0 0 16px rgba(255,255,255,.95), 0 0 0 1px rgba(255,255,255,.5); }
            }
        }

/* Sanctum — self-hosted typefaces (EB Garamond, OFL licensed).
   Loaded via app.css to win the cascade over Tailwind's .font-serif default. */
@font-face {
    font-family: 'EB Garamond';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/400-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'EB Garamond';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/400-italic.woff2') format('woff2');
}
@font-face {
    font-family: 'EB Garamond';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/500-normal.woff2') format('woff2');
}
@font-face {
    font-family: 'EB Garamond';
    font-style: italic;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/600-italic.woff2') format('woff2');
}
@font-face {
    font-family: 'EB Garamond';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/600-normal.woff2') format('woff2');
}

/* Apply the sacred serif wherever the app calls for `font-serif`
   (prayer text, intentions, saint quotes, historical entries). */
.font-serif {
    font-family: 'EB Garamond', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
}

/* Long-form prayer reading (Rosary, Novena, Treasury, checkpoints).
   Upright (roman) face at medium weight is far easier to read than the
   italic face at small sizes on a dark background. Applied on top of
   `font-serif` + a size; text-size settings (sm/lg/xl) still govern size. */
.prayer-read {
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0.004em;
}

/* ==========================================================================
   SETTINGS-DRIVEN: prayer text size
   Scoped to the sacred serif (the prayer/quote/intention text).
   ========================================================================== */
[data-text-size="sm"] .font-serif { font-size: 0.875rem !important; line-height: 1.6 !important; }
[data-text-size="lg"] .font-serif { font-size: 1.15rem !important; line-height: 1.7 !important; }
[data-text-size="xl"] .font-serif { font-size: 1.4rem !important; line-height: 1.8 !important; }

/* ==========================================================================
   SETTINGS-DRIVEN: reduced motion
   Kills the ambient glow, bead pulse, and view/modal/card transitions.
   ========================================================================== */
[data-motion="reduced"] .view-enter,
[data-motion="reduced"] .stagger > *,
[data-motion="reduced"] .modal-enter,
[data-motion="reduced"] .shimmer {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}
[data-motion="reduced"] .bead-active { animation: none !important; }
[data-motion="reduced"] #lit-glow { transition: none; }
[data-motion="reduced"] #lit-topbar { transition: none; }
[data-motion="reduced"] * { transition-duration: 0.01ms !important; }

/* ==========================================================================
   SETTINGS-DRIVEN: LIGHT THEME  (data-theme="light" on <html>)
   Warm parchment / aged-vellum palette. Dark is the default; Light remaps the
   whole surface, text, border, and accent system so everything stays legible
   on the light canvas (especially the liturgical-color chips, which are dark
   chips in dark mode and must become pale, high-contrast chips here).
   ========================================================================== */
[data-theme="light"] { color-scheme: light; background-color: #f4efe6; }
[data-theme="light"] body { background-color: #f4efe6; }

/* --- surfaces (warm, parchment-tinted) --- */
[data-theme="light"] .bg-zinc-950 { background-color: #fbf8f2 !important; }
[data-theme="light"] .bg-zinc-900 { background-color: #fffdf8 !important; }
[data-theme="light"] .bg-zinc-800 { background-color: #f0e9db !important; }
[data-theme="light"] .bg-zinc-700 { background-color: #e5dccb !important; }
[data-theme="light"] .bg-zinc-950\/50, [data-theme="light"] .bg-zinc-950\/60 { background-color: rgba(244,239,230,.72) !important; }
[data-theme="light"] .bg-zinc-950\/80 { background-color: rgba(244,239,230,.85) !important; }
[data-theme="light"] .bg-zinc-950\/40 { background-color: rgba(244,239,230,.55) !important; }
[data-theme="light"] .bg-zinc-900\/50, [data-theme="light"] .bg-zinc-900\/40 { background-color: rgba(255,253,248,.6) !important; }
[data-theme="light"] .bg-black\/95, [data-theme="light"] .bg-black\/80 { background-color: rgba(244,239,230,.94) !important; }
/* NOTE: bg-black (video frame) and bg-black/70 (video overlay btn) intentionally stay dark */

/* --- text (warm ink on parchment) --- */
[data-theme="light"] .text-zinc-100 { color: #2b2620 !important; }
[data-theme="light"] .text-zinc-200 { color: #2b2620 !important; }
[data-theme="light"] .text-zinc-300 { color: #4a4238 !important; }
[data-theme="light"] .text-zinc-400 { color: #6a6154 !important; }
[data-theme="light"] .text-zinc-500 { color: #847a6b !important; }
[data-theme="light"] .text-zinc-600 { color: #9a9082 !important; }
[data-theme="light"] .text-white { color: #2b2620 !important; }
[data-theme="light"] .text-zinc-100\/60, [data-theme="light"] .text-zinc-200\/60 { color: #6a6154 !important; }
/* accent text -> deep verdigris teal (on-theme with the cyan cross) */
[data-theme="light"] .text-cyan-400, [data-theme="light"] .text-cyan-500, [data-theme="light"] .text-cyan-300 { color: #0c5f63 !important; }
[data-theme="light"] .text-emerald-400, [data-theme="light"] .text-emerald-300 { color: #1a5e2e !important; }
[data-theme="light"] .text-red-400 { color: #8a2418 !important; }
[data-theme="light"] .text-blue-400 { color: #1e3a8a !important; }
[data-theme="light"] .text-amber-400, [data-theme="light"] .text-amber-300 { color: #7a5410 !important; }
[data-theme="light"] .text-indigo-400 { color: #3a2a7a !important; }
[data-theme="light"] .text-violet-400 { color: #4a2c7a !important; }
[data-theme="light"] .text-rose-400 { color: #8a2c52 !important; }
/* mid-scale accent text: keep it dark enough for the parchment chips */
[data-theme="light"] .text-emerald-500 { color: #1a5e2e !important; }
[data-theme="light"] .text-red-500 { color: #8a2418 !important; }
[data-theme="light"] .text-amber-500 { color: #7a5410 !important; }
[data-theme="light"] .text-indigo-500, [data-theme="light"] .text-indigo-200 { color: #3a2a7a !important; }
/* white text that sits on the (still-dark) video area keeps white */
[data-theme="light"] .bg-black\/70 .text-white, [data-theme="light"] .adoration-video-container .text-white, [data-theme="light"] .video-fullscreen-active .text-white { color: #fff !important; }

/* --- borders (warm hairlines) --- */
[data-theme="light"] .border-zinc-500 { border-color: #c9bda6 !important; }
[data-theme="light"] .border-zinc-600 { border-color: #d3c8b4 !important; }
[data-theme="light"] .border-zinc-700 { border-color: #dcd3c0 !important; }
[data-theme="light"] .border-zinc-800 { border-color: #e6ddcc !important; }
[data-theme="light"] .border-zinc-800\/80, [data-theme="light"] .border-zinc-800\/60, [data-theme="light"] .border-zinc-800\/50 { border-color: #e0d6c4 !important; }
[data-theme="light"] .border-cyan-500 { border-color: #2a9aa0 !important; }
[data-theme="light"] .border-cyan-900 { border-color: #bfe3e6 !important; }

/* --- LITURGICAL / ACCENT CHIPS: dark chips in dark mode become pale,
       high-contrast chips in light mode (this is what fixes the unreadable
       "brown on red" season badges). Applied with !important so they win. --- */
[data-theme="light"] .bg-emerald-950\/70, [data-theme="light"] .bg-emerald-950\/40, [data-theme="light"] .bg-emerald-950\/30, [data-theme="light"] .bg-emerald-900\/50 { background-color: #e2efe2 !important; }
[data-theme="light"] .bg-red-950\/70, [data-theme="light"] .bg-red-950\/50 { background-color: #f2e0dc !important; }
[data-theme="light"] .bg-violet-950\/70 { background-color: #ebe1f2 !important; }
[data-theme="light"] .bg-rose-950\/70 { background-color: #f4e2ea !important; }
[data-theme="light"] .bg-cyan-950\/20, [data-theme="light"] .bg-cyan-950\/25, [data-theme="light"] .bg-cyan-950\/30, [data-theme="light"] .bg-cyan-950\/40, [data-theme="light"] .bg-cyan-900\/50 { background-color: #dceef0 !important; }
[data-theme="light"] .bg-amber-950\/30, [data-theme="light"] .bg-amber-950\/50, [data-theme="light"] .bg-amber-900\/40 { background-color: #f4eacf !important; }
[data-theme="light"] .bg-blue-950\/30 { background-color: #e0e7f3 !important; }
[data-theme="light"] .bg-indigo-950\/20, [data-theme="light"] .bg-indigo-900\/50 { background-color: #e6e1f0 !important; }
/* chip borders + text (pair with the pale fills above) */
[data-theme="light"] .border-emerald-800 { border-color: #a7c9a7 !important; }
[data-theme="light"] .border-emerald-900 { border-color: #a7c9a7 !important; }
[data-theme="light"] .border-red-800, [data-theme="light"] .border-red-900 { border-color: #d8a49c !important; }
[data-theme="light"] .border-violet-800 { border-color: #c2a7da !important; }
[data-theme="light"] .border-rose-800 { border-color: #d8a8c0 !important; }
[data-theme="light"] .border-amber-900 { border-color: #d9c084 !important; }
[data-theme="light"] .border-blue-900 { border-color: #a9bede !important; }
[data-theme="light"] .border-indigo-900 { border-color: #b9a9dd !important; }
/* The chip *text* is where the dark-mode "-300/-400" light tints live; remap them to dark, saturated inks for contrast on the pale fills. */
[data-theme="light"] .bg-emerald-950\/70 .text-emerald-300, [data-theme="light"] .bg-emerald-950\/30 .text-emerald-300, [data-theme="light"] .text-emerald-300 { color: #1a5e2e !important; }
[data-theme="light"] .bg-red-950\/70 .text-red-400 { color: #8a2418 !important; }
[data-theme="light"] .bg-violet-950\/70 .text-violet-400 { color: #4a2c7a !important; }
[data-theme="light"] .bg-rose-950\/70 .text-rose-400 { color: #8a2c52 !important; }
/* the WHITE / BLACK liturgical badges (neutral) stay legible */
[data-theme="light"] .bg-zinc-200 { background-color: #efe8da !important; }
[data-theme="light"] .text-zinc-900 { color: #2b2620 !important; }

/* --- focus + selection --- */
[data-theme="light"] :focus-visible { outline: 2px solid rgba(12,95,99,.6); }
[data-theme="light"] body::selection { background: #ecd9a6 !important; color: #3a2f1a !important; }

/* --- scrollbars (warm) --- */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cbbfa6; border: 2px solid rgba(244,239,230,.9); }
[data-theme="light"] .thin-scrollbar::-webkit-scrollbar-thumb { background: #cbbfa6; }
[data-theme="light"] html { scrollbar-color: #cbbfa6 transparent; }
[data-theme="light"] ::-webkit-calendar-picker-indicator { filter: invert(0); opacity: 0.6; }

/* --- decorative + liturgical accents, tuned for parchment --- */
[data-theme="light"] .tab-fade-left { background: linear-gradient(to right, #f4efe6 20%, transparent); }
[data-theme="light"] .tab-fade-right { background: linear-gradient(to left, #f4efe6 20%, transparent); }
[data-theme="light"] .adoration-overlay { background: radial-gradient(circle, transparent 20%, #f4efe6 90%); }
[data-theme="light"] .tab-btn.active { color: #2b2620 !important; }
[data-theme="light"] .filter-btn.active { background-color: #f0e9db; color: #0c5f63; border-color: #d3c8b4; }
[data-theme="light"] .bead-active { box-shadow: 0 0 12px rgba(176,140,40,.85), 0 0 0 1px rgba(176,140,40,.5); }
[data-theme="light"] #lit-glow { opacity: 0.55; }
[data-theme="light"] .has-lit-theme #lit-card .lit-section-label { filter: brightness(0.62) saturate(1.25); }
[data-theme="light"] .has-lit-theme #lit-topbar { box-shadow: 0 0 10px 0 rgba(120,96,40,.35); }
/* shimmer placeholder text: dark sweep reads well on parchment */
[data-theme="light"] .shimmer { background: linear-gradient(100deg, #847a6b 35%, #b3a78f 50%, #847a6b 65%); -webkit-background-clip: text; background-clip: text; }


