/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Shikshapatri-aligned palette */
    --bg-primary: #E6A623;          /* Golden Yellow */
    --bg-secondary: #F7C844;        /* Medium Yellow */
    --color-royal-blue: #A5252C;    /* Deep Red */
    --color-electric-blue: #E65100; /* Burnt Orange */
    --color-gold: #A5252C;
    --color-light-gold: #A5252C;
    --color-amber: #E65100;
    --color-saffron-light: #E65100;
    --color-text-main: #2c2c2c;
    --color-text-muted: #5d4e75;

    /* Legacy aliases kept so existing rules still resolve */
    --primary-color: #E65100;
    --secondary-color: #A5252C;
    --text-color: #2c2c2c;
    --text-light: #5d4e75;

    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(165, 37, 44, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.12);
    --glass-blur: blur(16px);
    --gold-border-glow: rgba(165, 37, 44, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Noto Sans Gujarati', 'Roboto', -apple-system, BlinkMacSystemFont, 'Poppins', sans-serif;
    background-color: #E6A623;
    background-image: linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.2)), url('../images/thakorji-maharaj-bg.jpg');
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    color: var(--color-text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-x: hidden;
    font-weight: 400;
    line-height: 1.6;
    touch-action: manipulation;
}

body.reading-screen {
    background-color: #E6A623;
    background-image: url('../images/yellow-bg.webp');
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
}

/* Header — full-bleed PWA navbar (extends behind iOS status bar) */
header {
    position: fixed;
    top: 0;
    width: 100%;
    height: 58px;
    background: #E6A623;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    z-index: 10000;
    border-bottom: none;
}

#navbar-logo {
    height: 51px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#back-btn {
    position: absolute;
    left: 20px;
    background: transparent;
    color: #A5252C;
    /* Gold */
    border: none;
    padding: 8px;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.5rem;
    /* Increased size slightly since circle is gone */
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: none;
}

#back-btn:hover {
    transform: scale(1.1);
    box-shadow: none;
    color: #E65100;
}

/* Segmented Header Language Selector */
.header-lang-switch {
    position: absolute;
    right: 12px;
    display: flex;
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(165, 37, 44, 0.2);
    border-radius: 11px;
    padding: 2px;
    gap: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.lang-btn {
    background: transparent;
    border: none;
    color: #A5252C;
    padding: 2px 6px;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.3px;
}

.lang-btn:hover {
    background: rgba(165, 37, 44, 0.05);
}

.lang-btn.active {
    background: #A5252C;
    color: #FFFFFF;
    box-shadow: 0 1px 4px rgba(165, 37, 44, 0.25);
}

main {
    flex: 1;
    padding: 82px 16px 110px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.screen {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Glass Card Mixin Style */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
}

/* Chapter Grid (Home Screen) */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 5px 0;
}

@media (max-width: 700px) {
    .chapter-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Chapter Tile - Matching Gita Gyan Layout */
.chapter-tile {
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.4), rgba(165, 37, 44, 0.1));
    /* Golden Glass */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 16px 16px 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 25px rgba(139, 90, 43, 0.15);
    position: relative;
    overflow: visible;
    min-height: 130px;
    display: flex;
    flex-direction: column;
}

.chapter-tile::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at top right, rgba(255, 180, 80, 0.25), transparent 70%);
    pointer-events: none;
}

.chapter-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(139, 90, 43, 0.25);
    border-color: rgba(165, 37, 44, 0.6);
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.5), rgba(165, 37, 44, 0.2));
}

.chapter-tile:active {
    transform: translateY(-2px);
}

/* Number circle on left edge */
.chapter-number {
    position: absolute;
    top: 16px;
    left: 14px;
    background: linear-gradient(135deg, #FFB300, #FF8F00);
    color: #2C1D18;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 3px 12px rgba(255, 179, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.6);
    padding-top: 2px;
    /* Visual centering */
}

/* Header row with title and count */
.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    margin-left: 44px;
    padding-top: 5px;
    min-height: 36px;
}

/* Main title (Gujarati/Sanskrit) */
.chapter-name {
    color: #A5252C;
    font-weight: 700;
    font-size: 1.35rem;
    font-family: 'Noto Sans Gujarati', sans-serif;
    line-height: 1.2;
    margin: 0;
    flex: 1;
}

/* Count badge on same row as title */
.chapter-count {
    background: rgba(255, 200, 100, 0.5);
    color: #A5252C;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Description below title row */
.chapter-description {
    color: #2C1D18;
    font-size: 0.95rem;
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* Section Header Card (Section Detail Screen) */
.section-header-card {
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.4), rgba(165, 37, 44, 0.1));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 25px rgba(139, 90, 43, 0.15);
    text-align: center;
    position: relative;
}

.section-header-card #section-title {
    color: #A5252C;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    font-family: 'Noto Sans Gujarati', sans-serif;
    text-shadow: none;
}

.section-header-card #section-description {
    color: #2C1D18;
    font-size: 1.15rem;
    line-height: 1.6;
    margin-bottom: 0;
    /* Removed bottom margin */
}

.section-image-container {
    width: 100%;
    margin: 15px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(139, 90, 43, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.section-image {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: cover;
    display: block;
}

/* Vachanamrut Grid (Section Detail Screen) */
.vachanamrut-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Vachanamrut Tile (in grid) */
.vachanamrut-tile {
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.4), rgba(165, 37, 44, 0.1));
    /* Golden Glass */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid rgba(165, 37, 44, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(139, 90, 43, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
}

.vachanamrut-tile:hover {
    transform: translateX(4px);
    box-shadow: 0 8px 25px rgba(139, 90, 43, 0.2);
    border-color: rgba(165, 37, 44, 0.6);
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.5), rgba(165, 37, 44, 0.2));
}

.vachanamrut-tile:active {
    transform: translateX(2px);
}

.vachanamrut-tile-number {
    background: linear-gradient(135deg, #FFB300, #FF8F00);
    color: #2C1D18;
    min-width: 42px;
    height: 42px;
    border-radius: 50%;
    /* Circular */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 3px 10px rgba(255, 143, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    padding-top: 2px;
    /* Visual centering */
}

.vachanamrut-tile-content {
    flex: 1;
    min-width: 0;
}

.vachanamrut-tile-name {
    color: #A5252C;
    font-weight: 600;
    font-size: 1.3rem;
    font-family: 'Noto Sans Gujarati', sans-serif;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vachanamrut-tile-title {
    color: #2C1D18;
    font-size: 1.05rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vachanamrut-tile-bookmark {
    color: #A5252C;
    font-size: 1rem;
    margin-left: auto;
    flex-shrink: 0;
}

.section-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-card {
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.4), rgba(165, 37, 44, 0.1));
    /* Liquid Gold Gradient */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 16px 20px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 230, 150, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border-color: rgba(165, 37, 44, 0.5);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.section-icon {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    margin-left: 15px;
}

.section-card.active .section-icon {
    transform: rotate(90deg);
}

.vachanamruts-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 10px;
    /* Removed background and overlap for cleaner look */
}

.vachanamruts-dropdown.active {
    max-height: 3000px;
    /* Large enough to fit content */
    padding: 10px;
    margin-top: 10px;
}

.section-name {
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 2.0rem;
    /* Reduced by 10% from 2.2rem */
    margin: 0;
    font-family: 'Noto Sans Gujarati',
        sans-serif;
}

.section-count {
    background: rgba(255, 255, 255, 0.4);
    color: var(--secondary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Vachanamruts list */
#vachanamruts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 0;
}

#section-title {
    text-align: center;
    margin-bottom: 5px;
    /* Reduced gap */
    color: #fff;
    /* Assuming dark background or overlay, but with glass UI we might want dark text? User said transparent UI. */
    /* Actually, if the background is an image, the title outside cards should probably be white with shadow for contrast */
    color: var(--secondary-color);
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.5);
    font-family: 'Noto Sans Gujarati', sans-serif;
}

.vachanamrut-item {
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.4), rgba(165, 37, 44, 0.1));
    /* Liquid Gold Gradient */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
}

.vachanamrut-item:hover {
    transform: scale(1.01);
    background: rgba(255, 230, 150, 0.5);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.vachanamrut-number {
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 40px;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.bookmark-indicator {
    color: var(--secondary-color);
    margin-right: 10px;
    font-size: 0.9rem;
}

.vachanamrut-title {
    color: var(--text-color);
    font-size: 1.05rem;
    font-weight: 500;
    flex: 1;
    margin-left: 15px;
    /* text-align: right; Removed based on user feedback */
}

/* Vachanamrut detail */
.glass-card {
    background: rgba(255, 230, 150, 0.85);
    /* Golden translucent */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(165, 37, 44, 0.3);
    border-radius: 24px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

#vachanamrut-card h3 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    border-bottom: 2px solid rgba(165, 37, 44, 0.1);
    padding-bottom: 15px;
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

.title-content {
    flex: 1;
    text-align: center;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.icon-btn:hover {
    background: rgba(165, 37, 44, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.v-number {
    font-size: 1.6rem;
    color: var(--secondary-color);
}

.v-title-text {
    font-size: 1.2rem;
    color: var(--text-color);
    font-weight: 500;
    display: block;
    margin-top: 5px;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 20px 0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

#vachanamrut-setting {
    background: rgba(230, 81, 0, 0.08);
    border-left: 5px solid var(--primary-color);
    padding: 20px;
    margin: 20px 0;
    border-radius: 0 12px 12px 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-light);
    font-style: italic;
}

.vachanamrut-image-container {
    width: 100%;
    margin: 20px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(230, 81, 0, 0.15);
    border: 1px solid rgba(230, 81, 0, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

.vachanamrut-image {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.vachanamrut-image:hover {
    transform: scale(1.02);
}

.sanskrit-verses-container {
    background: rgba(230, 81, 0, 0.03);
    border: 1.5px dashed rgba(230, 81, 0, 0.3);
    padding: 20px;
    margin: 20px 0;
    border-radius: 12px;
    text-align: left;
    box-shadow: inset 0 0 10px rgba(230, 81, 0, 0.02);
}

.sanskrit-verses-content {
    font-size: 1.15rem;
    line-height: 2.0;
    color: #4E342E;
    font-family: 'Noto Serif', 'Georgia', serif;
    font-weight: 500;
    font-style: italic;
    white-space: pre-line;
}

#vachanamrut-text {
    font-size: 1.38rem;
    line-height: 1.9;
    color: #000000;
    text-align: justify;
    font-weight: 400;
    font-family: 'Noto Serif', 'Georgia', serif;
}

#vachanamrut-text p {
    margin-bottom: 1.5em;
}

#vachanamrut-footer-text {
    text-align: center;
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.2rem;
    margin-top: 30px;
    margin-bottom: 10px;
    font-family: 'Noto Sans Gujarati', sans-serif;
}

.settings-note {
    font-size: 0.9rem;
    color: #666;
    margin-top: 10px;
}

.settings-version {
    font-size: 0.85rem;
    color: #888;
    margin-top: 20px;
    font-family: monospace;
}

/* Responsive design */
@media (max-width: 768px) {
    header {
        padding: 0 15px;
    }

    #navbar-logo {
        height: 42px;
    }

    main {
        padding: 74px 12px 110px 12px;
    }

    #sections-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .section-card {
        padding: 20px;
    }

    .glass-card {
        padding: 20px;
        border-radius: 20px;
    }

    #vachanamrut-card h3 {
        font-size: 1.3rem;
    }

    #vachanamrut-text {
        font-size: 1.3rem;
        line-height: 1.8;
    }

    .sanskrit-verses-container {
        padding: 15px;
    }

    .sanskrit-verses-content {
        font-size: 1.02rem;
        line-height: 1.8;
    }
}

@media (max-width: 480px) {
    #navbar-logo {
        height: 34px;
    }

    main {
        padding: 70px 10px 110px 10px;
    }

    .section-card {
        padding: 16px;
    }

    .section-name {
        font-size: 1.6rem;
    }

    .glass-card {
        padding: 18px;
        border-radius: 16px;
    }

    #vachanamrut-setting {
        padding: 15px;
        font-size: 0.95rem;
    }

    #vachanamrut-text {
        font-size: 1.25rem;
        line-height: 1.75;
    }

    .sanskrit-verses-container {
        padding: 12px;
        margin: 12px 0;
    }

    .sanskrit-verses-content {
        font-size: 0.88rem;
        line-height: 1.6;
    }
}

footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: #E6A623;
    /* Match Header Color */
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: #A5252C;
    /* Red Text */
    text-align: center;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)) 4px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 10000; /* Match header z-index */
    border-top: 1px solid rgba(165, 37, 44, 0.3);
    /* Match Header Border style */
    /* Hidden by default, toggled by JS */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0); /* Forces hardware-accelerated layer in Safari to resolve stacking bugs */
}

/* Floating Action Button */
.fab-btn {
    position: fixed;
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    /* Moved up 10px and respect safe area */
    right: 10px;
    width: 53px;
    /* Increased by ~20% (44 * 1.2) */
    height: 53px;
    /* Increased by ~20% */
    border-radius: 50%;
    background: #E6A623;
    color: #A5252C;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 1.3rem;
    /* Increased font size slightly */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.fab-btn:active {
    transform: scale(0.95);
}

/* Expandable FAB Menu */
.fab-menu {
    position: fixed;
    bottom: calc(105px + env(safe-area-inset-bottom, 0px));
    /* Adjusted for larger FAB and respect safe area */
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-menu.active {
    pointer-events: all;
    opacity: 1;
    transform: translateY(0);
}

.fab-sub-btn {
    width: 53px;
    /* Match main FAB */
    height: 53px;
    /* Match main FAB */
    border-radius: 50%;
    background: #E6A623;
    color: #A5252C;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 1.3rem;
    /* Match main FAB font size */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.fab-sub-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.fab-sub-btn:active {
    transform: scale(0.95);
}

/* Favourites Screen */
#favourites-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

#no-favourites-msg {
    text-align: center;
    color: var(--text-color);
    font-size: 1.1rem;
    margin-top: 50px;
    opacity: 0.7;
}

.fav-card {
    background: linear-gradient(135deg, rgba(255, 230, 150, 0.4), rgba(165, 37, 44, 0.1));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.fav-card:hover {
    transform: scale(1.01);
    background: rgba(255, 230, 150, 0.5);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.fav-number {
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 5px;
    font-family: 'Noto Sans Gujarati', sans-serif;
}

.fav-title {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* Settings Screen */
.screen-title {
    text-align: center;
    color: var(--secondary-color);
    font-size: 1.8rem;
    font-weight: 700;
    margin: 20px 0;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.5);
    font-family: 'Noto Sans Gujarati', sans-serif;
}

.settings-card {
    margin: 20px;
}

.language-select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-family: 'Noto Sans Gujarati', 'Poppins', sans-serif;
    border: 2px solid rgba(165, 37, 44, 0.4);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-color);
    margin-bottom: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-select:hover {
    border-color: var(--secondary-color);
    background: rgba(255, 255, 255, 1);
}

.language-select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.danger-zone-label {
    color: #dc2626;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 15px 0 10px 0;
}

.settings-note {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.primary-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
    transition: all 0.3s ease;
    width: 100%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: translateY(0);
}

.danger-btn {
    background: #E65100;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.3);
    transition: all 0.3s ease;
}

.danger-btn:hover {
    background: #A5252C;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(165, 37, 44, 0.4);
}

/* Danger Zone Redesign */
.settings-centered {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.settings-header-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 5px;
}

.settings-header-badge h3 {
    margin: 0;
    border: none;
    padding: 0;
    font-size: 1.4rem;
}

.danger-badge {
    background: rgba(211, 47, 47, 0.1);
    color: #E65100;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    border: 1px solid rgba(211, 47, 47, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.danger-btn-subtle {
    background: transparent;
    color: #C62828;
    border: 1px solid rgba(198, 40, 40, 0.3);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 15px;
}

.danger-btn-subtle:hover {
    background: rgba(198, 40, 40, 0.05);
    border-color: #C62828;
}

/* Heart Button */
.heart-btn {
    position: absolute;
    left: 0;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: #E65100;
    /* Red */
}

.heart-btn:hover {
    background: rgba(211, 47, 47, 0.1);
}

/* Adjust title container for heart button */
.title-container {
    padding: 0 40px;
    /* Make space for buttons on both sides */
}

/* Language Toggle Switch */
.language-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
}

.lang-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-color);
    cursor: pointer;
    transition: color 0.3s ease;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(165, 37, 44, 0.2);
    /* Light red default */
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(165, 37, 44, 0.3);
}

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

input:checked+.slider {
    background-color: var(--primary-color);
    /* Orange/Gold */
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

/* Language specific adjustments */
body.english .chapter-description {
    font-size: 1.05rem;
    /* Slightly larger for English */
    line-height: 1.6;
}

body.gujarati .chapter-description {
    font-size: 1.0rem;
    line-height: 1.5;
}

/* Reading Page Sticky Footer */
.reading-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    background: linear-gradient(135deg, rgba(230, 166, 35, 0.95), rgba(255, 143, 0, 0.95));
    /* Yellow/Orange */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 25px 25px 0 0;
    padding: 15px 30px calc(20px + env(safe-area-inset-bottom, 0px)) 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 10005; /* Must be higher than header and standard footer */
    /* Above FAB */
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0); /* Forces hardware-accelerated layer in Safari to resolve stacking bugs */
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(165, 37, 44, 0.2);
    color: #A5252C;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.nav-btn:hover {
    background: rgba(165, 37, 44, 0.1);
    transform: scale(1.1);
}

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

.slider-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.reading-progress {
    color: #2C1D18;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: monospace;
}

.nav-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(165, 37, 44, 0.2);
    border-radius: 3px;
    outline: none;
    transition: opacity .2s;
}

.nav-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #A5252C;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
}



/* Media Settings */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(165, 37, 44, 0.1);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item span {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Container for Audio Player (handles both FAB and Bar states) */
.audio-player-container {
    position: fixed;
    z-index: 10000;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* FAB State Styling */
.audio-player-container.state-fab {
    right: 16px;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px)); /* Positioned above reading-footer */
    width: 54px;
    height: 54px;
}

@keyframes fab-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(165, 37, 44, 0.4), 0 0 0 0 rgba(165, 37, 44, 0.3);
    }
    70% {
        box-shadow: 0 4px 15px rgba(165, 37, 44, 0.4), 0 0 0 8px rgba(165, 37, 44, 0);
    }
    100% {
        box-shadow: 0 4px 15px rgba(165, 37, 44, 0.4), 0 0 0 0 rgba(165, 37, 44, 0);
    }
}

.audio-player-container.state-fab.is-playing .audio-fab-view {
    animation: fab-pulse 2s infinite;
    background: linear-gradient(135deg, #E53935, #A5252C); /* Crimson gradient when playing */
    border-color: rgba(255, 255, 255, 0.3);
}

.audio-fab-view {
    width: 100%;
    height: 100%;
    background: #E6A623;
    border: 1px solid rgba(165, 37, 44, 0.25);
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    border-radius: 50%; /* ROUND FAB */
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    margin: 0;
    position: relative;
}

.audio-fab-view:hover {
    background: linear-gradient(135deg, #FFD54F, #FFA000);
}

.audio-fab-view:active {
    transform: scale(0.95);
}

/* FAB progress ring */
.audio-fab-progress {
    position: absolute;
    top: -1px;
    left: -1px;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    transform: rotate(-90deg);
    pointer-events: none;
    z-index: 3;
}

.audio-fab-progress-circle {
    stroke: #E6A623; /* High contrast yellow/gold progress indicator circle */
    stroke-dasharray: 150.8;
    stroke-dashoffset: 150.8;
    transition: stroke-dashoffset 0.15s linear;
}

/* Make sure play/music icon is on top of progress circle */
.audio-fab-view i {
    position: relative;
    z-index: 4;
}

/* Bar State Styling */
.audio-player-container.state-bar {
    left: 16px;
    right: 16px;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 238, 185, 0.95); /* Opaque warm golden glass */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(165, 37, 44, 0.25);
    border-radius: 8px; /* SQUARE WITH MINIMAL ROUNDED BORDERS */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: visible; /* Prevent scrubber thumb clipping! */
}

.audio-player-container.state-fab.no-footer,
.audio-player-container.state-bar.no-footer {
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

/* Toggle visibility based on state */
.audio-player-container.state-fab .audio-fab-view {
    display: flex;
}
.audio-player-container.state-fab .audio-bar-view {
    display: none;
}

.audio-player-container.state-bar .audio-fab-view {
    display: none;
}
.audio-player-container.state-bar .audio-bar-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: visible; /* Prevent scrubber thumb clipping! */
}

/* Inset scrubber layout for spacing */
.audio-scrubber-layout {
    padding: 8px 16px 2px 16px; /* Spacing so it doesn't touch edges */
    width: 100%;
    box-sizing: border-box;
    overflow: visible; /* Prevent scrubber thumb clipping! */
}

.audio-scrubber-container {
    width: 100%;
    height: 24px; /* Increased height for touch hit target */
    position: relative;
    cursor: pointer;
    overflow: visible; /* Prevent scrubber thumb clipping! */
}

/* Background visual track background */
.audio-scrubber-container::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 10px; /* Center 4px track: (24 - 4) / 2 = 10px */
    height: 4px;
    background: rgba(165, 37, 44, 0.15);
    border-radius: 2px;
}

/* Custom styled input range for progress scrubbing */
.audio-progress-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 100%; /* Spans full 24px height */
    background: transparent;
    margin: 0;
    padding: 0;
    cursor: pointer;
    outline: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

/* Progress track styling */
.audio-progress-bar::-webkit-slider-runnable-track {
    width: 100%;
    height: 100%;
    background: transparent;
}

/* Scrubber thumb styling (ROUND) */
.audio-progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%; /* ROUND THUMB */
    background: #A5252C;
    margin-top: 5px; /* Center 14px thumb in 24px track: (24 - 14) / 2 = 5px */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    transition: transform 0.1s ease;
}

.audio-progress-bar:hover::-webkit-slider-thumb {
    transform: scale(1.2);
}

/* Mozilla Firefox styling for range input */
.audio-progress-bar::-moz-range-track {
    width: 100%;
    height: 100%;
    background: transparent;
}
.audio-progress-bar::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%; /* ROUND THUMB */
    background: #A5252C;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 1px solid white;
}

.audio-bar-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    gap: 12px;
}

.audio-bar-info {
    flex: 1;
    min-width: 0;
}

.audio-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #5D1A1A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.audio-bar-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.audio-bar-btn {
    background: transparent;
    border: none;
    color: #A5252C;
    font-size: 1.15rem;
    width: 32px;
    height: 32px;
    border-radius: 50%; /* ROUNDED BUTTONS FOR HOVER */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.audio-bar-btn:hover {
    background: rgba(165, 37, 44, 0.08);
}

.audio-bar-btn:active {
    transform: scale(0.95);
}

.audio-bar-btn.play-btn {
    background: #A5252C;
    color: white;
    font-size: 1rem;
    width: 38px;
    height: 38px;
    box-shadow: 0 2px 8px rgba(165, 37, 44, 0.3);
    border-radius: 50%; /* ROUNDED PLAY BUTTON */
}

.audio-bar-btn.play-btn:hover {
    background: #961515;
}

.audio-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.audio-timer {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(93, 26, 26, 0.75);
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}

.audio-bar-btn.close-btn {
    color: rgba(93, 26, 26, 0.5);
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
}

.audio-bar-btn.close-btn:hover {
    color: #A5252C;
    background: rgba(165, 37, 44, 0.05);
}

/* Background visual indicator of audio progress inside container */
.audio-progress-fill {
    position: absolute;
    top: 10px; /* Center 4px fill inside 24px container */
    left: 0;
    height: 4px;
    width: 0%;
    background: #A5252C;
    pointer-events: none;
    border-radius: 2px;
}

.nav-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #A5252C;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
}

/* Scroll Progress Bar */
.scroll-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 1001;
}
.scroll-progress-bar {
    height: 100%;
    width: 0%;
    background: #A5252C; /* Dark Red to pop out against the yellow header */
    transition: width 0.1s ease;
}


/* Reader Toolbar (Font and Theme controls) */
.reader-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;        /* keep facts pill on the same row */
    border-bottom: 1px solid rgba(165, 37, 44, 0.1);
    padding-bottom: 8px;
    margin-bottom: 14px;
    gap: 4px;
}
/* Tighten internal gaps on the smaller groups so everything stays roomy.
   (Icon-only bookmark override lives further down, after the original
   .bookmark-pill rule, so it wins on cascade order.) */
.font-controls { gap: 6px; padding: 0 6px; }
.theme-controls { gap: 4px; padding: 0 6px; }
.font-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 0 8px;
    height: 28px;
    border: 1px solid rgba(165, 37, 44, 0.2);
    box-sizing: border-box;
}
.toolbar-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #A5252C;
    padding: 2px 8px;
    border-radius: 10px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}
.toolbar-btn:hover {
    background: rgba(165, 37, 44, 0.08);
}
.font-size-display {
    font-size: 0.85rem;
    font-weight: 700;
    color: #2C1D18;
    min-width: 40px;
    text-align: center;
}
.theme-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 0 8px;
    height: 28px;
    border: 1px solid rgba(165, 37, 44, 0.2);
    box-sizing: border-box;
}
.theme-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.theme-btn.active {
    border-color: #A5252C;
    transform: scale(1.1);
}
.theme-btn.theme-default {
    background: #FFE696;
}
.theme-btn.theme-sepia {
    background: #F4ECD8;
}
.theme-btn.theme-dark {
    background: #1A1C1E;
}

/* Bookmark Pill Button in Toolbar */
.bookmark-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(165, 37, 44, 0.2);
    color: #A5252C;
    padding: 0 10px;
    height: 28px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    white-space: nowrap;
    flex-shrink: 0;
    box-sizing: border-box;
}
.bookmark-pill:hover {
    background: rgba(165, 37, 44, 0.08);
    border-color: rgba(165, 37, 44, 0.2);
}
.bookmark-pill.active {
    background: #A5252C;
    border-color: #A5252C;
    color: #FFFFFF;
}

/* Always icon-only bookmark pill — keeps the toolbar on a single row.
   Placed AFTER the original .bookmark-pill rule so cascade order wins. */
#bookmark-pill-text { display: none; }
.bookmark-pill {
    width: 28px;
    padding: 0;
    gap: 0;
    justify-content: center;
}

/* Reading Theme overrides for card content */
.glass-card.theme-sepia {
    background: rgba(244, 236, 216, 0.95);
    color: #4E3629;
    border-color: rgba(139, 90, 43, 0.2);
}
.glass-card.theme-sepia .v-number {
    color: #8D6E63 !important; /* Muted brown for sepia number */
}
.glass-card.theme-sepia .v-title-text {
    color: #4E3629 !important; /* Dark sepia for title text */
}
.glass-card.theme-sepia #vachanamrut-text {
    color: #2D1E16;
}
.glass-card.theme-sepia #vachanamrut-setting {
    background: rgba(139, 90, 43, 0.06);
    border-left-color: #8D6E63;
    color: #2C1D18;
}
.glass-card.theme-sepia .bookmark-pill {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(139, 90, 43, 0.2);
    color: #4E3629;
}
.glass-card.theme-sepia .bookmark-pill:hover {
    background: rgba(139, 90, 43, 0.08);
}
.glass-card.theme-sepia .bookmark-pill.active {
    background: #8D6E63;
    border-color: #8D6E63;
    color: #FFFFFF;
}

.glass-card.theme-dark {
    background: rgba(22, 24, 26, 0.98); /* Deep neutral charcoal, highly reader-friendly */
    color: #E2E2E2; /* Soft off-white to reduce eye strain */
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.glass-card.theme-dark #vachanamrut-text {
    color: #D2D2D2;
}
.glass-card.theme-dark .v-title-text {
    color: #E2E2E2 !important; /* Soft white title text in dark mode for readability */
}
.glass-card.theme-dark #vachanamrut-card h3,
.glass-card.theme-dark .v-number,
.glass-card.theme-dark .icon-btn,
.glass-card.theme-dark #vachanamrut-footer-text {
    color: #E6A623 !important; /* Rich amber/gold accent for dark mode */
}
.glass-card.theme-dark #vachanamrut-setting {
    background: rgba(255, 255, 255, 0.04);
    border-left-color: #E6A623;
    color: #B0BEC5;
}
.glass-card.theme-dark .reader-toolbar {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
.glass-card.theme-dark .font-controls,
.glass-card.theme-dark .theme-controls {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}
.glass-card.theme-dark .toolbar-btn {
    color: #E6A623;
}
.glass-card.theme-dark .toolbar-btn:hover {
    background: rgba(230, 166, 35, 0.1);
}
.glass-card.theme-dark .font-size-display {
    color: #E2E2E2;
}
.glass-card.theme-dark .bookmark-pill {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
    color: #E6A623;
}
.glass-card.theme-dark .bookmark-pill:hover {
    background: rgba(230, 166, 35, 0.1);
    border-color: rgba(230, 166, 35, 0.3);
}
.glass-card.theme-dark .bookmark-pill.active {
    background: #E6A623;
    border-color: #E6A623;
    color: #121212;
}

/* Theme overrides for Sanskrit verses container */
.glass-card.theme-sepia .sanskrit-verses-container {
    background: rgba(139, 90, 43, 0.03);
    border-color: rgba(139, 90, 43, 0.25);
}
.glass-card.theme-sepia .sanskrit-verses-content {
    color: #4E3629;
}

.glass-card.theme-dark .sanskrit-verses-container {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(230, 166, 35, 0.3);
}
.glass-card.theme-dark .sanskrit-verses-content {
    color: #B0BEC5;
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 90px; /* Positioned above footer/reading footer */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast-container.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast-message {
    background: rgba(45, 27, 14, 0.95); /* Warm dark brown */
    color: #FFF;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(165, 37, 44, 0.2);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-message i {
    color: #E6A623; /* Gold icon */
}

/* Micro-animations and Transitions */
.chapter-tile, .vachanamrut-tile, .fav-card {
    transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.25s ease, background 0.25s ease;
}

.icon-btn i {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.icon-btn:active i {
    transform: scale(1.3);
}

/* Screen Transitions */
.screen {
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* App Loading Overlay for smooth language transitions */
#app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 248, 225, 0.7); /* Warm translucent backdrop */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#app-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(165, 37, 44, 0.1);
    border-top: 3px solid #A5252C;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-family: 'Poppins', 'Noto Sans Gujarati', sans-serif;
    color: #A5252C;
    font-weight: 600;
    font-size: 0.95rem;
}

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

/* Language-specific visibility toggles */
body.gujarati .lang-eng {
    display: none !important;
}
body.english .lang-guj {
    display: none !important;
}

/* ===========================================================
   Facts Pill Button (sits beside bookmark in reader toolbar)
   =========================================================== */
.facts-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(165, 37, 44, 0.2);
    color: #A5252C;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 0;
}
.facts-pill:hover {
    background: rgba(165, 37, 44, 0.08);
    transform: scale(1.05);
}
.facts-pill:active {
    transform: scale(0.95);
}
.glass-card.theme-sepia .facts-pill {
    background: rgba(165, 37, 44, 0.06);
    color: #6E3F1B;
    border-color: rgba(110, 63, 27, 0.25);
}
.glass-card.theme-sepia .facts-pill:hover {
    background: rgba(110, 63, 27, 0.12);
}
.glass-card.theme-dark .facts-pill {
    background: rgba(255, 255, 255, 0.08);
    color: #F7C844;
    border-color: rgba(247, 200, 68, 0.3);
}
.glass-card.theme-dark .facts-pill:hover {
    background: rgba(247, 200, 68, 0.15);
}

/* ===========================================================
   Facts Modal
   =========================================================== */
.facts-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 29, 24, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: facts-fade-in 0.2s ease-out;
}
.facts-modal-overlay.closing {
    animation: facts-fade-out 0.18s ease-in forwards;
}
@keyframes facts-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes facts-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
.facts-modal {
    width: 100%;
    max-width: 520px;
    height: 85vh;          /* fixed height — content scrolls inside */
    max-height: 720px;     /* cap on large desktops so it doesn't get silly tall */
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    animation: facts-slide-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes facts-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.facts-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(165, 37, 44, 0.2);
    /* Solid (not gradient) so body content can't bleed through the title */
    background: #F7C844;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}
.glass-card.theme-sepia .facts-modal-header {
    background: #E8D7B0;
    border-bottom-color: rgba(110, 63, 27, 0.25);
}
.glass-card.theme-dark .facts-modal-header {
    background: #2A2424;
    border-bottom-color: rgba(247, 200, 68, 0.2);
}
.glass-card.theme-dark .facts-modal-title {
    color: #F7C844;
}
.glass-card.theme-dark .facts-modal-close {
    background: rgba(255, 255, 255, 0.1);
    color: #F7C844;
    border-color: rgba(247, 200, 68, 0.3);
}
.facts-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #A5252C;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.facts-modal-title i {
    font-size: 1rem;
}
.facts-modal-subtitle {
    font-size: 0.85rem;
    font-weight: 500;
    color: #5d4e75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.glass-card.theme-dark .facts-modal-subtitle {
    color: rgba(247, 200, 68, 0.75);
}
.facts-modal-close {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(165, 37, 44, 0.2);
    color: #A5252C;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    padding: 0;
}
.facts-modal-close:hover {
    background: rgba(165, 37, 44, 0.1);
}
.facts-modal-body {
    flex: 1 1 auto;
    min-height: 0; /* required so the flex child can shrink and scroll */
    padding: 16px 20px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Facts content blocks */
.facts-section {
    margin-bottom: 18px;
}
.facts-section:last-child {
    margin-bottom: 4px;
}
.facts-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #A5252C;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.facts-section-title i {
    font-size: 0.85rem;
    opacity: 0.8;
}
.facts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
.fact-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(165, 37, 44, 0.1);
    border-radius: 12px;
}
/* Row variant with a leading 44px decorative icon */
.fact-row-with-icon {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 10px;
}
.fact-row-with-icon .fact-row-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.fact-icon-img {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.08));
}
.fact-icon-fa {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 200, 68, 0.4);
    border: 1px solid rgba(165, 37, 44, 0.15);
    border-radius: 12px;
    color: #A5252C;
    font-size: 1.1rem;
}
.fact-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #5d4e75;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.fact-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: #2c2c2c;
    line-height: 1.4;
}
.fact-value .fact-secondary {
    display: block;
    font-size: 0.8rem;
    color: #5d4e75;
    margin-top: 2px;
    font-weight: 400;
}

/* Cross-reference chips (Shikshapatri / Mandirs / nearby events) */
.facts-xref-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.facts-xref {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(247, 200, 68, 0.18);
    border: 1px solid rgba(230, 81, 0, 0.2);
    border-radius: 10px;
    font-size: 0.85rem;
}
/* ===========================================================
   Authors / Compilers screen
   =========================================================== */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}
/* Each swami sits in a soft glass-tinted box. All photos normalized to 3:4
   portrait so the row reads as a clean set. */
.author-figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 8px;
    padding: 8px 8px 10px;
    /* Opaque frosted glass — matches the app's .glass-card aesthetic */
    background: rgba(255, 230, 150, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(165, 37, 44, 0.25);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    min-width: 0;
}
.author-photo {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: top center;
    display: block;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
}
.author-caption {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.2;
}
.author-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #A5252C;
    word-break: break-word;
}
.author-dates {
    font-size: 0.68rem;
    color: #5d4e75;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.about-vachanamrut-card.glass-card {
    padding: 18px 20px;
    margin-bottom: 24px;
    border-radius: 16px;
}
.about-vachanamrut-title {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #A5252C;
    border-bottom: 1px solid rgba(165, 37, 44, 0.15);
    padding-bottom: 8px;
}
.about-vachanamrut-text {
    font-size: 0.92rem;
    line-height: 1.6;
    color: #2c2c2c;
    margin: 0 0 10px;
}
.about-vachanamrut-text:last-of-type {
    margin-bottom: 14px;
}
.about-vachanamrut-source {
    font-size: 0.78rem;
    color: #5d4e75;
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid rgba(165, 37, 44, 0.1);
}
.about-vachanamrut-source a {
    color: #A5252C;
    text-decoration: none;
    font-weight: 600;
}
.about-vachanamrut-source a:hover { text-decoration: underline; }

@media (max-width: 380px) {
    .authors-grid { gap: 6px; }
    .author-figure { padding: 6px 5px 8px; gap: 6px; }
    .author-name { font-size: 0.7rem; }
    .author-dates { font-size: 0.6rem; }
}

.facts-xref-emoji {
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    /* Apple/Segoe/Noto color emoji */
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.facts-xref-img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    border: 1px solid rgba(230, 81, 0, 0.3);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.facts-xref-text {
    color: #2c2c2c;
    line-height: 1.35;
}
.facts-xref-text strong {
    color: #A5252C;
    font-weight: 700;
}
.facts-xref-delta {
    color: #5d4e75;
    font-size: 0.78rem;
}

/* Questioner chips — compact names only */
.facts-questioners {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.facts-questioner-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(165, 37, 44, 0.18);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #A5252C;
}
.facts-questioner-chip i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.facts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 16px;
    font-size: 0.9rem;
    color: #5d4e75;
    text-align: center;
    line-height: 1.5;
}
.facts-empty i {
    font-size: 1.6rem;
    color: rgba(165, 37, 44, 0.5);
}

/* Lock background scroll while the facts modal is open */
body.facts-modal-open {
    overflow: hidden;
    /* keep layout width stable when the scrollbar disappears */
    padding-right: var(--scrollbar-w, 0);
}

/* Mobile tightening */
@media (max-width: 600px) {
    .facts-modal {
        max-height: 92vh;
        border-radius: 16px;
    }
    .facts-modal-body {
        padding: 14px 16px 18px;
    }
    .fact-value {
        font-size: 0.9rem;
    }
}

/* Glossary in Facts Modal */
.facts-glossary-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.facts-glossary-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(165, 37, 44, 0.12);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.facts-glossary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #A5252C;
}
.facts-glossary-meaning {
    font-size: 0.76rem;
    color: #5d4e75;
    line-height: 1.45;
}