body { transition: background-color 0.3s, color 0.3s; }
        .verse-text { line-height: 1.8; word-break: keep-all; }
        .blank {
            display: inline-block;
            min-width: 2rem;
            text-align: center;
            border-bottom: 2px solid #9ca3af;
            color: transparent;
            cursor: pointer;
            transition: all 0.2s;
            padding: 0 4px;
            user-select: none;
        }
        .dark .blank { border-bottom-color: #6b7280; }
        .blank.revealed { color: #2563eb; border-bottom-color: transparent; }
        .dark .blank.revealed { color: #60a5fa; }

        #sidebar { transition: transform 0.3s ease-in-out; }
        #sidebar.open { transform: translateX(0) !important; }

        .modal-overlay {
            transition: opacity 0.3s ease-in-out;
            pointer-events: none;
            opacity: 0;
        }
        .modal-overlay.open {
            pointer-events: auto;
            opacity: 1;
        }

        select, input[type="text"] { appearance: none; outline: none; }
        select {
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
            background-position: right 0.5rem center;
            background-repeat: no-repeat;
            background-size: 1.5em 1.5em;
            padding-right: 2.5rem;
        }
        .dark select {
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
        }

        .custom-scrollbar { scroll-behavior: smooth; }
        .custom-scrollbar::-webkit-scrollbar { width: 6px; }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background-color: #cbd5e1;
            border-radius: 10px;
        }
        .dark .custom-scrollbar::-webkit-scrollbar-thumb { background-color: #4b5563; }
        .chapter-scroll { flex: 1; overflow-y: auto; padding-right: 15px; }

        .highlight-marker {
            background-color: #fef08a;
            padding: 0 2px;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        .highlight-marker:hover { background-color: #fde047; }
        .dark .highlight-marker { background-color: #ca8a04; color: #fff; }
        .dark .highlight-marker:hover { background-color: #eab308; }

        select:focus, textarea:focus, input:focus {
            outline: none;
            ring: 2px solid #2563eb;
            border-color: #2563eb;
        }

        .dialog-pop {
            transform: scale(0.95);
            opacity: 0;
            transition: all 0.2s ease-out;
        }
        .dialog-pop.open {
            transform: scale(1);
            opacity: 1;
        }

        .mobile-icon-only-text { display: inline; }

.mobile-nav-bar-3,
.mobile-nav-bar-2 {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-nav-bar-3 {
    justify-content: space-between;
}

.mobile-nav-bar-2 {
    justify-content: space-between;
}

.mobile-nav-btn {
    min-height: 48px;
    min-width: 88px;
    width: auto;
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    flex: 0 0 auto;
}

        .mobile-nav-btn i { margin: 0; }

        .picker-chip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: .5rem;
            width: 100%;
            min-height: 52px;
            padding: .85rem 1rem;
            border-radius: 1rem;
            border: 1px solid rgb(209 213 219);
            background: white;
            font-weight: 700;
            box-shadow: 0 1px 2px rgba(0,0,0,.03);
        }
        .dark .picker-chip {
            background: rgb(55 65 81);
            border-color: rgb(75 85 99);
            color: rgb(243 244 246);
        }

        .picker-sheet {
            transform: translateY(100%);
            transition: transform .28s ease;
        }
        .picker-sheet.open { transform: translateY(0); }

        @media (max-width: 640px) {
            main { padding: 12px !important; }

            header .max-w-7xl {
                padding-top: 12px !important;
                padding-bottom: 12px !important;
            }

            h1 { font-size: 1.35rem !important; }

            #currentModeLabel {
                font-size: 0.75rem !important;
                padding: 0.35rem 0.65rem !important;
            }

            #memorization-view > div.w-full.flex.justify-end.gap-3.mb-4 {
                gap: 0.5rem !important;
                margin-bottom: 0.75rem !important;
            }

            #memorization-view > div.w-full.flex.justify-end.gap-3.mb-4 button {
                padding: 0.75rem !important;
                border-radius: 0.9rem !important;
            }

            #memorization-view > div.w-full.flex.justify-end.gap-3.mb-4 i {
                font-size: 1rem !important;
            }

            #memorization-view .rounded-3xl .p-8,
            #readingContent .p-8,
            #reading-view .rounded-3xl .p-6 {
                padding: 1.25rem !important;
            }

            #verseCounter,
            #verseGroupBadge { font-size: 0.7rem !important; }

            #verseRef,
            #bibleVerseRef {
                font-size: 1.25rem !important;
                line-height: 1.4 !important;
                text-align: center;
            }

            #verseText {
                font-size: 1.85rem !important;
                line-height: 1.7 !important;
                word-break: keep-all;
            }

            #bibleVerseText {
                font-size: 1.1rem !important;
                line-height: 1.9 !important;
            }

            #reading-view button,
            #addVerseModalOverlay select,
            #addVerseModalOverlay button,
            #listModalOverlay button,
            #listModalOverlay input {
                font-size: 0.95rem !important;
            }

            .mobile-nav-bar-3 {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr !important;
    gap: 0.75rem !important;
    align-items: center !important;
    padding: 1rem !important;
}

.mobile-nav-bar-2 {
    display: grid !important;
    grid-template-columns: auto auto !important;
    justify-content: space-between !important;
    gap: 0.75rem !important;
    align-items: center !important;
    padding: 1rem !important;
}

.mobile-nav-btn {
    min-height: 48px;
    min-width: 52px;
    width: auto !important;
    padding: 0.8rem 0.9rem !important;
    border-radius: 1rem !important;
    font-size: 0.95rem !important;
    justify-content: center !important;
}

            .mobile-nav-btn i { font-size: 0.95rem !important; }

            .mobile-icon-only-text { display: none !important; }

            .mobile-random-btn {
                width: 52px !important;
                min-width: 52px !important;
                padding-left: 0 !important;
                padding-right: 0 !important;
                justify-self: center !important;
            }

            #memorization-view .rounded-2xl.shadow.p-6 { padding: 1rem !important; }

            #levelValue { font-size: 0.8rem !important; }

            #globalSearchInput { font-size: 1rem !important; }

            #pickerSheetPanel { max-height: 78vh; }

            .picker-chip {
                min-height: 48px;
                padding: .75rem .9rem;
                font-size: .92rem;
            }
        }

        @media (max-width: 400px) {
            #verseText { font-size: 1.65rem !important; }
            #verseRef, #bibleVerseRef { font-size: 1.1rem !important; }

            .mobile-nav-bar-3,
            .mobile-nav-bar-2 { gap: 0.5rem !important; }

       .mobile-nav-btn {
    min-height: 44px;
    min-width: 48px;
    padding: 0.7rem 0.75rem !important;
}

            .mobile-random-btn {
                width: 48px !important;
                min-width: 48px !important;
            }
        }

/* Reading nav scroll-snap collapse/expand */
#reading-view.reading-snap-active {
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#reading-view.reading-snap-active::-webkit-scrollbar {
    display: none;
}

#reading-view.reading-snap-active .reading-snap-nav {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    flex-shrink: 0;
}

#reading-view.reading-snap-active .reading-snap-content {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    flex-shrink: 0;
    /* Use viewport unit directly instead of height:100%.
       On mobile, when the address bar hides during programmatic scroll,
       100dvh grows but height:100% on a flex child inside a scroll
       container may NOT recalculate — leaving a gap at the bottom.
       Viewport units always reflect the current viewport size. */
    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
}

#readingNavCollapsed {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#readingNavCollapsed.collapsed-visible {
    display: flex !important;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Calendar styles */
.cal-grid-month { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-grid-month .cal-day-header {
    padding: 8px 4px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}
.dark .cal-grid-month .cal-day-header { color: #9ca3af; border-bottom-color: #374151; }
.cal-grid-month .cal-day-header:first-child { color: #ef4444; }
.cal-grid-month .cal-day-header:last-child { color: #3b82f6; }

.cal-day-cell {
    min-height: 90px;
    padding: 4px;
    border-bottom: 1px solid #f3f4f6;
    border-right: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.15s;
    overflow: hidden;
    min-width: 0;
}
.cal-day-cell:hover { background-color: #f9fafb; }
.dark .cal-day-cell { border-color: #1f2937; }
.dark .cal-day-cell:hover { background-color: #1f2937; }
.cal-day-cell.other-month { opacity: 0.35; }
.cal-day-cell.today .cal-day-num {
    background-color: #2563eb;
    color: white;
    border-radius: 9999px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-day-num {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 4px;
    color: #374151;
}
.dark .cal-day-num { color: #d1d5db; }
.cal-day-cell:nth-child(7n+1) .cal-day-num { color: #ef4444; }
.cal-day-cell:nth-child(7n) .cal-day-num { color: #3b82f6; }

.cal-event-dot {
    display: block;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin-bottom: 1px;
    max-width: 100%;
}
.cal-event-dot:hover { opacity: 0.8; }

@keyframes cal-highlight-pulse {
    0%, 100% { box-shadow: 0 0 0 4px #3b82f6, 0 0 16px 6px rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 0 0 6px #2563eb, 0 0 24px 10px rgba(37, 99, 235, 0.35); }
}
.cal-event-highlight {
    animation: cal-highlight-pulse 0.8s ease-in-out 6 !important;
    box-shadow: 0 0 0 4px #3b82f6, 0 0 16px 6px rgba(59, 130, 246, 0.5) !important;
    background: #2563eb !important;
    color: #fff !important;
    border-left-color: #1d4ed8 !important;
    z-index: 50 !important;
    position: relative !important;
    overflow: visible !important;
    border-radius: 6px;
}
.cal-span-bar.cal-event-highlight {
    opacity: 1 !important;
}

.cal-toggle-knob[data-on="true"] { background-color: #2563eb; }
.cal-toggle-knob[data-on="true"] span { transform: translateX(20px); }

/* Calendar week/day view */
:root { --cal-border: #e5e7eb; }
.dark { --cal-border: #374151; }
#calGrid { touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overflow-x: auto; }
.cal-time-col { transition: background 0.15s; }
.cal-time-slot:hover { background-color: rgba(59, 130, 246, 0.04); }
.dark .cal-time-slot:hover { background-color: rgba(59, 130, 246, 0.08); }
.cal-event-block { transition: opacity 0.15s, box-shadow 0.15s; }
.cal-event-block:hover { opacity: 0.85; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

@media (max-width: 640px) {
    .cal-day-cell { min-height: 60px; }
    .cal-event-dot { font-size: 0.6rem; padding: 1px 4px; }
    .cal-day-num { font-size: 0.7rem; }
}
