/* CSS Reset with box-sizing */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Theme variables - Refined color palettes */
:root {
    /* Light theme (default) - Cleaner, crisper whites and subtle grays */
    --background: #ffffff;
    --text-color: #333333;
    --header-bg: #f8f8f8;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --btn-bg: #f5f5f5; /* Not used for buttons anymore */
    --btn-hover: #f0f0f0;
    --btn-active: #e8e8e8;
    --highlight-bg: #e3f2fd;
    --highlight-text: #1565c0;
    --link-color: #2196f3;
    --link-hover: #1565c0;
    
    /* Scrollbar colors - light theme */
    --scrollbar-track: #f5f5f5;
    --scrollbar-thumb: #d0d0d0;
    --scrollbar-thumb-hover: #b8b8b8;
}

[data-theme="dark"] {
    /* Dark theme - Softer blacks for reduced eye strain */
    --background: #121212;
    --text-color: #e6e6e6;
    --header-bg: #1a1a1a;
    --card-bg: #2a2a2a;
    --border-color: #3a3a3a;
    --shadow-color: rgba(0, 0, 0, 0.25);
    --btn-bg: #2a2a2a; /* Not used for buttons anymore */
    --btn-hover: #383838;
    --btn-active: #404040;
    --highlight-bg: #2c3e50;
    --highlight-text: #ecf0f1;
    --link-color: #90caf9;
    --link-hover: #bbdefb;
    
    /* Scrollbar colors - dark theme */
    --scrollbar-track: #1a1a1a;
    --scrollbar-thumb: #4d4d4d;
    --scrollbar-thumb-hover: #666666;
}

/* Jet Black theme - Pure dark mode for OLED screens */
[data-theme="jet-black"] {
    --background: #000000;
    --text-color: #e0e0e0;
    --header-bg: #0f0f0f;
    --card-bg: #0f0f0f;
    --border-color: #2a2a2a;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --btn-bg: #1a1a1a;
    --btn-hover: #2a2a2a;
    --btn-active: #333333;
    --highlight-bg: #1e3a5f;
    --highlight-text: #ffffff;
    --link-color: #82b1ff;
    --link-hover: #b6e3ff;
    
    /* Scrollbar colors */
    --scrollbar-track: #0f0f0f;
    --scrollbar-thumb: #333333;
    --scrollbar-thumb-hover: #444444;
}

/* Twilight theme - Softer dark blue-gray for evening reading */
[data-theme="twilight"] {
    --background: #282c35;
    --text-color: #e6e6e6;
    --header-bg: #1d2026;
    --card-bg: #323844;
    --border-color: #484f5e;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --btn-bg: #323844;
    --btn-hover: #3e4554;
    --btn-active: #4a5166;
    --highlight-bg: #5072a7;
    --highlight-text: #ffffff;
    --link-color: #8c9eff;
    --link-hover: #536dfe;
    
    /* Scrollbar colors */
    --scrollbar-track: #282c35;
    --scrollbar-thumb: #484f5e;
    --scrollbar-thumb-hover: #5d6579;
}

/* Amber Night theme - Warm dark mode with amber accent */
[data-theme="amber-night"] {
    --background: #222222; /* Slightly lighter than previous #1a1a1a */
    --text-color: #ffcc80;
    --header-bg: #242424;
    --card-bg: #2c2c2c;
    --border-color: #3d3d3d;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --btn-bg: #2c2c2c;
    --btn-hover: #383838;
    --btn-active: #444444;
    --highlight-bg: #b36b00;
    --highlight-text: #ffe0b3;
    --link-color: #ffb74d; /* Changed: Brighter amber for better contrast */
    --link-hover: #ffd54f;
    
    /* Scrollbar colors */
    --scrollbar-track: #242424;
    --scrollbar-thumb: #4d4d4d;
    --scrollbar-thumb-hover: #666666;
}

/* Newspaper theme - Classic print feel with off-white background */
[data-theme="newspaper"] {
    --background: #f7f7f2;
    --text-color: #222222;
    --header-bg: #e8e8e0;
    --card-bg: #ffffff;
    --border-color: #d8d8d0;
    --shadow-color: rgba(0, 0, 0, 0.06);
    --btn-bg: #ffffff; /* Not used for buttons anymore */
    --btn-hover: #f7f7f2;
    --btn-active: #f0f0e8;
    --highlight-bg: #f0ece3;
    --highlight-text: #413c32;
    --link-color: #0d47a1; /* Changed: Darker blue for better contrast with text */
    --link-hover: #1565c0;
    
    /* Scrollbar colors */
    --scrollbar-track: #f2f2ed;
    --scrollbar-thumb: #c5c5b9;
    --scrollbar-thumb-hover: #b0b0a6;
}

/* Sepia theme - Traditional warm brown tones */
[data-theme="sepia"] {
    --background: #f5efe0;
    --text-color: #4a3c2e;
    --header-bg: #ebe5d3;
    --card-bg: #f9f5e9;
    --border-color: #d3c7a6;
    --shadow-color: rgba(74, 60, 46, 0.1);
    --btn-bg: #f9f5e9; /* Not used for buttons anymore */
    --btn-hover: #f0e9d6;
    --btn-active: #e6ddbd;
    --highlight-bg: #e8d8b7;
    --highlight-text: #3f2e16;
    --link-color: #a1887f; /* Changed: More reddish brown for better contrast */
    --link-hover: #795548;
    
    /* Scrollbar colors */
    --scrollbar-track: #ede7d6;
    --scrollbar-thumb: #c5b89a;
    --scrollbar-thumb-hover: #b2a686;
}

/* Forest theme - Softer greens for a calming nature feel */
[data-theme="forest"] {
    --background: #f3f7f3;
    --text-color: #2c4a34;
    --header-bg: #e5efe5;
    --card-bg: #ffffff;
    --border-color: #d5e3d5;
    --shadow-color: rgba(44, 74, 52, 0.08);
    --btn-bg: #ffffff; /* Not used for buttons anymore */
    --btn-hover: #f3f7f3;
    --btn-active: #e5efe5;
    --highlight-bg: #c7e0c7;
    --highlight-text: #1e3e20;
    --link-color: #2e7d32; /* Changed: Darker green for better contrast */
    --link-hover: #1b5e20;
    
    /* Scrollbar colors */
    --scrollbar-track: #edf4ed;
    --scrollbar-thumb: #b9d1bd;
    --scrollbar-thumb-hover: #9cb89f;
}

/* Custom Scrollbar Styling */
/* Width */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

/* Track */
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

/* Handle */
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
    transition: background 0.3s ease;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Apply smooth transitions for theme changes */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.chapter-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    background-color: var(--background);
    transition: background-color 0.3s ease;
}

.chapter-header, .chapter-footer {
    background-color: var(--header-bg);
    padding: 12px 15px;
    text-align: center;
    position: fixed;
    width: 100%;
    left: 0;
    transition: transform 0.3s ease, background-color 0.3s ease;
    z-index: 10;
    box-shadow: 0 0 10px var(--shadow-color);
}

/* Header layout with flexbox */
.chapter-header {
    top: 0;
    transform: translateY(0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    position: fixed;
    width: 100%;
    left: 0;
    z-index: 10;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    min-width: 40px;
    z-index: 5; /* Ensure these are above the centered title */
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 40px;
    z-index: 5; /* Ensure these are above the centered title */
    gap: 12px; /* Add space between logo and menu button */
}

/* Site logo styling */
.site-logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
    text-decoration: none; /* Override default underline for links */
    transition: opacity 0.2s ease;
    letter-spacing: 0.5px;
}

.site-logo:hover {
    opacity: 0.8;
    text-decoration: none; /* Keep consistent with no underline */
}

.header-right {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.8;
}

.chapter-title {
    font-size: 1rem;
    font-weight: 500;
    position: absolute; /* Take it out of the normal flex flow */
    left: 50%; /* Center point of the header */
    transform: translateX(-50%); /* Offset by half its width */
    text-align: center;
    width: auto;
    max-width: 50%; /* Prevent very long titles from overlapping */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-count, .reading-time {
    display: flex;
    align-items: center;
    gap: 5px;
}

.word-count i, .reading-time i {
    font-size: 0.9rem;
}

/* Mobile responsiveness adjustments */
@media (max-width: 600px) {
    .header-right {
        font-size: 0.75rem;
        gap: 8px;
    }
    
    .word-count i, .reading-time i {
        font-size: 0.8rem;
    }

    .site-logo {
        font-size: 0.95rem;
    }
}

.chapter-footer {
    bottom: 0;
    transform: translateY(0);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px 15px;
}

.chapter-header.hidden {
    transform: translateY(-100%);
}

.chapter-footer.hidden {
    transform: translateY(100%);
}

.chapter-content {
    padding: 20px;
    flex-grow: 1;
    margin-top: 45px; /* Adjusted for smaller header */
    margin-bottom: 90px; /* Increased to provide more space for the two-row footer */
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.nav-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.primary-controls {
    margin-bottom: 8px;
}

.font-controls {
    gap: 15px; /* Reduced from 20px to accommodate the new button */
}

/* Fix for navigation buttons - restore their styling */
.nav-btn {
    width: 40px;
    height: 40px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    color: var(--text-color);
    box-shadow: 0 2px 5px var(--shadow-color);
}

.nav-btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.nav-btn:active {
    background-color: var(--btn-active);
    transform: translateY(0);
    box-shadow: 0 1px 3px var(--shadow-color);
}

/* Style for font buttons - make same size as nav buttons */
.font-btn {
    width: 40px;  /* Increased from 36px to match nav buttons */
    height: 40px; /* Increased from 36px to match nav buttons */
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem; /* Increased from 0.9rem to match nav buttons */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    color: var(--text-color);
    box-shadow: 0 2px 5px var(--shadow-color);
    position: relative;
}

.font-btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.font-btn:active {
    background-color: var(--btn-active);
    transform: translateY(0);
    box-shadow: 0 1px 3px var(--shadow-color);
}

.font-size-symbol {
    margin-left: 2px;
    font-weight: bold;
}

/* Paragraph spacing */
#chapter-text p {
    margin-bottom: 1.5rem; /* Increased spacing between paragraphs */
}

/* Font selector modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    box-shadow: 0 4px 20px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

/* Add modal actions div to contain the novel link and close button */
.modal-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Style for the novel link in the TOC header */
.to-novel-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--link-color);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

.to-novel-link:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px var(--shadow-color);
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.font-list {
    overflow-y: auto;
    padding: 10px;
    max-height: 60vh;
}

.font-option {
    display: flex;
    flex-direction: column;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    background-color: var(--btn-bg);
}

.font-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.font-option.selected {
    border-color: var(--highlight-bg);
    box-shadow: 0 0 0 2px rgba(var(--highlight-bg-rgb, 227, 242, 253), 0.3);
}

.font-preview {
    font-size: 1.4rem;
    margin-bottom: 5px;
}

.font-name {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

#chapter-text {
    line-height: 1.8;
    font-size: 1.1rem;
    color: var(--text-color);
    transition: color 0.3s ease;
}

/* Separate styling for main navigation vs utility buttons */
/* #home-btn, #contents-btn, #theme-btn {
    background-color: var(--card-bg);
} */

/* Create a new consistent styling class for all buttons */
.nav-btn, .font-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    /* Other properties remain the same */
}

.nav-btn:hover, .font-btn:hover {
    background-color: var(--btn-hover);
    /* ...existing code... */
}

.nav-btn:active, .font-btn:active {
    background-color: var(--btn-active);
    /* ...existing code... */
}

/* Remove the redundant button styling section */
/* Delete the section that overwrites button colors */

/* Theme selector styles */
.theme-list {
    overflow-y: auto;
    padding: 10px;
    max-height: 60vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    padding: 15px;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    height: 120px;
}

.theme-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.theme-option.selected {
    border-color: var(--highlight-bg);
    box-shadow: 0 0 0 2px rgba(var(--highlight-bg-rgb, 227, 242, 253), 0.3);
}

/* Add specific colors for each theme preview based on theme value */
.theme-sample[data-theme="light"] {
    --preview-bg: #ffffff;
    --preview-text: #333333;
    --preview-header: #f8f8f8;
    --preview-border: #e0e0e0;
}

.theme-sample[data-theme="dark"] {
    --preview-bg: #121212;
    --preview-text: #e6e6e6;
    --preview-header: #1a1a1a;
    --preview-border: #3a3a3a;
}

.theme-sample[data-theme="jet-black"] {
    --preview-bg: #000000;
    --preview-text: #e0e0e0;
    --preview-header: #0f0f0f;
    --preview-border: #2a2a2a;
}

.theme-sample[data-theme="twilight"] {
    --preview-bg: #282c35;
    --preview-text: #e6e6e6;
    --preview-header: #1d2026;
    --preview-border: #484f5e;
}

.theme-sample[data-theme="amber-night"] {
    --preview-bg: #222222; /* Updated to match the new background color */
    --preview-text: #ffcc80;
    --preview-header: #242424;
    --preview-border: #3d3d3d;
}

.theme-sample[data-theme="newspaper"] {
    --preview-bg: #f7f7f2;
    --preview-text: #222222;
    --preview-header: #e8e8e0;
    --preview-border: #d8d8d0;
}

.theme-sample[data-theme="sepia"] {
    --preview-bg: #f5efe0;
    --preview-text: #4a3c2e;
    --preview-header: #ebe5d3;
    --preview-border: #d3c7a6;
}

.theme-sample[data-theme="forest"] {
    --preview-bg: #f3f7f3;
    --preview-text: #2c4a34;
    --preview-header: #e5efe5;
    --preview-border: #d5e3d5;
}

.theme-sample {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 10px;
    background-color: var(--preview-bg);
    border: 1px solid var(--preview-border);
}

.theme-sample-header {
    height: 15px;
    border-radius: 3px;
    margin-bottom: 8px;
    background-color: var(--preview-header);
}

.theme-sample-content {
    flex: 1;
}

.theme-sample-lines {
    height: 6px;
    border-radius: 3px;
    margin-bottom: 6px;
    width: 90%;
    background-color: var(--preview-text);
    opacity: 0.7;
}

.theme-sample-lines:nth-child(2n) {
    width: 70%;
}

.theme-name {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    background-color: var(--card-bg);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

/* Basic mobile responsiveness */
@media (max-width: 600px) {
    .chapter-header, .chapter-footer {
        padding: 10px;
    }
    
    .chapter-content {
        margin-top: 40px;
        margin-bottom: 80px; /* Increased for mobile as well */
        padding: 15px;
    }
    
    .nav-btn, .font-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .nav-controls {
        gap: 10px;
    }

    .chapter-footer {
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .primary-controls {
        margin-bottom: 5px;
    }

    .font-controls {
        gap: 15px;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .theme-list {
        grid-template-columns: 1fr;
    }
}

/* Text selection style */
::selection {
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
}

::-moz-selection {
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
}

/* Novel title and chapter name styling */
.novel-info {
    margin-bottom: 2rem;
    text-align: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.novel-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--link-color);
    text-decoration: underline; /* Changed: Links are now underlined by default */
    transition: color 0.2s ease;
    display: block;
    margin-bottom: 0.3rem;
}

.novel-title:hover {
    color: var(--link-hover);
}

.chapter-name {
    font-size: 0.95rem;
    font-weight: normal;
    color: var(--text-color);
    opacity: 0.75;
}

/* General link styling */
a {
    color: var(--link-color);
    text-decoration: underline; /* Changed: Links are now underlined by default */
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover);
}

/* Bottom chapter navigation */
.chapter-bottom-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.chapter-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--link-color);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.chapter-nav-link:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px var(--shadow-color);
}

.chapter-nav-link:active {
    transform: translateY(0);
}

.prev-chapter {
    margin-right: auto;
}

.next-chapter {
    margin-left: auto;
}

/* Mobile adjustments for bottom navigation */
@media (max-width: 600px) {
    .chapter-bottom-nav {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .chapter-nav-link {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    
    .to-novel {
        order: -1;
        width: 100%;
        justify-content: center;
        margin-bottom: 8px;
    }
    
    .prev-chapter, .next-chapter {
        flex: 1;
    }
}

/* Table of contents styles */
.chapter-list {
    overflow-y: auto;
    padding: 10px;
    max-height: 60vh;
}

.chapter-item {
    display: flex;
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    background-color: var(--card-bg);
}

.chapter-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
    background-color: var(--btn-hover);
}

.chapter-item.active {
    border-color: var(--highlight-bg);
    box-shadow: 0 0 0 2px rgba(var(--highlight-bg-rgb, 227, 242, 253), 0.3);
    background-color: var(--btn-hover);
}

.chapter-item a {
    color: var(--text-color);
    text-decoration: none;
    width: 100%;
    display: block;
}

/* Style for undownloaded chapters in the table of contents */
.chapter-item.not-downloaded {
    opacity: 0.8;
    border-style: dashed;
}

.chapter-item.not-downloaded a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-style: italic;
}

.chapter-item.not-downloaded .chapter-status-icon {
    opacity: 0.7;
}

/* Novel page specific styles */
.novel-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    background-color: var(--background);
    transition: background-color 0.3s ease;
}

.novel-page-title {
    font-size: 1rem;
    font-weight: 500;
    position: absolute; /* Take it out of the normal flex flow */
    left: 50%; /* Center point of the header */
    transform: translateX(-50%); /* Offset by half its width */
    text-align: center;
    width: auto;
    max-width: 50%; /* Prevent very long titles from overlapping */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.novel-content {
    padding: 20px;
    margin-top: 60px; /* Adjusted for header */
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.novel-details {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    padding: 20px;
}

.novel-title-large {
    flex-grow: 1;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 0; /* Remove the bottom margin as it's handled by the container */
}

.novel-meta {
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.alt-names, .novel-tags {
    flex: 1;
    min-width: 250px;
}

.alt-names h3, .novel-tags h3 {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.alt-names ul {
    list-style: none;
}

.alt-names ul li {
    padding: 5px 0;
    color: var(--text-color);
    opacity: 0.8;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-block;
}

.chapters-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.chapters-list {
    display: grid;
    gap: 10px;
    margin-bottom: 2rem;
}

.chapter-list-item {
    background-color: var(--card-bg);
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.chapter-list-item a {
    text-decoration: none;
    color: var(--text-color);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Chapter status icon for undownloaded chapters */
.chapter-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    opacity: 0.7;
    font-size: 0.9em;
}

.chapter-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
    background-color: var(--btn-hover);
}

.home-button-container {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.home-button {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--card-bg);
    color: var(--link-color);
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    box-shadow: 0 2px 5px var(--shadow-color);
    font-weight: 500;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.home-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
    background-color: var(--btn-hover);
}

/* Ensure consistent header button styling for novel page */
.novel-container .header-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.novel-container .header-btn:hover {
    opacity: 0.7;
}

/* Novel title container to position home button next to title */
.novel-title-container {
    display: flex;
    align-items: center;
    position: relative;
    margin-bottom: 1.5rem;
}

/* Position the home button on the left edge */
#home-header-btn {
    position: absolute;
    left: 0;
}

/* Mobile responsiveness for novel page */
@media (max-width: 600px) {
    .novel-meta {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .novel-title-large {
        font-size: 1.5rem;
    }
    
    .tag {
        padding: 3px 10px;
        font-size: 0.8rem;
    }
    
    .chapter-list-item a {
        padding: 10px 12px;
    }
    
    .novel-title-container {
        gap: 10px;
    }
}

/* All novels page styling */
.all-novels-container {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    padding: 20px;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.novels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.novel-card {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    transition: all 0.2s ease;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.novel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px var(--shadow-color);
}

.novel-card-content {
    padding: 20px;
}

.novel-card-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 10px;
}

.novel-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    color: var(--text-color);
    opacity: 0.8;
    font-size: 0.9rem;
}

.novel-card-author, .novel-card-chapters {
    display: flex;
    align-items: center;
    gap: 5px;
}

.novel-card-link {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    margin-top: 10px;
    transition: all 0.2s ease;
}

.novel-card-link:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.loading-indicator {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px;
    color: var(--text-color);
    opacity: 0.7;
    font-size: 1.1rem;
}

.loading-indicator i {
    font-size: 2rem;
}

.error-message, .empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px;
    color: var(--text-color);
    text-align: center;
}

.error-message i, .empty-state i {
    font-size: 3rem;
    opacity: 0.5;
}

/* Responsive styles for novel cards */
@media (max-width: 600px) {
    .novels-grid {
        grid-template-columns: 1fr;
    }
    
    .novel-card-content {
        padding: 15px;
    }
}

/* Add Novel Form Styles */
.add-novel-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--background);
    color: var(--text-color);
    font-size: 1rem;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.85rem;
}

.scrape-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.scrape-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.scrape-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.scrape-status {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.scrape-status.loading {
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 10px;
}

.scrape-status.success {
    background-color: rgba(46, 125, 50, 0.2);
    color: #2e7d32;
}

.scrape-status.error {
    background-color: rgba(211, 47, 47, 0.2);
    color: #d32f2f;
}

/* Download status indicators for chapters */
.chapter-download-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    opacity: 0.7;
    font-size: 0.9em;
}

/* Different status indicators */
.status-downloaded .chapter-download-status {
    color: var(--link-color);
}

.status-not-downloaded .chapter-download-status {
    color: var(--text-color);
    opacity: 0.6;
}

.status-downloading .chapter-download-status {
    color: var(--highlight-bg);
    animation: pulse 1.5s infinite;
}

/* Different status indicators with improved visual distinction */
.status-downloaded-local .chapter-status-icon {
    color: #4caf50; /* Green for locally downloaded */
}

.status-on-server .chapter-status-icon {
    color: #2196f3; /* Blue for available on server */
}

.status-not-available .chapter-status-icon {
    color: #f44336; /* Red for not available */
    opacity: 0.6;
}

.status-unknown .chapter-status-icon {
    color: #9e9e9e; /* Gray for unknown status */
    opacity: 0.6;
}

.status-downloading .chapter-status-icon {
    color: var(--highlight-bg);
    animation: pulse 1.5s infinite;
}

/* Style for server-available but not downloaded chapters */
.chapter-list-item.status-on-server,
.chapter-item.status-on-server {
    border-style: solid;
}

.chapter-list-item.status-unknown,
.chapter-item.status-unknown {
    border-style: dotted;
    opacity: 0.8;
}

.chapter-list-item.status-not-available,
.chapter-item.status-not-available {
    border-style: dashed;
    opacity: 0.7;
}

/* Status text in the chapter list */
.chapter-status-text {
    font-size: 0.8em;
    margin-left: 5px;
}

/* Download All Chapters button */
.download-progress {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--btn-hover);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--link-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Download button animations */
@keyframes pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

/* Add rotating animation for sync icons */
.fa-spin-hover:hover {
    animation: spin 2s linear infinite;
}

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

/* Novel card download status */
.novel-card-status {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var (--card-bg);
    box-shadow: 0 2px 5px var(--shadow-color);
    z-index: 1;
}

/* Sync status message styling */
.sync-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    margin-bottom: 15px;
    opacity: 0.9;
}

.sync-status.success {
    background-color: rgba(46, 125, 50, 0.2);
    color: #2e7d32;
}

.sync-status i {
    font-size: 1.1rem;
}

/* Enhance the progress bar with a subtle animation */
.progress-bar {
    height: 100%;
    background-color: var(--link-color);
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.15) 50%, 
        transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}