* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: #fefefe;
    color: #222;
    line-height: 1.8;
    padding: 20px;
    max-width: 1000px;
    margin: auto;
    transition: all 0.3s;
}

body.dark {
    background: #1e1e1e;
    color: #ddd;
}

/* 标题 */
h1, h2 {
    margin-bottom: 15px;
    text-align: center;
}

h2 {
    font-size: 1.2rem;
}

/* 书籍列表 */
.books-container {
    margin-top: 50px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    list-style: none;
    justify-content: flex-start;
    padding: 0;
}

.books-container li {
    width: calc(25% - 15px);
    text-align: center;
    max-width: 100%;
    border-radius: 4px;
    display: block;
    margin: auto;
}

.books-container img {
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.books-container li span {
    display: block;
    margin-top: 5px;
}

.books-container li a {
    text-decoration: none;
    color: #222;
}

body.dark .books-container li a {
    color: #ddd;
}

/* 章节列表 */
.chapter-list {
    list-style: none;
    padding: 0;
}

.chapter-list li {
    margin-bottom: 8px;
}

.chapter-list a {
    text-decoration: none;
    color: #0077cc;
}

body.dark .chapter-list a {
    color: #4da6ff;
}

.chapter-list a:hover {
    text-decoration: underline;
}

/* 通用章节导航（上/下章） */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin: 10px 50px;
    gap: 50px;
    flex-wrap: nowrap;
}

.chapter-nav a {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-decoration: none;
    color: #0077cc;
    transition: all 0.2s;
    min-width: 80px;
}

body.dark .chapter-nav a {
    color: #4da6ff;
    border-color: #555;
}

.chapter-nav a.disabled {
    color: #aaa;
    pointer-events: none;
    border-color: #eee;
}

body.dark .chapter-nav a.disabled {
    color: #555;
    border-color: #333;
}

/* 底部固定章节导航（带进度） */
.chapter-nav.bottom {
    background: #fff;
    border-top: 1px solid #eee;
    padding: 10px 0;
    font-size: 14px;
    color: #555;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.05);
}

.chapter-nav.bottom.fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* 进度显示 */
#readingProgress {
    display: inline-block;
    margin: 10px 15px;
    font-weight: bold;
    color: #333;
}

/* 暗黑模式 - 底部固定导航栏 */
body.dark .chapter-nav.bottom,
body.dark .chapter-nav.bottom.fixed {
    background: #1e1e1e;           /* 与 body.dark 一致 */
    border-top-color: #333;        /* 深色边框 */
    color: #ddd;                   /* 文字颜色 */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3); /* 更明显的阴影，增强层次 */
}

/* 暗黑模式 - 进度文字 */
body.dark #readingProgress {
    color: #eee;
}

/* 控制栏：字体、行距等 */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.controls button,
.controls select {
    padding: 6px 12px;
    font-size: 0.9rem;
    border: 1px solid #ccc;
    background: #f8f8f8;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    outline: none;
}

body.dark .controls button,
body.dark .controls select {
    background: #333;
    border-color: #555;
    color: #ddd;
}

.controls button:hover,
.controls select:hover {
    background: #eaeaea;
}

body.dark .controls button:hover,
body.dark .controls select:hover {
    background: #444;
}

.controls select {
    min-width: 120px;
    text-align: center;
}

/* 内容区域 */
.content {
    font-size: 1rem;
    line-height: 1.8;
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    white-space: pre-wrap;
}

/* === 目录下拉菜单 === */

.chapter-dropdown {
    position: relative;
    display: inline-block;
}

.chapter-dropdown a {
    border: none;
}

.dropdown-toggle {
    border: 1px solid #ccc;
    margin: 4px 15px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    background: #f0f0f0;
    font-weight: 500;
}

body.dark .dropdown-toggle {
    background: #333;
    border-color: #555;
    color: #ddd;
}

.dropdown-toggle:hover {
    background: #e0e0e0;
}

body.dark .dropdown-toggle:hover {
    background: #444;
}

/* 下拉菜单 */
.dropdown-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 200px;
    max-width: 400px;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    z-index: 1001;
    padding: 10px 0;
    margin-bottom: 5px;
    white-space: nowrap;
}

body.dark .dropdown-menu {
    background: #1e1e1e;
    border-color: #444;
}

/* 下拉菜单中的标题 */
.dropdown-menu h3 {
    margin: 0 15px 10px;
    font-size: 1rem;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

body.dark .dropdown-menu h3 {
    color: #bbb;
    border-bottom-color: #444;
}

/* 下拉菜单中的章节列表 */
.dropdown-menu .chapter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown-menu .chapter-list li {
    margin: 0;
}

.dropdown-menu .chapter-list a {
    display: block;
    padding: 8px 15px;
    text-decoration: none;
    color: #0077cc;
    font-size: 0.85rem;
    transition: background 0.2s;
}

body.dark .dropdown-menu .chapter-list a {
    color: #4da6ff;
}

.dropdown-menu .chapter-list a:hover {
    background: #f0f0f0;
}

body.dark .dropdown-menu .chapter-list a:hover {
    background: #333;
}

body.dark .file-item {
    background: #424242;
}

/* 响应式设计 */
@media (max-width: 900px) {
    .books-container li {
        width: calc(33.33% - 13px);
    }
}

@media (max-width: 600px) {
    .books-container li {
        width: calc(50% - 10px);
    }

    .chapter-nav a {
        min-width: 45%;
        font-size: 0.9rem;
    }

    body {
        padding: 15px;
    }

    h1, h2 {
        font-size: 1.3rem;
    }

    .chapter-nav.bottom {
        padding: 8px 0;
        font-size: 13px;
        min-height: 50px;
        gap: 5px;
    }

    .chapter-nav.bottom p {
        font-size: 0.5rem;
    }

    .chapter-nav.bottom a {
        margin-left: 10px;
        margin-right: 10px;
        min-width: 10px;
        font-size: 0.85rem;
        padding: 5px 0;
    }

    #readingProgress {
        font-size: 0.85rem;
    }

    .dropdown-toggle {
        margin: 5px 8px;
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .dropdown-menu {
        min-width: 180px;
        max-width: calc(100vw - 20px);
        font-size: 0.85rem;
    }

    .dropdown-menu h3 {
        font-size: 0.95rem;
        margin: 0 12px 8px;
    }

    .dropdown-menu .chapter-list a {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}