/* ============================================
   THÁNHCA.NET - Mobile-First Layout v2
   Bottom navigation, responsive grid,
   liturgical season auto-theming,
   fluid responsive design
   ============================================ */

/* === GLOBAL RESPONSIVE RULES === */
img, video, svg, canvas {
    max-width: 100%;
    height: auto;
}

iframe, embed, object {
    max-width: 100%;
}

table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

/* Prevent horizontal overflow */
.main-content,
.page {
    overflow-x: hidden;
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION BAR
   ============================================================ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(180deg, rgba(28,8,56,.97), rgba(42,12,80,.99));
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(200,150,60,.2);
    z-index: 999;
    padding: 0 4px;
    box-shadow: 0 -3px 14px rgba(20,0,50,.24);
}
.mobile-bottom-nav-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: 4px 2px;
    cursor: pointer;
    text-decoration: none;
    color: rgba(255,255,255,.5);
    transition: all .2s ease;
    position: relative;
    border: none;
    background: none;
    font-family: var(--font-primary);
    -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item:active {
    transform: scale(.92);
}
.mobile-nav-item.active {
    color: var(--gold);
}
.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 3px;
    background: var(--gold);
    border-radius: 0 0 3px 3px;
}
.mobile-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}
.mobile-nav-label {
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* ============================================================
   MOBILE HAMBURGER MENU BUTTON
   ============================================================ */
.mobile-menu-btn {
    display: none;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.85);
    cursor: pointer;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.mobile-menu-btn:active {
    background: rgba(255,255,255,.15);
}

/* ============================================================
   MOBILE SLIDE-OUT MENU OVERLAY
   ============================================================ */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,0,20,.7);
    backdrop-filter: blur(3px);
    z-index: 9998;
    opacity: 0;
    transition: opacity .3s ease;
}
.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-slide-menu {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, rgba(28,8,56,.98), rgba(42,12,80,.97));
    backdrop-filter: blur(12px);
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 4px 0 18px rgba(20,0,50,.28);
}
.mobile-slide-menu.active {
    transform: translateX(0);
}
.mobile-slide-menu-header {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mobile-slide-menu-brand {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .4px;
    line-height: 1.08;
    max-width: calc(100% - 44px);
    text-wrap: balance;
}
.mobile-slide-menu-brand span { color: var(--gold); }
.mobile-slide-menu-close {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-slide-menu-nav {
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.mobile-slide-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,.65);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    border: none;
    background: none;
    font-family: var(--font-primary);
    width: 100%;
    text-align: left;
}
.mobile-slide-nav-item:active,
.mobile-slide-nav-item:hover {
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.95);
}
.mobile-slide-nav-item.active {
    background: linear-gradient(135deg, rgba(107,70,150,.5), rgba(80,40,120,.4));
    color: #fff;
    font-weight: 600;
}
.mobile-slide-nav-icon {
    font-size: 1.1rem;
    width: 26px;
    text-align: center;
    flex-shrink: 0;
}

/* ============================================================
   LITURGICAL SEASON AUTO-THEMING
   ============================================================ */

/* Mùa Thường Niên — Xanh lá */
[data-season="thuong-nien"] {
    --season-primary: #16a34a;
    --season-secondary: #22c55e;
    --season-bg: rgba(34,197,94,.08);
    --season-gradient: linear-gradient(135deg, #1a6b3f, #27ae60);
    --season-border: rgba(34,197,94,.25);
    --season-glow: rgba(34,197,94,.15);
}
/* Mùa Vọng — Tím */
[data-season="mua-vong"] {
    --season-primary: #7c3aed;
    --season-secondary: #8b5cf6;
    --season-bg: rgba(124,58,237,.08);
    --season-gradient: linear-gradient(135deg, #4a1a7d, #6b3fa0);
    --season-border: rgba(124,58,237,.25);
    --season-glow: rgba(124,58,237,.15);
}
/* Giáng Sinh — Trắng / Vàng */
[data-season="giang-sinh"] {
    --season-primary: #c8963c;
    --season-secondary: #deb06a;
    --season-bg: rgba(200,150,60,.08);
    --season-gradient: linear-gradient(135deg, #b8860b, #deb06a);
    --season-border: rgba(200,150,60,.25);
    --season-glow: rgba(200,150,60,.15);
}
/* Mùa Chay — Tím đậm */
[data-season="mua-chay"] {
    --season-primary: #5b21b6;
    --season-secondary: #7c3aed;
    --season-bg: rgba(91,33,182,.08);
    --season-gradient: linear-gradient(135deg, #2d0a4e, #5a1a8a);
    --season-border: rgba(91,33,182,.25);
    --season-glow: rgba(91,33,182,.15);
}
/* Phục Sinh — Trắng / Vàng sáng */
[data-season="phuc-sinh"] {
    --season-primary: #d4af37;
    --season-secondary: #fbbf24;
    --season-bg: rgba(212,175,55,.08);
    --season-gradient: linear-gradient(135deg, #b8860b, #ffd700);
    --season-border: rgba(212,175,55,.25);
    --season-glow: rgba(212,175,55,.15);
}

/* Apply season accents without recoloring the whole header */
[data-season] .top-header {
    border-bottom-color: var(--season-border);
}
[data-season] .top-header::before {
    background: linear-gradient(90deg, transparent, var(--season-primary), var(--season-secondary), transparent) !important;
    opacity: .72;
}
[data-season] .brand-title span {
    color: var(--season-secondary);
}

/* Sidebar accent */
[data-season] .nav-item.active {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 2px 8px var(--season-glow);
}
[data-season] .nav-item.active .nav-icon {
    color: var(--season-secondary);
}

/* Mobile bottom nav season accent */
[data-season] .mobile-bottom-nav {
    border-top-color: var(--season-border);
}
[data-season] .mobile-nav-item.active {
    color: var(--season-secondary);
}
[data-season] .mobile-nav-item.active::before {
    background: var(--season-secondary);
}

/* Footer accent */
[data-season] .site-footer {
    border-top-color: var(--season-border);
}

/* Season transition */
[data-season] .top-header,
[data-season] .top-header::before,
[data-season] .mobile-bottom-nav,
[data-season] .site-footer,
[data-season] .brand-title span {
    transition: border-color .35s ease, color .35s ease, opacity .35s ease;
}

/* ============================================================
   PULL TO REFRESH INDICATOR
   ============================================================ */
.pull-refresh-indicator {
    display: none;
    position: fixed;
    top: 0; left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--purple);
    color: #fff;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    z-index: 800;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    transition: transform .3s ease;
}
.pull-refresh-indicator.visible {
    display: flex;
    transform: translateX(-50%) translateY(16px);
}
.pull-refresh-indicator.loading {
    animation: spinPull .8s linear infinite;
}
@keyframes spinPull {
    to { transform: translateX(-50%) translateY(16px) rotate(360deg); }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* --------- Tablet (≤ 1000px) --------- */
@media (max-width: 1000px) {
    .right-sidebar { display: none; }
}

/* --------- Mobile (≤ 768px) --------- */
@media (max-width: 768px) {
    /* Show mobile nav, hide desktop sidebar */
    .sidebar { display: none !important; }
    .mobile-bottom-nav { display: block; }
    .mobile-menu-btn { display: flex; }
    .main-wrapper { margin-left: 0 !important; }
    .content-row { display: block; }

    /* Header compact */
    .top-header { min-height: auto; }
    .header-brand { padding: 8px 14px 2px; }
    .brand-title {
        font-size: clamp(1.36rem, 5.8vw, 1.76rem);
        letter-spacing: .02em;
        line-height: 1.04;
    }
    .brand-sub {
        font-size: .61rem;
        margin-top: 3px;
        letter-spacing: .05em;
        line-height: 1.22;
        max-width: 100%;
    }
    .header-jesus-wrap { display: none; }

    /* Header nav row */
    .header-nav { display: none; }
    .header-nav-row {
        padding: 6px 14px 10px;
        display: grid;
        grid-template-columns: 40px minmax(0, 1fr);
        align-items: stretch;
        gap: 8px;
    }
    .mobile-header-left {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px;
        border-radius: 20px;
        border: 1px solid rgba(255,255,255,.14);
        background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.05));
        box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
    }
    .mobile-header-home-btn,
    .header-auth {
        width: auto;
        min-width: 0;
        gap: 6px;
        justify-content: flex-end;
        align-items: stretch;
        flex-wrap: nowrap;
    }
    #header-analytics-badge { display: none; }
    #auth-toolbar,
    #user-logged-in {
        flex: 0 0 auto;
        justify-content: flex-end;
        min-width: 0;
        gap: 6px !important;
    }
    #auth-toolbar {
        display: flex;
        align-items: stretch;
    }
    .header-btn-outline,
    .header-btn-filled {
        min-height: 40px;
        min-width: 102px;
        padding: 0 12px;
        font-size: .78rem;
        border-radius: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-header-home-btn,
    .mobile-menu-btn,
    .header-icon-btn {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        font-size: 1rem;
        border: 0;
        background: transparent;
        box-shadow: none;
        color: rgba(255,255,255,.92);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 40px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Main content — add bottom padding for nav bar */
    .main-content {
        min-height: calc(100vh - 80px);
        padding-bottom: 82px;
    }
    .page { padding: 10px; }

    /* Footer hidden on mobile (bottom nav replaces it) */
    .site-footer { display: none; }

    /* Dashboard search bar */
    #dashboard-content {
        display: flex;
        flex-direction: column;
    }
    #dashboard-content > .liturgical-today-widget { order: 1; }
    #dashboard-content > .category-icons-grid { order: 2; }
    #dashboard-content > .search-bar-row { order: 3; }
    #dashboard-content > div:nth-child(2) {
        order: 4;
        justify-content: flex-start !important;
        margin-bottom: 12px !important;
    }
    #dashboard-content > .filter-tabs { order: 5; }
    #dashboard-content > .song-list-header { order: 6; }
    #dashboard-content > .song-list { order: 7; }
    .dashboard-week-title {
        display: none;
    }
    .search-bar-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 12px;
    }
    .search-tool-btns {
        display: none;
    }
    .search-input {
        min-height: 48px;
        border-radius: 14px;
        font-size: .98rem;
    }
    .search-tool-btn {
        min-width: 0;
        height: 40px;
        padding: 0 6px;
        border-radius: 12px;
        font-size: .82rem;
    }
    /* 2-column song grid for dashboard */
    .song-list-header { display: none; }
    .song-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 2px;
    }
    .song-row {
        display: flex;
        flex-direction: column;
        padding: 12px;
        border-radius: 12px;
        border: 1px solid rgba(107,70,150,.08);
        background: rgba(255,255,255,.98);
        box-shadow: 0 2px 8px rgba(61,32,102,.06);
        gap: 6px;
        transition: all .2s;
    }
    .song-row:hover {
        box-shadow: 0 4px 16px rgba(61,32,102,.12);
        transform: translateY(-2px);
    }
    .song-col-title {
        order: 1;
    }
    .song-name {
        font-size: .88rem;
        white-space: normal;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .song-col-cat {
        order: 2;
        font-size: .72rem;
    }
    .song-col-author {
        order: 3;
        font-size: .72rem;
        color: var(--text-muted);
    }
    .song-col-views {
        order: 4;
        font-size: .72rem;
    }
    .song-col-actions {
        order: 5;
        justify-content: flex-start;
        gap: 6px;
    }

    /* Category icons - scroll horizontal */
    .category-icons-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px 6px;
        overflow: visible;
        padding-bottom: 0;
    }
    .cat-icon-btn {
        min-width: 0;
        gap: 6px;
    }
    .cat-icon-inner {
        width: 56px;
        height: 56px;
        margin: 0 auto;
        font-size: 1.26rem;
        border-radius: 16px;
        box-shadow: 0 10px 18px rgba(61,32,102,.1);
    }
    .cat-icon-label {
        font-size: .73rem;
        line-height: 1.25;
        max-width: 94px;
    }

    /* Filter tabs - horizontal scroll */
    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
    }
    .filter-tabs::-webkit-scrollbar { display: none; }
    .filter-tab { padding: 7px 10px; font-size: .78rem; }

    /* Alpha filter - horizontal scroll */
    .alpha-filter {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .alpha-filter::-webkit-scrollbar { display: none; }

    /* Week detail grid */
    .wkd-grid { grid-template-columns: 1fr !important; gap: 10px; }

    /* Stats grid */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-icon { font-size: 1.2rem; }
    .stat-value { font-size: 1rem; }

    /* Hero card */
    .hero-card { padding: 14px 16px; }
    .hero-title { font-size: 1rem; }
    .hero-actions { gap: 6px; }

    /* Page title */
    .page-title { font-size: var(--fs-md); }

    /* Liturgical today widget */
    .liturgical-today-widget {
        padding: 12px 12px 14px !important;
        gap: 10px !important;
        margin-bottom: 14px !important;
        border-left-width: 3px !important;
        border-radius: 18px !important;
        align-items: flex-start !important;
        box-shadow: 0 8px 22px rgba(61,32,102,.08);
    }
    .liturgical-today-widget > div:first-child {
        width: 40px;
        display: flex;
        justify-content: center;
        font-size: 1.7rem !important;
        margin-top: 2px;
    }
    .liturgical-today-widget > div:nth-child(2) {
        flex: 1 1 calc(100% - 52px) !important;
        min-width: 0 !important;
    }
    .liturgical-today-widget > div:nth-child(2) > div:first-child {
        font-size: .67rem !important;
        line-height: 1.35 !important;
        margin-bottom: 4px !important;
    }
    .liturgical-today-widget > div:nth-child(2) > div:nth-child(2) {
        font-size: 1rem !important;
        margin-bottom: 6px !important;
    }
    .liturgical-today-widget > div:nth-child(2) > div:last-child {
        gap: 6px !important;
    }
    .liturgical-today-widget > div:nth-child(2) > div:last-child > span {
        font-size: .74rem !important;
    }
    .liturgical-today-widget > div:nth-child(2) > div:last-child > span:nth-child(2) {
        display: none !important;
    }
    .liturgical-today-widget > div:last-child {
        flex: 1 1 100%;
        width: 100%;
        padding-left: 50px;
        align-items: stretch !important;
        justify-content: flex-start !important;
    }
    .liturgical-today-widget > div:last-child > button:first-child {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: auto;
        max-width: 100%;
        min-height: 36px;
        padding: 0 12px !important;
        border-radius: 999px !important;
        font-size: .76rem !important;
        align-self: flex-start;
    }

    /* Modals - full screen on mobile */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        animation: slideUpModal .3s ease;
    }
    @keyframes slideUpModal {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* PDF Quick View - full screen */
    .pdf-quick-overlay {
        padding: 0;
        align-items: flex-end;
        background: rgba(18, 8, 36, .56);
        backdrop-filter: blur(5px);
    }
    .pdf-quick-modal {
        max-width: 100%;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -12px 28px rgba(20,0,50,.2);
    }
    .pdf-quick-overlay.active .pdf-quick-modal { transform: translateY(0); }
    .pdf-qm-header {
        padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
        gap: 10px;
    }
    .pdf-qm-title {
        font-size: .92rem;
        line-height: 1.35;
    }
    .pdf-qm-close {
        min-width: 38px;
        height: 38px;
    }
    .pdf-qm-frame {
        height: 100%;
        min-height: 0;
        background: #f3f4f6;
    }

    /* Suggestions page */
    .sugg-year-tabs { gap: 8px; }
    .sugg-ytab { padding: 10px; max-width: none; }
    .sugg-stab { padding: 8px 14px; font-size: .8rem; }

    /* Quick actions */
    .quick-actions { grid-template-columns: 1fr; }

    /* Forum & other list items */
    .week-list-item { padding: 10px 14px; gap: 10px; }
    .phuvu-cards-grid { grid-template-columns: 1fr; }

    /* Category tabs (library) horizontal scroll */
    .category-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .category-tabs::-webkit-scrollbar { display: none; }

    /* Song table -> card layout */
    .songs-table { font-size: .74rem; }
    .songs-table th { padding: 8px 10px; font-size: .6rem; }
    .songs-table td { padding: 8px 10px; }

    /* Auth modal full-width */
    #auth-modal .modal { border-radius: 16px 16px 0 0; }
    .auth-modal-body { padding: 16px 14px 18px !important; }
    .auth-hero {
        padding: 16px;
        border-radius: 18px;
        gap: 12px;
    }
    .auth-hero-mark {
        width: 46px;
        height: 46px;
        border-radius: 14px;
        font-size: 1.25rem;
    }
    .auth-hero-title { font-size: 1.04rem; }
    .auth-hero-subtitle { font-size: .78rem; }
    .auth-provider-grid { grid-template-columns: 1fr; }
    .auth-social-btn {
        min-height: 50px;
        border-radius: 14px;
        font-size: .86rem;
    }
    .auth-mode-tabs { gap: 4px; padding: 4px; }
    .auth-mode-tab { min-height: 40px; font-size: .8rem; }
    .auth-form-footer {
        flex-direction: column;
        align-items: flex-start;
    }
    .auth-inline-note {
        min-width: 0;
        width: 100%;
    }

    /* Toast repositioned for mobile */
    .toast {
        bottom: 72px;
        right: 12px;
        left: 12px;
        text-align: center;
    }

    /* Dashboard week title */
    .dashboard-week-title { font-size: 1.1rem; }

    /* Personal grid */
    .dashboard-personal-grid {
        grid-template-columns: 1fr !important;
    }

    #user-logged-in {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        width: 100%;
    }
    #user-display-name {
        min-width: 0;
        max-width: 72px;
        display: block;
        padding: 0 8px;
        min-height: 40px;
        border: 1px solid rgba(255,255,255,.16);
        border-radius: 16px;
        background: rgba(255,255,255,.06);
    }
    #user-display-name > span {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        min-width: 0;
        height: 100%;
    }
    #user-display-name > span > span:first-of-type {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    body.user-authenticated #auth-toolbar {
        display: none !important;
    }
    body.user-authenticated #user-logged-in {
        display: grid !important;
        grid-template-columns: minmax(0, 72px) 40px;
        justify-content: flex-end;
    }
    body.user-authenticated #user-logged-in .header-btn-outline {
        min-width: 40px;
        width: 40px;
        padding: 0;
        font-size: 0;
    }
    body.user-authenticated #user-logged-in .header-btn-outline::before {
        content: '🚪';
        font-size: 1rem;
        line-height: 1;
    }

    /* Floating favorites button */
    .fav-btn-float {
        width: 46px;
        height: 46px;
        right: 12px;
        bottom: calc(74px + env(safe-area-inset-bottom));
        font-size: 1.08rem;
        box-shadow: 0 10px 18px rgba(232,67,147,.26);
    }
    .fav-btn-float .fav-badge {
        min-width: 16px;
        height: 16px;
        font-size: .55rem;
    }

    /* Mobile refresh - dashboard visual language */
    .top-header {
        background:
            radial-gradient(circle at top center, rgba(255,255,255,.12), transparent 34%),
            linear-gradient(180deg, rgba(63,24,110,.98), rgba(54,18,98,.96) 58%, rgba(42,16,80,.92));
        border-bottom-color: rgba(255,255,255,.16);
        box-shadow: 0 18px 38px rgba(34,10,72,.22);
    }
    .header-brand {
        padding: 12px 16px 6px;
    }
    .brand-title {
        font-size: clamp(1.44rem, 6.4vw, 1.96rem);
        letter-spacing: .035em;
        text-shadow: 0 4px 18px rgba(28,8,56,.28);
    }
    .brand-sub {
        font-size: .62rem;
        letter-spacing: .09em;
        opacity: .84;
    }
    .header-nav-row {
        padding: 6px 14px 14px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    .mobile-header-left {
        gap: 5px;
        padding: 5px;
        border-radius: 24px;
        background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.05));
        border-color: rgba(255,255,255,.18);
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.16),
            0 10px 22px rgba(24,6,48,.12);
    }
    .mobile-header-home-btn,
    .mobile-menu-btn,
    .header-icon-btn {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 14px;
        font-size: 1.06rem;
    }
    .header-auth {
        gap: 10px;
        align-items: center;
        flex: 1 1 auto;
    }
    #auth-toolbar {
        gap: 8px !important;
    }
    .header-btn-outline,
    .header-btn-filled {
        min-height: 44px;
        min-width: 110px;
        border-radius: 22px;
        font-size: .82rem;
        font-weight: 700;
        letter-spacing: .01em;
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.14),
            0 14px 26px rgba(26,8,52,.14);
    }
    .header-btn-outline {
        background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
        border-color: rgba(255,255,255,.18);
        color: rgba(255,255,255,.95);
    }
    .header-btn-filled {
        background: linear-gradient(135deg, #d89d2f, #f2bb51);
        border-color: rgba(255,255,255,.22);
        color: #4f2c00;
    }
    #user-logged-in {
        grid-template-columns: minmax(0, 1fr) 48px;
        gap: 8px !important;
    }
    #user-display-name {
        min-height: 48px;
        max-width: 72px;
        padding: 0 8px;
        border-radius: 22px;
        border-color: rgba(255,255,255,.18);
        background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.05));
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.16),
            0 10px 22px rgba(24,6,48,.12);
    }
    #user-display-name > span {
        justify-content: center;
    }
    body.user-authenticated #user-logged-in {
        grid-template-columns: minmax(0, 84px) 48px;
    }
    body.user-authenticated #user-logged-in .header-btn-outline {
        min-width: 48px;
        width: 48px;
        border-radius: 16px;
    }

    body[data-page="dashboard"] .main-content {
        background: transparent;
        border-right: none;
    }
    body[data-page="dashboard"] .scenic-bg {
        filter: brightness(.9) saturate(1.04);
    }
    body[data-page="dashboard"] .scenic-bg::after {
        background: linear-gradient(180deg,
            rgba(86,36,142,.56) 0%,
            rgba(153,118,205,.22) 24%,
            rgba(240,230,255,.52) 58%,
            rgba(245,239,255,.8) 100%);
    }
    body[data-page="dashboard"] .page {
        background: transparent;
    }
    body[data-page="dashboard"] #page-dashboard {
        position: relative;
        padding-bottom: 136px;
    }
    body[data-page="dashboard"] #dashboard-content {
        gap: 18px;
    }
    body[data-page="dashboard"] #dashboard-content > .liturgical-today-widget { order: 1; }
    body[data-page="dashboard"] #dashboard-content > .dashboard-category-grid { order: 2; }
    body[data-page="dashboard"] #dashboard-content > .dashboard-search-row { order: 3; }
    body[data-page="dashboard"] #dashboard-content > .dashboard-alpha-bar { order: 4; }
    body[data-page="dashboard"] #dashboard-content > .filter-tabs { order: 5; }
    body[data-page="dashboard"] #dashboard-content > .song-list-header { order: 6; }
    body[data-page="dashboard"] #dashboard-content > .song-list { order: 7; }

    body[data-page="dashboard"] .liturgical-today-widget {
        position: relative;
        padding: 18px 16px 18px !important;
        gap: 10px !important;
        margin-bottom: 0 !important;
        border: 1px solid rgba(255,255,255,.72) !important;
        border-left: 1px solid rgba(255,255,255,.72) !important;
        border-radius: 32px !important;
        background:
            radial-gradient(circle at 16% 20%, rgba(255,227,165,.34), transparent 20%),
            radial-gradient(circle at 82% 84%, rgba(255,255,255,.6), transparent 26%),
            linear-gradient(180deg, rgba(255,255,255,.84), rgba(255,255,255,.68)) !important;
        box-shadow:
            0 22px 44px rgba(76,36,124,.11),
            inset 0 1px 0 rgba(255,255,255,.84) !important;
        overflow: hidden;
        isolation: isolate;
    }
    body[data-page="dashboard"] .liturgical-today-widget::before {
        content: '';
        position: absolute;
        inset: auto 0 0 0;
        height: 52%;
        background:
            radial-gradient(circle at 18% 100%, rgba(255,255,255,.82), transparent 28%),
            radial-gradient(circle at 48% 100%, rgba(255,255,255,.74), transparent 34%),
            radial-gradient(circle at 76% 100%, rgba(255,255,255,.86), transparent 28%);
        opacity: .92;
        pointer-events: none;
        z-index: 0;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div {
        position: relative;
        z-index: 1;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:first-child {
        width: 60px;
        font-size: 2.28rem !important;
        line-height: 1;
        margin-top: 2px;
        text-shadow: 0 8px 22px rgba(214,156,41,.34);
        filter: drop-shadow(0 10px 22px rgba(214,156,41,.22));
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:nth-child(2) {
        flex: 1 1 calc(100% - 72px) !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:nth-child(2) > div:first-child {
        margin-bottom: 4px !important;
        font-size: .74rem !important;
        font-weight: 800 !important;
        text-transform: none !important;
        letter-spacing: .01em !important;
        color: #ca912d !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:nth-child(2) > div:nth-child(2) {
        margin-bottom: 8px !important;
        font-size: 1.14rem !important;
        font-weight: 800 !important;
        line-height: 1.08 !important;
        letter-spacing: -.01em;
        color: #3d235f !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:nth-child(2) > div:last-child {
        gap: 8px !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:nth-child(2) > div:last-child > span {
        font-size: .82rem !important;
        color: rgba(79,57,108,.76) !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:nth-child(2) > div:last-child > span strong {
        color: #cb922f !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:last-child {
        width: 100%;
        padding-left: 0 !important;
        margin-top: 4px;
        justify-content: flex-start !important;
        align-items: stretch !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:last-child > button:first-child {
        min-height: 46px;
        min-width: 148px;
        padding: 0 24px !important;
        border-radius: 20px !important;
        align-self: flex-start;
        background: linear-gradient(135deg, #d59a31, #efb54d) !important;
        box-shadow:
            inset 0 1px 0 rgba(255,255,255,.38),
            0 14px 26px rgba(211,155,54,.22);
        color: #fff !important;
        font-size: .92rem !important;
        font-weight: 800 !important;
    }
    body[data-page="dashboard"] .liturgical-today-widget > div:last-child > button:last-child {
        display: none !important;
    }

    body[data-page="dashboard"] .dashboard-category-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 14px 12px;
        margin-top: 2px;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-btn {
        min-height: 106px;
        padding: 13px 8px 11px;
        gap: 8px;
        border-radius: 24px;
        background: linear-gradient(180deg, rgba(255,255,255,.76), rgba(255,255,255,.58));
        border: 1px solid rgba(255,255,255,.78);
        box-shadow:
            0 18px 34px rgba(74,32,120,.08),
            inset 0 1px 0 rgba(255,255,255,.84);
    }
    .dashboard-category-grid .cat-icon-btn[data-cat="duc-me"] {
        display: none;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-inner {
        width: auto;
        height: auto;
        margin: 0;
        border: none;
        border-radius: 0;
        background: transparent !important;
        box-shadow: none;
        font-size: 1.6rem;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-inner::before {
        display: none;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-label {
        max-width: none;
        font-size: .7rem;
        font-weight: 700;
        color: #4b2b74;
        line-height: 1.2;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-btn[data-cat="ca-tiep-lien"] .cat-icon-label,
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-btn[data-cat="dang-le-vat"] .cat-icon-label {
        font-size: .64rem;
    }

    body[data-page="dashboard"] .dashboard-search-row {
        margin: 0;
        margin-top: 18px;
        margin-bottom: 12px;
    }
    body[data-page="dashboard"] .dashboard-search-row .search-input-wrap {
        position: relative;
    }
    body[data-page="dashboard"] .dashboard-search-row .search-input {
        min-height: 56px;
        padding-left: 54px;
        border-radius: 24px;
        border: 1px solid rgba(255,255,255,.78);
        background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.62));
        box-shadow:
            0 18px 36px rgba(74,32,120,.08),
            inset 0 1px 0 rgba(255,255,255,.82);
        font-size: .98rem;
    }
    body[data-page="dashboard"] .dashboard-search-row .search-icon-inner {
        left: 20px;
        font-size: 1.08rem;
        color: rgba(103,76,150,.46);
    }

    body[data-page="dashboard"] .dashboard-alpha-bar {
        display: none;
    }
    body[data-page="dashboard"] .dashboard-week-title {
        display: none;
    }

    body[data-page="dashboard"] .filter-tabs {
        display: none;
    }
    body[data-page="dashboard"] .song-list {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 2px 0 0;
    }
    body[data-page="dashboard"] .song-row {
        padding: 15px 16px;
        border-radius: 22px;
        border: 1px solid rgba(255,255,255,.72);
        background: linear-gradient(180deg, rgba(255,255,255,.74), rgba(255,255,255,.56));
        box-shadow:
            0 14px 30px rgba(74,32,120,.07),
            inset 0 1px 0 rgba(255,255,255,.82);
    }
    body[data-page="dashboard"] .song-name {
        font-size: .96rem;
    }

    body[data-page="dashboard"] .fav-btn-float {
        width: 58px;
        height: 58px;
        right: 16px;
        bottom: calc(136px + env(safe-area-inset-bottom));
        font-size: 1.24rem;
        border: 1px solid rgba(255,255,255,.58);
        box-shadow:
            0 22px 34px rgba(226,61,146,.26),
            inset 0 1px 0 rgba(255,255,255,.32);
    }
    body[data-page="dashboard"] .fav-btn-float .fav-badge {
        min-width: 20px;
        height: 20px;
        top: -5px;
        right: -2px;
        font-size: .68rem;
    }

    .mobile-bottom-nav {
        height: 68px;
        padding: 0 8px;
        background:
            linear-gradient(180deg, rgba(41,14,79,.94), rgba(33,10,62,.98));
        backdrop-filter: blur(14px);
        box-shadow: 0 -8px 22px rgba(20,0,50,.18);
    }
    .mobile-nav-item {
        gap: 5px;
        padding: 7px 2px 6px;
    }
    .mobile-nav-icon {
        font-size: 1.38rem;
    }
    .mobile-nav-label {
        font-size: .7rem;
        font-weight: 700;
    }
}

/* --------- Small phones (≤ 400px) --------- */
@media (max-width: 400px) {
    .song-list {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .brand-title { font-size: 1.34rem; }
    .brand-sub {
        font-size: .6rem;
        max-width: 100%;
    }
    .mobile-nav-label { font-size: .56rem; }
    .page-title { font-size: var(--fs-base); }

    /* Fluid padding for very small phones */
    .page { padding: 8px; }
    .header-brand { padding: 8px 12px 2px; }
    .header-nav-row {
        padding: 4px 12px 10px;
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 8px;
    }
    .liturgical-today-widget > div:last-child {
        padding-left: 0;
    }
    .category-icons-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px 4px;
    }
    body[data-page="dashboard"] .dashboard-category-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px 8px;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-btn {
        min-height: 102px;
        padding: 12px 6px 10px;
        border-radius: 24px;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-inner {
        font-size: 1.48rem;
    }
    body[data-page="dashboard"] .dashboard-category-grid .cat-icon-label {
        font-size: .66rem;
    }
    body[data-page="dashboard"] .dashboard-search-row .search-input {
        min-height: 54px;
        font-size: .96rem;
    }
    .modal { max-height: 95vh; }
    .modal-body { padding: 14px; }
}

@media (max-width: 480px) {
    .header-auth {
        align-items: stretch;
        gap: 8px;
    }
    #auth-toolbar {
        width: auto;
    }
    #user-logged-in {
        width: 100%;
        justify-content: space-between;
    }
    #user-display-name {
        padding: 0 8px;
    }
    body.user-authenticated #user-logged-in {
        grid-template-columns: minmax(0, 68px) 40px;
    }
    #user-display-name {
        max-width: 68px;
    }
    body.user-authenticated #user-logged-in {
        grid-template-columns: minmax(0, 72px) 48px;
    }
    body.user-authenticated #user-logged-in .header-btn-outline {
        min-width: 48px;
        width: 48px;
    }
    #user-display-name {
        max-width: 72px;
    }
    .header-btn-outline,
    .header-btn-filled {
        text-align: center;
        min-width: 96px;
        font-size: .76rem;
    }
    .mobile-slide-menu {
        width: min(88vw, 320px);
    }
    .pdf-qm-header {
        padding: 12px 14px;
    }
    .pdf-qm-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .pdf-qm-title {
        width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .song-list-header,
    .song-row {
        grid-template-columns: minmax(0, 1fr) 96px 120px 72px 88px;
    }
    .song-name {
        font-size: .96rem;
    }
}

/* ============================================================
   FADE/SLIDE ANIMATIONS FOR PAGE TRANSITIONS
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Smooth page transitions */
@media (max-width: 768px) {
    .page.active {
        animation: fadeInScale .25s ease;
    }
}

/* ============================================================
   SAFE AREAS (iPhone notch, etc.)
   ============================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(68px + env(safe-area-inset-bottom));
    }
    .main-content {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
    body[data-page="dashboard"] .main-content {
        padding-bottom: calc(98px + env(safe-area-inset-bottom));
    }
    .top-header {
        padding-top: env(safe-area-inset-top);
    }
}

/* ============================================================
   TOUCH OPTIMIZATIONS
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .action-btn { min-height: 40px; }
    .filter-tab { min-height: 38px; }
    .nav-item { min-height: 42px; }
    
    /* Remove hover effects on touch devices */
    .song-row:hover {
        background: transparent;
        transform: none;
    }
    .song-row:active {
        background: rgba(107,70,150,.06);
    }
    .cat-icon-btn:hover .cat-icon-inner {
        transform: none;
    }
    .cat-icon-btn:active .cat-icon-inner {
        transform: scale(.95);
    }
}

/* ============================================================
   TOUCH PERFORMANCE PROFILE
   ============================================================ */
html.lite-effects {
    --shadow-sm: 0 1px 4px rgba(61,32,102,.06);
    --shadow-md: 0 4px 12px rgba(61,32,102,.1);
    --shadow-lg: 0 10px 24px rgba(61,32,102,.14);
    --tr: .16s ease-out;
}
html.lite-effects .scenic-bg {
    background-attachment: scroll;
    filter: brightness(.76) saturate(.82);
}
html.lite-effects .scenic-bg::after {
    background: linear-gradient(180deg,
        rgba(60,20,100,.5) 0%,
        rgba(90,40,140,.26) 24%,
        rgba(200,180,230,.42) 60%,
        rgba(236,230,246,.92) 100%);
}
html.lite-effects .top-header,
html.lite-effects .main-content,
html.lite-effects .right-sidebar,
html.lite-effects .sidebar,
html.lite-effects .mobile-bottom-nav,
html.lite-effects .mobile-slide-menu,
html.lite-effects .mobile-menu-overlay,
html.lite-effects .pdf-quick-overlay,
html.lite-effects .pdf-qm-header,
html.lite-effects .toast,
html.lite-effects .modal-overlay {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html.lite-effects .page,
html.lite-effects .page.active,
html.lite-effects .modal,
html.lite-effects .pdf-quick-modal,
html.lite-effects .toast {
    animation: none !important;
}
html.lite-effects .header-jesus-wrap {
    opacity: .58;
}
html.lite-effects .pdf-quick-overlay {
    background: rgba(18,8,36,.38);
}
html.lite-effects .pdf-quick-modal {
    box-shadow: 0 -12px 28px rgba(20,0,50,.16);
}
html.lite-effects .mobile-bottom-nav {
    box-shadow: 0 -2px 12px rgba(20,0,50,.18);
}
html.lite-effects .action-btn:hover,
html.lite-effects .rsidebar-link-card:hover,
html.lite-effects .forum-topic-row:hover,
html.lite-effects .stat-card:hover,
html.lite-effects .search-chip:hover,
html.lite-effects .cat-icon-btn:hover .cat-icon-inner {
    transform: none !important;
}
html.lite-effects .song-row,
html.lite-effects .wkd-song-card,
html.lite-effects .massset-choice-card,
html.lite-effects .forum-topic-row,
html.lite-effects .cal-season-group,
html.lite-effects .rsidebar-box,
html.lite-effects .rsidebar-link-card,
html.lite-effects .song-item,
html.lite-effects .liturgical-today-widget {
    content-visibility: auto;
    contain-intrinsic-size: 1px 120px;
}
