* {
    box-sizing: border-box;
}

:root {
    --reader-serif: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", "Songti SC", serif;
    --reader-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --accent: #4a90e2;
}

body {
    margin: 0;
    font-family: var(--reader-sans);
    background: #f5f6fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-header {
    background: linear-gradient(90deg, #4a90e2 0%, #357abd 100%);
    color: #fff;
    padding: 15px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    margin: 0;
    font-size: 1.6rem;
}

.logo a {
    color: #fff;
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.main-nav a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: #fff;
    text-decoration: underline;
}

.search-form {
    display: flex;
    gap: 0;
}

.search-form input {
    padding: 8px 12px;
    border: none;
    border-radius: 4px 0 0 4px;
    width: 180px;
    outline: none;
}

.search-form button {
    padding: 8px 14px;
    border: none;
    background: #ff6b6b;
    color: #fff;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background 0.2s;
}

.search-form button:hover {
    background: #ff5252;
}

main.container {
    padding-top: 30px;
    padding-bottom: 50px;
    min-height: 600px;
}

.section-title {
    font-size: 1.4rem;
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a90e2;
    color: #222;
}

.breadcrumb {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 20px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
}

.breadcrumb a {
    color: #4a90e2;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb .sep {
    margin: 0 8px;
    color: #ccc;
}

.breadcrumb .current {
    color: #555;
}

.novel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 25px;
}

.novel-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.novel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.novel-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.novel-card img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    display: block;
    background: #e0e0e0;
}

.novel-card .info {
    padding: 12px;
}

.novel-card h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: #222;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.novel-card .meta {
    font-size: 0.85rem;
    color: #888;
    display: flex;
    justify-content: space-between;
}

.novel-detail {
    background: #fff;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.detail-header {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.detail-header img {
    width: 220px;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.detail-info {
    flex: 1;
    min-width: 280px;
}

.detail-info h1 {
    margin: 0 0 12px;
    font-size: 1.8rem;
    color: #222;
}

.detail-info .author,
.detail-info .category,
.detail-info .words {
    margin: 6px 0;
    color: #666;
}

.detail-info .summary {
    margin-top: 15px;
    color: #555;
    line-height: 1.8;
}

.chapter-list {
    margin-top: 25px;
}

.chapter-list h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #222;
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.chapter-item {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px 15px;
    transition: background 0.2s;
}

.chapter-item:hover {
    background: #e9ecef;
}

.chapter-item a {
    color: #333;
    text-decoration: none;
    display: block;
    font-size: 0.95rem;
}

/* Reading page */
.reading-page {
    background: #fff;
    border-radius: 8px;
    padding: 30px 40px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    animation: pageIn 0.5s ease;
}

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

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 110;
    pointer-events: none;
}

.reading-progress .progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #4a90e2, #63b3ed);
    transition: width 0.1s linear;
}

.reader-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 12px 16px;
    margin: -30px -40px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
    justify-content: center;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-label {
    font-size: 0.85rem;
    color: #666;
    margin-right: 4px;
}

.reader-toolbar button {
    border: 1px solid #d0d7de;
    background: #fff;
    color: #333;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.reader-toolbar button:hover,
.reader-toolbar button.active {
    border-color: #4a90e2;
    color: #4a90e2;
}

.reader-toolbar button.active {
    background: rgba(74, 144, 226, 0.1);
}

#fontSizeLabel {
    display: inline-block;
    min-width: 40px;
    text-align: center;
    font-size: 0.85rem;
    color: #555;
}

.toc-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 80vw;
    height: 100vh;
    background: #fff;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    z-index: 200;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.toc-panel.open {
    transform: translateX(0);
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.toc-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #222;
}

.toc-header button {
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list li {
    border-bottom: 1px solid #f0f0f0;
}

.toc-list li.current {
    background: rgba(74, 144, 226, 0.1);
}

.toc-list li.current a {
    color: #4a90e2;
    font-weight: 600;
}

.toc-list a {
    display: block;
    padding: 12px 20px;
    color: #444;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.toc-list a:hover {
    background: #f5f6fa;
}

.reader-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.reader-mask.show {
    opacity: 1;
    visibility: visible;
}

.chapter-header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 0.6s ease;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chapter-header h1 {
    font-size: 1.7rem;
    margin: 0 0 10px;
    color: #222;
    font-weight: 700;
}

.reading-meta {
    color: #888;
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.chapter-stats {
    font-size: 0.85rem;
    color: #999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: #f8f9fa;
    border-radius: 20px;
}

.chapter-stats .dot {
    color: #ccc;
}

.progress-hint {
    display: none;
    text-align: center;
    background: rgba(74, 144, 226, 0.12);
    color: #357abd;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.progress-hint.show {
    display: block;
    animation: fadeIn 0.4s ease;
}

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

.chapter-content {
    font-family: var(--reader-serif);
    font-size: 18px;
    line-height: 1.9;
    color: #333;
    text-align: justify;
    transition: font-size 0.2s, line-height 0.2s;
}

.chapter-content.line-compact { line-height: 1.7; }
.chapter-content.line-normal { line-height: 1.9; }
.chapter-content.line-loose { line-height: 2.5; }

.chapter-content p {
    margin: 0 0 1.3em;
    text-indent: 2em;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 45px;
    padding-top: 25px;
    border-top: 1px solid #eee;
}

.chapter-nav a {
    padding: 10px 22px;
    background: #4a90e2;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s, transform 0.2s;
}

.chapter-nav a:hover {
    background: #357abd;
    transform: translateY(-1px);
}

.chapter-nav a.disabled {
    background: #ccc;
    pointer-events: none;
}

.back-to-top,
.exit-focus-btn {
    position: fixed;
    right: 24px;
    border: none;
    border-radius: 50%;
    background: #4a90e2;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 80;
}

.back-to-top {
    bottom: 24px;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
}

.exit-focus-btn {
    top: 24px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 95;
}

.back-to-top.show,
.exit-focus-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover,
.exit-focus-btn:hover {
    background: #357abd;
}

/* Reading themes */
.reading-page.theme-light {
    background: #fff;
    color: #333;
}
.reading-page.theme-light .chapter-content { color: #333; }
.reading-page.theme-light .chapter-header h1 { color: #222; }

.reading-page.theme-dark {
    background: #1e1e2f;
    color: #d1d1e0;
}
.reading-page.theme-dark .chapter-content { color: #c5c5d5; }
.reading-page.theme-dark .chapter-header h1,
.reading-page.theme-dark .reading-meta,
.reading-page.theme-dark .reader-toolbar .tool-label,
.reading-page.theme-dark .chapter-stats { color: #b0b0c5; }
.reading-page.theme-dark .reader-toolbar { background: #27273a; border-bottom-color: #3a3a52; }
.reading-page.theme-dark .reader-toolbar button { background: #2c2c40; border-color: #44445e; color: #c5c5d5; }
.reading-page.theme-dark .reader-toolbar button:hover,
.reading-page.theme-dark .reader-toolbar button.active { border-color: #7aa7e8; color: #7aa7e8; }
.reading-page.theme-dark .reader-toolbar button.active { background: rgba(122, 167, 232, 0.15); }
.reading-page.theme-dark .chapter-nav a { background: #4a90e2; }
.reading-page.theme-dark .chapter-nav a:hover { background: #357abd; }
.reading-page.theme-dark .chapter-nav { border-top-color: #3a3a52; }
.reading-page.theme-dark .chapter-stats { background: #27273a; }

.reading-page.theme-eye {
    background: #e8f5e9;
    color: #2e4a30;
}
.reading-page.theme-eye .chapter-content { color: #3a5c3e; }
.reading-page.theme-eye .chapter-header h1 { color: #1b3a1d; }
.reading-page.theme-eye .reading-meta,
.reading-page.theme-eye .reader-toolbar .tool-label,
.reading-page.theme-eye .chapter-stats { color: #558b2f; }
.reading-page.theme-eye .reader-toolbar { background: #dcedc8; border-bottom-color: #c5e1a5; }
.reading-page.theme-eye .reader-toolbar button { background: #f1f8e9; border-color: #aed581; color: #33691e; }
.reading-page.theme-eye .reader-toolbar button:hover,
.reading-page.theme-eye .reader-toolbar button.active { border-color: #558b2f; color: #558b2f; }
.reading-page.theme-eye .reader-toolbar button.active { background: rgba(85, 139, 47, 0.12); }
.reading-page.theme-eye .chapter-nav a { background: #558b2f; }
.reading-page.theme-eye .chapter-nav a:hover { background: #33691e; }
.reading-page.theme-eye .chapter-stats { background: #dcedc8; }

.reading-page.theme-paper {
    background: #f7f2e0;
    color: #4a3f35;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(141, 110, 99, 0.04) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(141, 110, 99, 0.04) 0%, transparent 20%);
}
.reading-page.theme-paper .chapter-content { color: #5c4d3f; }
.reading-page.theme-paper .chapter-header h1 { color: #3e3227; }
.reading-page.theme-paper .reading-meta,
.reading-page.theme-paper .reader-toolbar .tool-label,
.reading-page.theme-paper .chapter-stats { color: #8d6e63; }
.reading-page.theme-paper .reader-toolbar { background: #efe6cf; border-bottom-color: #e0d3b8; }
.reading-page.theme-paper .reader-toolbar button { background: #faf5e6; border-color: #d6c7a6; color: #6b5a45; }
.reading-page.theme-paper .reader-toolbar button:hover,
.reading-page.theme-paper .reader-toolbar button.active { border-color: #8d6e63; color: #8d6e63; }
.reading-page.theme-paper .reader-toolbar button.active { background: rgba(141, 110, 99, 0.12); }
.reading-page.theme-paper .chapter-nav a { background: #8d6e63; }
.reading-page.theme-paper .chapter-nav a:hover { background: #6d4c41; }
.reading-page.theme-paper .chapter-stats { background: #efe6cf; }

/* Focus / fullscreen reading mode */
body.reader-focus-mode {
    background: var(--focus-bg, #fff);
}

body.reader-focus-mode .site-header,
body.reader-focus-mode .site-footer {
    display: none;
}

body.reader-focus-mode main.container {
    padding: 0;
    max-width: none;
}

body.reader-focus-mode .reading-page {
    max-width: 920px;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 60px;
    margin: 0 auto;
}

body.reader-focus-mode .reader-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-bottom: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    background: rgba(248, 249, 250, 0.96);
    backdrop-filter: blur(6px);
}

body.reader-focus-mode .reader-toolbar.toolbar-hidden {
    transform: translateY(-110%);
}

body.reader-focus-mode .reading-progress {
    top: auto;
    bottom: 0;
    height: 4px;
}

body.reader-focus-mode .reading-progress .progress-bar {
    background: linear-gradient(90deg, #4a90e2, #63b3ed);
}

.empty-tip {
    text-align: center;
    padding: 60px 0;
    color: #888;
}

.site-footer {
    background: #2c3e50;
    color: #aaa;
    text-align: center;
    padding: 20px 0;
    font-size: 0.9rem;
}

.ai-notice {
    margin: 0 0 8px;
    color: #f0c040;
    font-size: 0.85rem;
}

.ai-badge {
    display: inline-block;
    background: #ff6b6b;
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 6px;
    vertical-align: middle;
}

.ai-tip {
    color: #888;
    font-size: 0.9rem;
    margin: 8px 0 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 3px solid #4a90e2;
    border-radius: 0 4px 4px 0;
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .main-nav {
        justify-content: center;
    }

    .search-form {
        justify-content: center;
    }

    .detail-header {
        flex-direction: column;
        align-items: center;
    }

    .detail-info {
        text-align: center;
    }

    .reading-page {
        padding: 20px;
    }

    .reader-toolbar {
        margin: -20px -20px 20px;
        padding: 10px;
        gap: 8px 10px;
    }

    .reader-toolbar button {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .tool-label {
        font-size: 0.8rem;
    }

    .chapter-header h1 {
        font-size: 1.45rem;
    }

    .chapter-content {
        font-size: 17px;
    }

    .chapter-stats {
        font-size: 0.8rem;
    }

    body.reader-focus-mode .reading-page {
        padding: 70px 18px 50px;
    }

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

    .novel-card img {
        height: 190px;
    }
}
