/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --background-color: #ecf0f1;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Amazon Ember', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--card-background);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--secondary-color);
    color: white;
    box-shadow: var(--shadow);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.header-link:hover {
    opacity: 0.9;
}

.header-nav-buttons {
    display: flex;
    gap: 20px;
    margin-left: 20px;
}

.header-nav-btn {
    background: transparent;
    color: white;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
    font-weight: 400;
}

.header-nav-btn:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.logo {
    font-family: 'New York', Baskerville, 'Baskerville Old Face', 'Hoefler Text', Garamond, 'Times New Roman', serif;
    font-size: 1.5rem;
    font-style: normal;
    margin: 0;
    font-weight: 600;
}

.logo-icon {
    height: 36px;
    width: auto;
    border-radius: 6px;
}

/* Breadcrumb Navigation - styled to replace back buttons */
.breadcrumb-nav {
    padding: 0;
    margin-top: 16px;
    margin-bottom: 24px;
}

.breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* First breadcrumb link gets the back arrow */
.breadcrumb-item:first-child .breadcrumb-link::before {
    content: '← ';
}

.breadcrumb-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb-link:hover {
    color: #2980b9;
}

.breadcrumb-separator {
    color: var(--text-light);
    font-size: 0.8rem;
}

.breadcrumb-current {
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 400;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 0 0 40px 0;
}

.hidden {
    display: none !important;
}

/* Books Section */
.books-section {
    padding-top: 20px;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 480px) {
    .books-grid {
        gap: 10px;
    }

    .container {
        padding: 0 12px;
    }
}

@media (min-width: 650px) {
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .container {
        padding: 0 20px;
    }
}

@media (min-width: 900px) {
    .books-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
    }
}

/* Category Detail Section */
.category-detail-section {
    padding-top: 20px;
    animation: fadeIn 0.3s ease;
}

@media (max-width: 768px) {
    .category-detail-section {
        padding-top: 16px;
    }
}

@media (max-width: 480px) {
    .category-detail-section {
        padding-top: 12px;
    }
}

.category-detail-header {
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .category-detail-header {
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    .category-detail-header {
        margin-bottom: 12px;
    }
}

.category-detail-header h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.category-detail-subtitle {
    font-size: 1rem;
    color: var(--text-light);
}

/* All Categories Section */
.all-categories-section {
    padding-top: 20px;
}

.book-card {
    background: var(--card-background);
    border-radius: 8px;
    padding: 16px 16px 20px 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

@media (max-width: 768px) {
    .book-card {
        padding: 12px 12px 16px 12px;
    }
}

@media (max-width: 480px) {
    .book-card {
        padding: 8px 8px 10px 8px;
    }
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--secondary-color);
}

.book-card .book-cover-wrapper {
    max-width: 230px;
    margin: 0 auto 20px auto;
    aspect-ratio: 2/3;
}

.book-cover {
    width: 100%;
    max-width: 230px;
    height: auto;
    aspect-ratio: 2/3;
    object-fit: contain;
    border-radius: 8px;
    margin: 0 auto 20px auto;
    display: block;
}

@media (max-width: 768px) {
    .book-cover {
        max-width: 180px;
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .book-cover {
        max-width: 100%;
        margin-bottom: 8px;
    }
}

.book-card h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: var(--primary-color);
    line-height: 1.3;
}

@media (max-width: 768px) {
    .book-card h3 {
        font-size: 1rem;
        margin-bottom: 4px;
    }
}

@media (max-width: 480px) {
    .book-card h3 {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }
}

.book-card .author {
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .book-card .author {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
}

@media (max-width: 480px) {
    .book-card .author {
        font-size: 0.75rem;
        margin-bottom: 4px;
    }
}

.book-card .meta {
    font-size: 0.85rem;
    color: var(--text-light);
}

@media (max-width: 768px) {
    .book-card .meta {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .book-card .meta {
        font-size: 0.7rem;
    }
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Skeleton Loading Styles */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0px,
        #e8e8e8 40px,
        #f0f0f0 80px
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 4px;
}

.book-cover-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #f0f0f0 0px,
        #e8e8e8 40px,
        #f0f0f0 80px
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 4px;
    z-index: 1;
}

.book-cover-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

.book-cover-wrapper picture {
    display: block;
    width: 100%;
}

.book-cover-wrapper img {
    opacity: 0;
    transition: opacity 0.3s ease-in;
    position: relative;
    z-index: 2;
}

.book-cover-wrapper img.loaded {
    opacity: 1;
}

.illustration-skeleton {
    width: 100%;
    height: 400px;
    background: linear-gradient(
        90deg,
        #f0f0f0 0px,
        #e8e8e8 40px,
        #f0f0f0 80px
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 8px;
    margin: 20px 0;
}

.content-skeleton {
    height: 20px;
    margin: 10px 0;
    background: linear-gradient(
        90deg,
        #f0f0f0 0px,
        #e8e8e8 40px,
        #f0f0f0 80px
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 4px;
}

.content-skeleton.title {
    height: 24px;
    width: 60%;
    margin-bottom: 20px;
}

.content-skeleton.text {
    height: 16px;
    margin: 8px 0;
}

.content-skeleton.text:last-child {
    width: 80%;
}

.error {
    background-color: #fee;
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    color: var(--accent-color);
}

/* Summary Section */
.summary-section {
    animation: fadeIn 0.3s ease;
    background: var(--card-background);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
}

.summary-section > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.summary-section > *:first-child {
    padding-top: 16px;
}

.summary-section > *:last-child {
    padding-bottom: 40px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.back-button {
    background: transparent;
    color: var(--secondary-color);
    border: none;
    padding: 8px 0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 500;
}

.back-button-container {
    margin-top: 16px;
    margin-bottom: 24px;
}

.back-button:hover {
    color: #2980b9;
}

/* Book Detail Header */
.book-detail-header {
    display: flex;
    gap: 24px;
    margin-bottom: 40px;
    align-items: flex-start;
}

.book-detail-cover {
    width: 120px;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Responsive book cover sizing - larger on wider screens */
@media (min-width: 480px) {
    .book-detail-cover {
        width: 150px;
    }
}

@media (min-width: 768px) {
    .book-detail-cover {
        width: 200px;
    }
}

@media (min-width: 1024px) {
    .book-detail-cover {
        width: 240px;
    }
}

/* Author link styling - make it obvious and clickable */
.author-link {
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
}

.author-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.book-detail-info h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 8px;
    line-height: 1.2;
}

.book-author {
    font-size: 1.1rem;
    color: var(--text-light);
    font-style: italic;
}

.author {
    font-size: 1.1rem;
    color: var(--text-light);
    font-style: italic;
}

/* Book Content Sections */

/* About This Book Section */
.about-section {
    margin-bottom: 48px;
    padding: 24px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.about-single-column {
    margin-bottom: 32px;
}

.about-single-column:last-child {
    margin-bottom: 0;
}

.about-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.about-heading {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0;
}

.learn-more-btn {
    color: #3498db;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.learn-more-btn:hover {
    color: #2980b9;
    text-decoration: underline;
}

.about-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #333;
    margin: 0;
}

.about-text p {
    margin: 0 0 1em 0;
}

.about-text p:last-child {
    margin-bottom: 0;
}

.about-text strong {
    font-weight: 600;
    color: var(--primary-color);
}

.about-text em {
    font-style: italic;
}

.about-text a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-color);
}

.about-text a:hover {
    opacity: 0.8;
}

/* Author Info */
.author-info-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.author-name-display {
    font-size: 1rem;
    color: #333;
    font-weight: 600;
}

.author-country-inline {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.author-bio-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #333;
    margin: 0 0 20px 0;
}

/* Author Books Section */
.author-books-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #d0d0d0;
}

.author-books-heading {
    font-size: 1rem;
    color: #555;
    font-weight: 600;
    margin: 0 0 16px 0;
}

.author-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.author-book-item {
    cursor: pointer;
    transition: transform 0.2s;
}

.author-book-item:hover {
    transform: translateY(-2px);
}

.author-book-cover {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
}

.author-book-title {
    font-size: 0.85rem;
    color: #333;
    line-height: 1.3;
    text-align: center;
}

.author-book-text-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.author-book-text-item {
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--primary-color);
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

.author-book-text-item:hover {
    background-color: #f0f0f0;
}

.author-book-text-item:last-child {
    border-bottom: none;
}

/* Responsive design for about section */
@media (max-width: 768px) {
    .about-section {
        padding: 20px;
    }

    .author-books-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
}

/* Summary Tabs */
.summary-tabs-section {
    margin-bottom: 48px;
}

.summary-tabs-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 24px;
}

.summary-tabs-header {
    display: flex;
    gap: 0;
    flex: 1;
}

.summary-tabs-header-container .tts-button-inline {
    margin-bottom: 0;
    align-self: flex-end;
    margin-bottom: 8px;
}

.summary-tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.summary-tab:hover {
    color: var(--primary-color);
}

.summary-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.summary-tab-content {
    display: none;
}

.summary-tab-content.active {
    display: block;
}

.chapters-section {
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: none;
}

.chapters-section > h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 16px 0 32px 0;
}

/* Related Books Section */
.related-books-section {
    margin-bottom: 48px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.related-books-section > h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 16px 0 24px 0;
}


.related-books-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    padding: 1rem 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.related-books-scroll::-webkit-scrollbar {
    display: none;
}

.related-book-card {
    flex: 0 0 auto;
    width: 200px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    transition: transform 0.2s ease;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-book-card:hover {
    transform: scale(1.05);
    z-index: 1;
}

.related-book-card .book-cover-wrapper {
    height: 300px;
}

.related-book-cover {
    width: 100%;
    height: 300px;
    object-fit: contain;
    border-radius: 4px;
    background-color: #f7fafc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.related-book-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-book-author {
    font-size: 0.85rem;
    color: #718096;
    margin: 0;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .related-book-card {
        width: 150px;
    }

    .related-book-card .book-cover-wrapper {
        height: 200px;
    }

    .related-book-cover {
        height: 200px;
    }

    .related-book-title {
        font-size: 0.85rem;
    }

    .related-book-author {
        font-size: 0.75rem;
    }

    .related-books-scroll {
        padding: 0.75rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .related-book-card {
        width: 130px;
    }

    .related-book-card .book-cover-wrapper {
        height: 180px;
    }

    .related-book-cover {
        height: 180px;
    }

    .related-books-scroll {
        padding: 0.5rem 0.5rem;
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0;
}

.section-header h4 {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0;
}

.tts-button-inline {
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.tts-button-inline:hover {
    background: var(--secondary-color);
    color: white;
}

.expand-link {
    background: transparent;
    color: var(--secondary-color);
    border: none;
    padding: 6px 0;
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 500;
}

.expand-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Summary Text */
.summary-text {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-color);
}

.summary-text.preview {
    color: var(--text-color);
}

/* Concise Preview Container */
.concise-preview-container {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    margin-bottom: 16px;
    transition: max-height 0.4s ease;
}

.concise-preview-container.expanded {
    max-height: none;
}

.concise-preview-text {
    position: relative;
}

.concise-preview-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.concise-preview-fade.hidden {
    opacity: 0;
}

/* Medium Preview Container */
.medium-preview-container {
    position: relative;
    max-height: 300px;
    overflow: hidden;
    margin-bottom: 16px;
}

.medium-preview-text {
    position: relative;
}

.preview-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
    pointer-events: none;
}

.expand-link.centered {
    display: block;
    text-align: center;
    margin: 0 auto;
    width: fit-content;
}

/* Chapters List */
.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chapter-box {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--secondary-color);
    padding: 16px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.chapter-box:hover {
    background: #e8f4f8;
    border-left-color: #2980b9;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.chapter-box-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

/* Section Headers (for two-level structure) */
.section-header {
    margin-top: 24px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.section-header:first-child {
    margin-top: 0;
}

.section-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--heading-color);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Indented chapters (for two-level structure) */
.chapter-box.indented {
    margin-left: 20px;
}

/* Medium Detail Section */
.medium-detail-section {
    animation: fadeIn 0.3s ease;
    background: var(--card-background);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
}

.medium-detail-section > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.medium-detail-section > *:first-child {
    padding-top: 16px;
}

.medium-detail-section > *:last-child {
    padding-bottom: 40px;
}

.medium-detail-header {
    margin-bottom: 32px;
}

.medium-detail-header h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 8px;
    line-height: 1.2;
}

.medium-detail-subtitle {
    font-size: 1rem;
    color: var(--text-light);
}

.medium-detail-content {
    margin-top: 24px;
}

/* Chapter Detail Section */
.chapter-detail-section {
    animation: fadeIn 0.3s ease;
    background: var(--card-background);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
}

.chapter-detail-section > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

.chapter-detail-section > *:first-child {
    padding-top: 16px;
}

.chapter-detail-section > *:last-child {
    padding-bottom: 40px;
}

.chapter-detail-header {
    margin-bottom: 32px;
}

.chapter-detail-header h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 8px;
    line-height: 1.2;
}

.chapter-detail-subtitle {
    font-size: 1rem;
    color: var(--text-light);
}

.chapter-detail-content {
    /* Content is already contained within chapter-detail-section which has edge-to-edge white background */
}

/* Chapter Illustration */
.chapter-illustration-container {
    margin: 32px 0;
    text-align: center;
}

.chapter-illustration {
    max-width: 100%;
    max-height: 600px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive illustration sizing */
@media (max-width: 768px) {
    .chapter-illustration {
        max-height: none;
        width: 100%;
    }

    .chapter-illustration-container {
        margin: 32px -20px;
        width: calc(100% + 40px);
    }
}

.chapter-summary-box {
    background: #fff9e6;
    border-left: 4px solid #ffc107;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 32px;
}

.chapter-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.chapter-summary-header h4 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
}

.spoiler-warning {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: normal;
}

.chapter-summary-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.toggle-summary-btn {
    background: transparent;
    color: var(--secondary-color);
    border: none;
    padding: 0;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: normal;
    line-height: 1;
}

.toggle-summary-btn:hover {
    color: #2980b9;
    transform: scale(1.1);
}

.chapter-summary-content {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.chapter-fulltext-section {
    margin-top: 32px;
}

.chapter-fulltext {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-color);
    margin-top: 16px;
}

/* Markdown formatting in summaries */
.summary-text h1,
.summary-text h2,
.summary-text h3,
.summary-text h4,
.chapter-summary h1,
.chapter-summary h2,
.chapter-summary h3,
.chapter-summary h4,
.full-text-content h1,
.full-text-content h2,
.full-text-content h3,
.full-text-content h4,
.summary-content h1,
.summary-content h2,
.summary-content h3,
.summary-content h4 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.summary-text h1,
.chapter-summary h1,
.full-text-content h1,
.summary-content h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.3em;
}

.summary-text h2,
.chapter-summary h2,
.full-text-content h2,
.summary-content h2 {
    font-size: 1.5rem;
}

.summary-text h3,
.chapter-summary h3,
.full-text-content h3,
.summary-content h3 {
    font-size: 1.3rem;
}

.summary-text h4,
.chapter-summary h4,
.full-text-content h4,
.summary-content h4 {
    font-size: 1.15rem;
}

.summary-text p,
.chapter-summary p,
.full-text-content p,
.summary-content p,
.chapter-fulltext p {
    margin-bottom: 1em;
}

.summary-text ul,
.summary-text ol,
.chapter-summary ul,
.chapter-summary ol,
.full-text-content ul,
.full-text-content ol,
.summary-content ul,
.summary-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.summary-text li,
.chapter-summary li,
.full-text-content li,
.summary-content li {
    margin-bottom: 0.5em;
}

.summary-text strong,
.chapter-summary strong,
.full-text-content strong,
.summary-content strong {
    font-weight: 600;
    color: var(--primary-color);
}

.summary-text em,
.chapter-summary em,
.full-text-content em,
.summary-content em {
    font-style: italic;
}

.summary-text blockquote,
.chapter-summary blockquote,
.full-text-content blockquote,
.summary-content blockquote {
    border-left: 4px solid var(--secondary-color);
    margin: 1.5em 0;
    padding: 0.5em 1em;
    background: var(--background-color);
    font-style: italic;
}

.summary-text code,
.chapter-summary code,
.full-text-content code,
.summary-content code {
    background: var(--background-color);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.summary-text pre,
.chapter-summary pre,
.full-text-content pre,
.summary-content pre {
    background: var(--background-color);
    padding: 1em;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1em 0;
}

.summary-text pre code,
.chapter-summary pre code,
.full-text-content pre code,
.summary-content pre code {
    background: none;
    padding: 0;
}

.summary-text hr,
.chapter-summary hr,
.full-text-content hr,
.summary-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* Comprehensive View */
.comprehensive-view .overall-summary {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 2px solid var(--border-color);
}

.comprehensive-view h3 {
    font-size: 1.6rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.chapter-item {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--background-color);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chapter-header h4 {
    font-size: 1.3rem;
    color: var(--primary-color);
    flex: 1;
}

.chapter-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chapter-listen-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.chapter-listen-btn:hover {
    background: #2980b9;
}

.chapter-listen-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.chapter-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--secondary-color);
    transition: transform 0.3s;
}

.chapter-toggle.expanded {
    transform: rotate(180deg);
}

.chapter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.chapter-content.expanded {
    max-height: none;
    overflow: visible;
}

.chapter-summary {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    padding-top: 16px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px 0;
    margin-top: 40px;
    margin-bottom: 100px; /* Space for persistent player */
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
}

.footer .small {
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Persistent Audio Player */
.persistent-audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.player-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

.now-playing-icon {
    font-size: 1.5rem;
}

.player-text {
    display: flex;
    flex-direction: column;
}

.player-title {
    font-weight: 600;
    font-size: 1rem;
}

.player-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.player-controls audio {
    display: none; /* Hide native audio controls, use custom */
}

.player-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

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

.player-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.1s linear;
}

.player-time {
    font-size: 0.85rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Full-Length View */
.full-view .full-chapter-item {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--background-color);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

/* Summary Section */
.summary-section {
    margin-bottom: 16px;
    padding: 0px 16px 0px 16px;
}

.summary-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Add padding and margin when expanded */
.summary-section:has(.summary-content:not(.collapsed)) .summary-section-header {
    margin-bottom: 12px;
}

.summary-section-header h5 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
}

.summary-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.summary-listen-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.summary-listen-btn:hover {
    background: #2980b9;
}

.summary-listen-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.summary-toggle-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-toggle-btn:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.summary-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    max-height: none;
    overflow: visible;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.summary-content.collapsed {
    max-height: 0;
    overflow: hidden;
    padding: 0;
}

/* Full Text Section */
.full-text-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.full-text-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.full-text-section-header h5 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0;
}

.fulltext-listen-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.fulltext-listen-btn:hover {
    background: #2980b9;
}

.fulltext-listen-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.full-text-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .logo {
        font-size: 1.3rem;
    }

    .logo-icon {
        height: 30px;
    }

    .option-cards {
        grid-template-columns: 1fr;
    }

    .summary-content {
        padding: 20px;
    }

    .book-info h2 {
        font-size: 1.5rem;
    }

    /* Edge-to-edge white background is already applied via main section styles */
    .summary-section > *,
    .medium-detail-section > *,
    .chapter-detail-section > * {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Reduce book detail header gap on mobile */
    .book-detail-header {
        gap: 16px;
        margin-bottom: 24px;
    }

    /* Reduce margins between sections */
    .concise-summary-section,
    .medium-preview-section,
    .chapters-section {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }

    /* Persistent player mobile layout */
    .player-content {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .player-info {
        width: 100%;
    }

    .player-controls {
        width: 100%;
    }

    .player-time {
        font-size: 0.75rem;
    }
}

/* ===== Category Carousels ===== */
.categories-section {
    margin-bottom: 1rem;
    margin-top: 2.5rem;  /* More space after blue header */
}

.categories-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;  /* Less gap between carousels */
}

.category-carousel {
    margin-bottom: 0;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0;
}

.category-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.view-all-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

.view-all-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

.carousel-container {
    position: relative;
    width: 100%;
}

.carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
}

.carousel-nav-btn:hover {
    background: #f7f7f7;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.carousel-nav-btn.left {
    left: -20px;
}

.carousel-nav-btn.right {
    right: -20px;
}

.carousel-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.carousel-scroll {
    display: flex;
    gap: 0.75rem;  /* Less gap between books */
    overflow-x: auto;  /* Allow horizontal scrolling */
    overflow-y: visible;  /* Allow vertical overflow for scaled cards */
    scroll-behavior: smooth;
    padding: 1rem 1rem;  /* Add padding to prevent clipping on all sides */
    scrollbar-width: none;  /* Firefox - hide scrollbar */
    -ms-overflow-style: none;  /* IE/Edge - hide scrollbar */
}

.carousel-scroll::-webkit-scrollbar {
    display: none;  /* Chrome/Safari - hide scrollbar */
}

.carousel-book-card {
    flex: 0 0 auto;
    width: 200px;  /* Larger cards */
    background: transparent;  /* No card background */
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    transition: transform 0.2s ease;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: auto;  /* Allow scroll events to pass through */
}

.carousel-book-card:hover {
    transform: scale(1.05);
    z-index: 1;  /* Bring hovered card to front */
}

.carousel-book-card .book-cover-wrapper {
    height: 300px;  /* Fixed height for carousel covers */
}

.carousel-book-cover {
    width: 100%;
    height: 300px;  /* Taller to accommodate books like "A Tale of Two Cities" */
    object-fit: contain;  /* Show full image without cropping */
    border-radius: 4px;
    background-color: #f7fafc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.carousel-book-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-book-author {
    font-size: 0.85rem;
    color: #718096;
    margin: 0;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.75rem 0;
    padding: 0;
}

/* Responsive carousel styling */
@media (max-width: 768px) {
    .category-title {
        font-size: 1.25rem;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .carousel-book-card {
        width: 150px;
    }

    .carousel-book-card .book-cover-wrapper {
        height: 200px;
    }

    .carousel-book-cover {
        height: 200px;
    }

    .carousel-scroll {
        padding: 0.75rem 0.75rem;  /* Reduce padding on tablet: 12px */
    }

    .categories-container {
        gap: 0.75rem;  /* Reduce gap between carousels */
    }

    .categories-section {
        margin-top: 1.25rem;  /* Reduce space after blue header */
    }

    .category-header {
        margin-bottom: 0.5rem;  /* Reduce gap between header and carousel */
    }
}

@media (max-width: 480px) {
    .category-title {
        font-size: 1.1rem;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .carousel-book-card {
        width: 130px;
        padding: 0.75rem;
    }

    .carousel-book-card .book-cover-wrapper {
        height: 180px;
    }

    .carousel-book-cover {
        height: 180px;
    }

    .carousel-book-title {
        font-size: 0.85rem;
    }

    .carousel-book-author {
        font-size: 0.75rem;
    }

    .carousel-scroll {
        padding: 0.25rem 0.5rem 0.5rem 0.5rem;  /* Reduce top padding on mobile: 4px top, 8px bottom/sides */
    }

    .categories-container {
        gap: 0.25rem;  /* 4px gap between carousels */
    }

    .categories-section {
        margin-top: 0.5rem;  /* 8px space after blue header */
    }

    .category-header {
        margin-bottom: 0;  /* 0px gap between header and carousel */
    }
}

/* ===== Reading Experience Enhancements ===== */

/* Reading Settings Toggle Button */
.back-button-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reading-settings-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reading-settings-toggle:hover {
    background: var(--background-color);
    border-color: var(--secondary-color);
}

/* Reading Progress Bar - Kindle Style */
.reading-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 999;
    pointer-events: none;
}

.reading-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.3);
    transition: width 0.2s ease;
    width: 0%;
}

.reading-progress-text {
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 400;
    text-align: center;
    margin-top: 5px;
}

/* Progress bar colors for different themes */
.chapter-detail-section[data-theme="dark"] .reading-progress-fill {
    background: rgba(255, 255, 255, 0.3);
}

.chapter-detail-section[data-theme="dark"] .reading-progress-text {
    color: rgba(255, 255, 255, 0.5);
}

.chapter-detail-section[data-theme="sepia"] .reading-progress-fill {
    background: rgba(92, 79, 61, 0.3);
}

.chapter-detail-section[data-theme="sepia"] .reading-progress-text {
    color: rgba(92, 79, 61, 0.5);
}

/* Next Chapter Button */
.next-chapter-container {
    margin-top: 48px;
    margin-bottom: 80px;
    text-align: center;
}

.next-chapter-btn {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s;
}

.next-chapter-btn:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

/* Reading Settings Panel */
.reading-settings-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 360px;
    max-width: 90vw;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.reading-settings-panel:not(.hidden) {
    transform: translateX(0);
}

.reading-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background-color);
}

.reading-settings-header h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin: 0;
}

.reading-settings-close {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.reading-settings-close:hover {
    color: var(--primary-color);
}

.reading-settings-section {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.reading-settings-section:last-child {
    border-bottom: none;
}

.reading-settings-section h4 {
    font-size: 1rem;
    color: var(--primary-color);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Font Selection */
.font-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.font-choice {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.font-choice:hover {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

.font-choice.active {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.1);
}

.font-choice[data-font="georgia"] {
    font-family: Georgia, serif;
}

.font-choice[data-font="system"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.font-choice[data-font="opensans"] {
    font-family: 'Open Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.font-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}

.font-labels span {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Text Size Control */
.size-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.size-btn {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 44px;
}

.size-btn:hover {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

.size-slider-container {
    flex: 1;
}

.size-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
}

.size-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    cursor: pointer;
    border: none;
}

.size-value {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 600;
}

/* Theme Selection */
.theme-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.theme-choice {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.theme-choice:hover {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

.theme-choice.active {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.1);
}

.theme-preview {
    width: 100%;
    height: 60px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.theme-preview-light {
    background: white;
}

.theme-preview-dark {
    background: #1a1a1a;
}

.theme-preview-sepia {
    background: #f4ecd8;
}

.theme-choice span {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
}

/* Chapter Reading Themes */
.chapter-detail-section[data-theme="light"] {
    background: white;
    color: #2c3e50;
}

/* When chapter section is active with light theme, set body background */
body:has(.chapter-detail-section[data-theme="light"]:not(.hidden)) {
    background: white;
}

.chapter-detail-section[data-theme="dark"] {
    background: #1a1a1a;
    color: #e0e0e0;
}

/* When chapter section is active with dark theme, set body background */
body:has(.chapter-detail-section[data-theme="dark"]:not(.hidden)) {
    background: #1a1a1a;
}

.chapter-detail-section[data-theme="dark"] .chapter-fulltext p,
.chapter-detail-section[data-theme="dark"] .chapter-summary-text,
.chapter-detail-section[data-theme="dark"] h2,
.chapter-detail-section[data-theme="dark"] h4 {
    color: #e0e0e0;
}

.chapter-detail-section[data-theme="dark"] .chapter-summary-box {
    background: #2a2a2a;
    border-left-color: #ffc107;
}

.chapter-detail-section[data-theme="dark"] .back-button {
    color: #5cb3e0;
}

.chapter-detail-section[data-theme="dark"] .next-chapter-btn {
    color: #e0e0e0;
    border-color: #444;
}

.chapter-detail-section[data-theme="dark"] .next-chapter-btn:hover {
    border-color: #5cb3e0;
    color: #5cb3e0;
    background: rgba(92, 179, 224, 0.1);
}

.chapter-detail-section[data-theme="sepia"] {
    background: #f4ecd8;
    color: #5c4f3d;
}

/* When chapter section is active with sepia theme, set body background */
body:has(.chapter-detail-section[data-theme="sepia"]:not(.hidden)) {
    background: #f4ecd8;
}

.chapter-detail-section[data-theme="sepia"] .chapter-fulltext p,
.chapter-detail-section[data-theme="sepia"] .chapter-summary-text,
.chapter-detail-section[data-theme="sepia"] h2,
.chapter-detail-section[data-theme="sepia"] h4 {
    color: #5c4f3d;
}

.chapter-detail-section[data-theme="sepia"] .chapter-summary-box {
    background: #e8dcc4;
    border-left-color: #d4a574;
}

.chapter-detail-section[data-theme="sepia"] .next-chapter-btn {
    color: #5c4f3d;
    border-color: #d4c5a9;
}

.chapter-detail-section[data-theme="sepia"] .next-chapter-btn:hover {
    border-color: #a88f5a;
    color: #4a3f2f;
    background: rgba(168, 143, 90, 0.1);
}

/* Medium Detail Reading Themes */
.medium-detail-section[data-theme="light"] {
    background: white;
    color: #2c3e50;
}

/* When medium section is active with light theme, set body background */
body:has(.medium-detail-section[data-theme="light"]:not(.hidden)) {
    background: white;
}

.medium-detail-section[data-theme="dark"] {
    background: #1a1a1a;
    color: #e0e0e0;
}

/* When medium section is active with dark theme, set body background */
body:has(.medium-detail-section[data-theme="dark"]:not(.hidden)) {
    background: #1a1a1a;
}

.medium-detail-section[data-theme="dark"] .summary-text,
.medium-detail-section[data-theme="dark"] h2,
.medium-detail-section[data-theme="dark"] h3,
.medium-detail-section[data-theme="dark"] h4 {
    color: #e0e0e0;
}

.medium-detail-section[data-theme="dark"] .back-button {
    color: #5cb3e0;
}

.medium-detail-section[data-theme="sepia"] {
    background: #f4ecd8;
    color: #5c4f3d;
}

/* When medium section is active with sepia theme, set body background */
body:has(.medium-detail-section[data-theme="sepia"]:not(.hidden)) {
    background: #f4ecd8;
}

.medium-detail-section[data-theme="sepia"] .summary-text,
.medium-detail-section[data-theme="sepia"] h2,
.medium-detail-section[data-theme="sepia"] h3,
.medium-detail-section[data-theme="sepia"] h4 {
    color: #5c4f3d;
}

/* Sticky Reading Header */
.sticky-reading-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white !important;
    border-bottom: 1px solid #bdc3c7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    pointer-events: none;
}

.sticky-reading-header:not(.hidden) {
    pointer-events: auto;
}

.sticky-reading-header.hidden {
    transform: translateY(-100%);
    visibility: hidden;
}

.sticky-header-content {
    max-width: 100%;
    margin: 0;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sticky-header-content h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 400;
    color: #2c3e50 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    white-space: nowrap;
    text-align: center;
}

.sticky-header-title-separator {
    margin: 0 8px;
    color: #7f8c8d;
}

.sticky-settings-btn {
    background: transparent;
    border: 1px solid #bdc3c7;
    color: #2c3e50 !important;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 16px;
    flex-shrink: 0;
}

.sticky-settings-btn:hover {
    background: #ecf0f1;
    border-color: #3498db;
}


/* Font Family Application - includes summary text */
.chapter-detail-section[data-font="georgia"] .chapter-fulltext,
.chapter-detail-section[data-font="georgia"] .chapter-summary-text,
.chapter-detail-section[data-font="georgia"] .summary-text,
.medium-detail-section[data-font="georgia"] .summary-text {
    font-family: Georgia, serif;
}

.chapter-detail-section[data-font="system"] .chapter-fulltext,
.chapter-detail-section[data-font="system"] .chapter-summary-text,
.chapter-detail-section[data-font="system"] .summary-text,
.medium-detail-section[data-font="system"] .summary-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.chapter-detail-section[data-font="opensans"] .chapter-fulltext,
.chapter-detail-section[data-font="opensans"] .chapter-summary-text,
.chapter-detail-section[data-font="opensans"] .summary-text,
.medium-detail-section[data-font="opensans"] .summary-text {
    font-family: 'Open Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (max-width: 768px) {
    .reading-settings-panel {
        width: 100%;
        max-width: 100%;
    }

    .reading-progress-bar {
        height: 32px;
    }

    .next-chapter-container {
        margin-bottom: 60px;
    }
}

/* ===================================
   Image Lightbox Overlay
   =================================== */

/* Lightbox overlay - full screen dark background */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Close button - top right corner */
.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

/* Lightbox image - centered and scaled */
.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Make illustration clickable (pointer cursor) */
.chapter-illustration {
    cursor: pointer;
    transition: opacity 0.3s ease-in;
}

.chapter-illustration:hover {
    opacity: 0.9 !important; /* Override when loaded */
}

.chapter-illustration-container {
    position: relative;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .lightbox-close {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .lightbox-image {
        max-width: 95vw;
        max-height: 95vh;
    }
}

/* ===== Author Page Styles ===== */

#author-detail-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.author-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.author-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.author-country {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.author-bio-section,
.author-books-section,
.author-other-books-section,
.author-long-bio-section {
    margin-bottom: 3rem;
}

.author-bio-section h2,
.author-books-section h2,
.author-other-books-section h2,
.author-long-bio-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.author-books-section h2 .count {
    color: var(--text-secondary);
    font-size: 1.25rem;
    font-weight: normal;
}

.author-short-bio,
.author-long-bio {
    line-height: 1.8;
    color: var(--text-color);
}

.author-short-bio p,
.author-long-bio p {
    margin-bottom: 1rem;
}

/* Books carousel on author page */
.books-carousel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

/* Other books grid (non-platform books) */
.other-books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-top: 1.5rem;
}

.other-books-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.other-books-column li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    position: relative;
    padding-left: 1.5rem;
}

.other-books-column li:before {
    content: "📚";
    position: absolute;
    left: 0;
    top: 0.75rem;
}

.other-books-column li:last-child {
    border-bottom: none;
}

/* Author link styling */
.author-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.author-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .author-header h1 {
        font-size: 2rem;
    }

    .other-books-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .books-carousel {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
}
