/* Basic Reset & Typography */
body {
    font-family: 'Hind Siliguri', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.font-serif {
    font-family: 'Playfair Display', serif;
}

.hidden { display: none !important; }

/* Theme Variables */
:root {
    --bg-color: #f3f4f6;
    --book-bg: #ffffff;
    --text-color: #1f2937;
    --toolbar-bg: rgba(255, 255, 255, 0.9);
    --highlight-color: rgba(255, 235, 59, 0.5);
}

body.theme-sepia {
    --bg-color: #eaddca;
    --book-bg: #f9f4e8;
    --text-color: #5b4636;
    --toolbar-bg: rgba(249, 244, 232, 0.9);
    --highlight-color: rgba(255, 200, 100, 0.5);
}

body.theme-dark {
    --bg-color: #121212;
    --book-bg: #1e1e1e;
    --text-color: #d1d5db;
    --toolbar-bg: rgba(30, 30, 30, 0.9);
    --highlight-color: rgba(59, 130, 246, 0.3);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

#toolbar, #bottom-nav {
    background-color: var(--toolbar-bg);
}

#book-wrapper {
    background-color: var(--book-bg);
    color: var(--text-color);
}

/* ========================= Library View ========================= */
#library-view {
    min-height: 100vh;
    padding: 3rem 1.5rem 4rem;
    max-width: 1100px;
    margin: 0 auto;
}

.library-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.75rem;
}

.book-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    border-radius: 0.75rem;
    overflow: hidden;
    background-color: var(--book-bg, #fff);
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.book-card-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background-color: #e5e7eb;
}

.book-card-body {
    padding: 0.9rem 1rem 1.1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-card-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    color: #1f2937;
}

.book-card-author {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.6rem;
}

.book-card-progress-wrap {
    margin-top: auto;
}

.book-card-progress-bar-bg {
    width: 100%;
    height: 4px;
    background-color: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.book-card-progress-bar-fill {
    height: 100%;
    background-color: #3b82f6;
    border-radius: 999px;
}

.book-card-progress-label {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 0.3rem;
}

/* Book Content Styling */
#book-content {
    font-size: 18px;
    line-height: 1.8;
    text-align: justify;
}

#book-content h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
}

#book-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

#book-content p {
    margin-bottom: 1.5rem;
    text-indent: 2em;
}

#book-content p:first-of-type::first-letter {
    font-family: 'Playfair Display', serif;
    font-size: 3em;
    float: left;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.1em;
    font-weight: bold;
}

/* Pagination Mode Styling */
#book-content.mode-page {
    column-count: 1;
    column-gap: 40px;
    height: 100%;
    overflow: hidden;
    transition: transform 0.3s ease-in-out;
}

/* Scroll Mode Styling */
#book-content.mode-scroll {
    column-count: auto;
    height: 100%;
    overflow-y: auto;
    transition: none;
    padding-right: 1rem;
}

/* Custom Scrollbar */
#book-content.mode-scroll::-webkit-scrollbar {
    width: 6px;
}
#book-content.mode-scroll::-webkit-scrollbar-track {
    background: transparent;
}
#book-content.mode-scroll::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

/* Highlight Styling */
mark.custom-highlight {
    background-color: var(--highlight-color);
    color: inherit;
    cursor: pointer;
    border-radius: 2px;
    padding: 0 2px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #book-content {
        font-size: 16px;
        padding: 1.5rem !important;
    }
    #book-content h1 {
        font-size: 2rem;
    }
    #book-wrapper {
        margin: 0.5rem;
        width: calc(100% - 1rem);
        height: 85vh !important;
    }
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1.1rem;
    }
}

/* Active state for sidebar buttons */
.theme-btn.active, .mode-btn.active {
    border-color: #3b82f6;
    background-color: #eff6ff;
    color: #3b82f6;
}