#reading-mode-view {
    /* Define base light theme variables */
    --bg-page: #f9f9f9;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --accent: #d4af37;
    /* Metallic Gold */
    --max-reading-width: 800px;

    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5000;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1.125rem;
    overflow-y: auto;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: block;
}

#reading-mode-view.hidden {
    display: none !important;
}

#reading-mode-view[data-theme="dark"] {
    --bg-page: #0f0f13;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --border-color: #3f3f46;
}

#reading-mode-view .reading-container {
    width: 100%;
    max-width: var(--max-reading-width);
    padding: 0 2rem 4rem 2rem;
    position: relative;
    margin: 0 auto;
}

#reading-mode-view .reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-top: 2rem;
    padding-bottom: 1rem;
    position: sticky;
    top: 0;
    background-color: var(--bg-page);
    z-index: 10;
    transition: background-color 0.3s ease;
}

#reading-mode-view .book-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent);
    margin: 0;
}

#reading-mode-view .header-controls {
    display: flex;
    gap: 1rem;
}

#reading-mode-view .control-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.2s;
}

#reading-mode-view .control-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#reading-mode-view .index-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-page);
    z-index: 5100;
    display: none;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

#reading-mode-view .index-overlay.active {
    display: flex;
}

#reading-mode-view .index-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--max-reading-width);
    margin: 0 auto 2rem auto;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

#reading-mode-view .reading-index-list {
    list-style: none;
    max-width: var(--max-reading-width);
    margin: 0 auto;
    width: 100%;
}

#reading-mode-view .index-item {
    margin-bottom: 1rem;
}

#reading-mode-view .index-link {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    transition: color 0.2s;
    display: block;
    padding: 0.5rem 0;
}

#reading-mode-view .index-link:hover {
    color: var(--accent);
}

#reading-mode-view .book-content {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    outline: none;
}

#reading-mode-view .chapter-section {
    min-height: 50vh;
}

#reading-mode-view .chapter-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--accent);
}

#reading-mode-view .chapter-text p,
#reading-mode-view .chapter-text div {
    margin-bottom: 1.5rem;
    text-align: justify;
}

#reading-mode-view .chapter-text>*:first-child::first-letter {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--accent);
    float: left;
    line-height: 1;
    margin-right: 0.5rem;
}

@media (max-width: 600px) {
    #reading-mode-view .reading-container {
        padding: 2rem 1rem;
    }

    #reading-mode-view .book-title {
        font-size: 1.5rem;
    }

    #reading-mode-view .chapter-title {
        font-size: 2rem;
    }
}