body {
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.reader-layout {
    display: flex;
    flex-grow: 1; /* Fill available space between header and footer */
    overflow: hidden; /* Prevent scrollbars on the layout itself if children overflow */
}

header {
    background-color: #333;
    color: #fff;
    padding: 1em 0;
    text-align: center;
}

header h1 {
    margin: 0;
}

nav#chapter-list {
    width: 250px; /* Fixed width for the navigation panel */
    flex-shrink: 0; /* Prevent nav from shrinking */
    background-color: #ddd;
    padding: 15px;
    overflow-y: auto;
    height: 100%; /* Fill the height of .reader-layout */
}

nav#chapter-list ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

nav#chapter-list li a {
    display: block;
    padding: 8px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #ccc;
}

nav#chapter-list li a:hover {
    background-color: #ccc;
}

main#novel-content {
    flex-grow: 1; /* Main content takes remaining space */
    padding: 20px;
    background-color: #fff;
    overflow-y: auto;
    height: 100%; /* Fill the height of .reader-layout */
}

main#novel-content article h2 {
    margin-top: 0;
}

main#novel-content article p {
    line-height: 1.6;
    margin-bottom: 1em;
}

footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 1em 0;
    margin-top: auto;
}

/* Basic Responsive Design */
@media (min-width: 768px) {
    /* .reader-layout handles the row layout now */
    /* body remains flex-direction: column */

    /* header, .reader-layout, footer are direct children of body and stack vertically */
    /* nav#chapter-list and main#novel-content are inside .reader-layout and arrange horizontally */
}

@media (max-width: 767px) {
    .reader-layout {
        flex-direction: column; /* Stack nav and main content vertically */
    }

    nav#chapter-list {
        width: 100%; /* Full width on small screens */
        height: auto; /* Adjust height based on content */
        max-height: 40vh; /* Limit height to prevent taking too much space */
        flex-shrink: 1; /* Allow shrinking if needed */
    }

    main#novel-content {
        width: 100%; /* Full width on small screens */
        height: auto; /* Adjust height based on content */
        flex-grow: 1; /* Allow it to take remaining space if nav is short */
    }
    /* header and footer order remains managed by body's flex-direction: column */
}