<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电子书阅读器</title>
    <style>
        :root {
            --bg-primary: #f5f5f5;
            --bg-card: #ffffff;
            --text-primary: #333333;
            --text-secondary: #666666;
            --text-muted: #999999;
            --border-color: #e8eef5;
            --accent-color: #667eea;
            --accent-hover: #5568d3;
            --header-bg: #ffffff;
            --progress-bg: #e0e0e0;
        }

        body.theme-dark {
            --bg-primary: #1a1a2e;
            --bg-card: #16213e;
            --text-primary: #e0e0e0;
            --text-secondary: #aaaaaa;
            --text-muted: #888888;
            --border-color: #2a3a5e;
            --accent-color: #667eea;
            --accent-hover: #8899ff;
            --header-bg: #16213e;
            --progress-bg: #2a3a5e;
        }

        body.theme-eye {
            --bg-primary: #f5f0e8;
            --bg-card: #faf7f2;
            --text-primary: #5c4a32;
            --text-secondary: #8b7355;
            --text-muted: #a89070;
            --border-color: #e8dfd4;
            --accent-color: #8b6914;
            --accent-hover: #a07818;
            --header-bg: #faf7f2;
            --progress-bg: #e8dfd4;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            transition: background-color 0.3s, color 0.3s;
        }
        
        #app {
            min-height: 100vh;
        }
        
        .bookshelf-page {
            padding: 20px;
            width: 100%;
        }
        
        .bookshelf-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .bookshelf-title {
            font-size: 24px;
            font-weight: bold;
            color: var(--text-primary);
        }
        
        .header-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .import-button {
            padding: 8px 20px;
            background: var(--accent-color);
            color: white;
            border: none;
            border-radius: 20px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: background 0.3s;
        }

        .import-button:hover {
            background: var(--accent-hover);
        }

        .settings-button {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            cursor: pointer;
            font-size: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.3s;
        }

        .settings-button:hover {
            background: var(--border-color);
        }
        
        .bookshelf-stats {
            color: var(--text-secondary);
            margin-bottom: 15px;
            font-size: 14px;
        }
        
        .book-list {
            display: grid;
            gap: 12px;
        }
        
        .book-item {
            display: flex;
            align-items: center;
            background: var(--bg-card);
            padding: 16px;
            border-radius: 12px;
            border: 1.5px solid var(--border-color);
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .book-item:hover {
            border-color: var(--accent-color);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
        }
        
        .book-cover {
            width: 50px;
            height: 66px;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 16px;
            margin-right: 14px;
            flex-shrink: 0;
        }
        
        .book-info {
            flex: 1;
        }
        
        .book-title {
            font-size: 15px;
            font-weight: 600;
            margin-bottom: 3px;
            color: var(--text-primary);
        }
        
        .book-author {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 6px;
        }
        
        .book-progress {
            margin-bottom: 4px;
        }
        
        .progress-text {
            font-size: 12px;
            color: var(--text-muted);
        }
        
        .progress-bar {
            height: 4px;
            background: var(--progress-bg);
            border-radius: 2px;
            margin-top: 4px;
        }
        
        .progress-fill {
            height: 100%;
            background: var(--accent-color);
            border-radius: 2px;
        }
        
        .book-last-read {
            font-size: 11px;
            color: var(--text-muted);
            margin-top: 4px;
        }
        
        .book-arrow {
            font-size: 20px;
            color: var(--text-muted);
            flex-shrink: 0;
        }
        
        .book-delete-btn {
            padding: 4px 8px;
            background: #e74c3c;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            margin-left: 10px;
            opacity: 0;
            transition: opacity 0.2s;
        }
        
        .book-item:hover .book-delete-btn {
            opacity: 1;
        }
        
        .book-delete-btn:hover {
            background: #c0392b;
        }
        
        .reader-page {
            display: flex;
            flex-direction: column;
            height: 100vh;
            background: var(--bg-primary);
        }
        
        .reader-header {
            display: flex;
            align-items: center;
            padding: 12px 20px;
            background: var(--header-bg);
            border-bottom: 1px solid var(--border-color);
        }
        
        .back-button {
            padding: 6px 14px;
            background: var(--bg-card);
            color: var(--text-primary);
            border: 1.5px solid var(--border-color);
            border-radius: 8px;
            cursor: pointer;
            margin-right: 15px;
            font-size: 14px;
            transition: all 0.3s;
        }

        .back-button:hover {
            border-color: var(--accent-color);
        }
        
        .reader-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
        }
        
        .reader-content-container {
            flex: 1;
            overflow-y: auto;
            padding: 24px 20px;
            width: 100%;
        }
        
        .chapter-title {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 20px;
            color: var(--text-primary);
        }
        
        .reader-content .paragraph {
            margin-bottom: 16px;
            line-height: 1.6;
            color: var(--text-primary);
            text-indent: 2em;
        }
        
        .reader-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 20px;
            background: var(--header-bg);
            border-top: 1px solid var(--border-color);
        }
        
        .nav-button {
            padding: 10px 32px;
            background: var(--accent-color);
            color: white;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 14px;
            transition: background 0.3s;
        }

        .nav-button:hover {
            background: var(--accent-hover);
        }
        
        .nav-button:disabled {
            background: var(--progress-bg);
            color: var(--text-muted);
            cursor: not-allowed;
        }
        
        .empty-tip {
            text-align: center;
            padding: 60px 20px;
            color: #999;
        }
        
        .empty-tip p {
            margin: 10px 0;
        }
        
        .small-tip {
            font-size: 14px !important;
            color: #bbb !important;
        }
        
        .chapter-info {
            font-size: 14px;
            color: var(--text-secondary);
        }
        
        .settings-page, .import-page {
            padding: 20px;
            width: 100%;
        }
        
        .page-header {
            display: flex;
            align-items: center;
            margin-bottom: 30px;
            position: relative;
        }
        
        .page-back-btn {
            padding: 6px 14px;
            background: var(--bg-card);
            color: var(--text-primary);
            border: 1.5px solid var(--border-color);
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }
        
        .page-back-btn:hover {
            border-color: var(--accent-color);
        }
        
        .page-title {
            font-size: 18px;
            font-weight: 600;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            color: var(--text-primary);
        }
        
        .settings-group {
            background: var(--bg-card);
            padding: 20px;
            border-radius: 12px;
            margin-bottom: 16px;
            border: 1.5px solid var(--border-color);
        }
        
        .settings-group-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 16px;
            color: var(--text-primary);
        }
        
        .setting-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 0;
            border-bottom: 1px solid #f0f0f0;
        }
        
        .setting-item:last-child {
            border-bottom: none;
        }
        
        .setting-label {
            font-size: 15px;
            color: #555;
        }
        
        .setting-control {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .setting-control input[type="range"] {
            width: 150px;
        }
        
        .setting-value {
            min-width: 50px;
            text-align: center;
            font-size: 14px;
            color: #667eea;
            font-weight: 600;
        }

        /* 滑块设置项 - 全宽 */
        .settings-slider-group {
            background: var(--bg-card);
            padding: 20px;
            border-radius: 12px;
            margin-bottom: 16px;
            border: 1.5px solid var(--border-color);
        }

        .settings-slider-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 12px;
            color: var(--text-primary);
        }

        .slider-container {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 8px;
        }

        .slider-min-label, .slider-max-label {
            font-size: 13px;
            color: var(--text-muted);
            white-space: nowrap;
        }

        .slider-container input[type="range"] {
            flex: 1;
            height: 4px;
            -webkit-appearance: none;
            appearance: none;
            background: linear-gradient(to right, var(--accent-color) 0%, var(--accent-color) var(--progress, 50%), var(--progress-bg) var(--progress, 50%), var(--progress-bg) 100%);
            border-radius: 2px;
            outline: none;
        }

        .slider-container input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--accent-color);
            cursor: pointer;
            border: 3px solid var(--bg-card);
            box-shadow: 0 1px 4px rgba(0,0,0,0.2);
        }

        .slider-current-value {
            text-align: center;
            font-size: 14px;
            color: var(--accent-color);
            font-weight: 500;
        }

        /* 主题选择 */
        .theme-section {
            background: var(--bg-card);
            padding: 20px;
            border-radius: 12px;
            margin-bottom: 16px;
            border: 1.5px solid var(--border-color);
        }

        .theme-section-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 16px;
            color: var(--text-primary);
        }

        .theme-options {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 16px;
        }

        .theme-option {
            display: flex;
            flex-direction: column;
            align-items: center;
            cursor: pointer;
        }

        .theme-card {
            width: 100%;
            height: 70px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            font-weight: bold;
            border: 2px solid #e0e0e0;
            transition: all 0.3s;
            margin-bottom: 8px;
        }

        .theme-card.active {
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
        }

        .theme-card-light {
            background: #ffffff;
            color: #333;
        }

        .theme-card-dark {
            background: #1a1a1a;
            color: #ffffff;
        }

        .theme-card-eye {
            background: #f5f0e8;
            color: #8b7355;
        }

        .theme-label {
            font-size: 13px;
            color: var(--accent-color);
        }

        /* 自动调整字体大小 */
        .auto-font-section {
            background: var(--bg-card);
            padding: 20px;
            border-radius: 12px;
            margin-bottom: 16px;
            border: 1.5px solid var(--border-color);
        }

        .auto-font-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .auto-font-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .auto-font-desc {
            font-size: 13px;
            color: var(--text-muted);
            margin-top: 8px;
            border-left: 3px solid var(--border-color);
            padding-left: 10px;
        }

        /* Toggle switch */
        .toggle-switch {
            position: relative;
            width: 52px;
            height: 28px;
            flex-shrink: 0;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: 0.3s;
            border-radius: 28px;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 22px;
            width: 22px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: 0.3s;
            border-radius: 50%;
        }

        .toggle-switch input:checked + .toggle-slider {
            background-color: var(--accent-color);
        }

        .toggle-switch input:checked + .toggle-slider:before {
            transform: translateX(24px);
        }

        /* 预览效果 */
        .preview-section {
            background: var(--bg-card);
            padding: 20px;
            border-radius: 12px;
            margin-bottom: 16px;
            border: 1.5px solid var(--accent-color);
        }

        .preview-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 16px;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .preview-content {
            padding: 20px;
            border-radius: 8px;
            line-height: 1.8;
        }

        .preview-chapter-title {
            font-weight: bold;
            margin-bottom: 12px;
        }

        .preview-paragraph {
            text-indent: 2em;
            margin-bottom: 8px;
        }
        
        .import-area {
            background: var(--bg-card);
            padding: 40px;
            border-radius: 12px;
            text-align: center;
            border: 1.5px solid var(--border-color);
        }
        
        .import-area p {
            margin: 10px 0;
            color: var(--text-secondary);
        }
        
        .import-file-input {
            display: none;
        }
        
        .import-file-btn {
            padding: 12px 24px;
            background: var(--accent-color);
            color: white;
            border: none;
            border-radius: 20px;
            cursor: pointer;
            font-size: 16px;
            margin-top: 20px;
            transition: background 0.3s;
        }
        
        .import-file-btn:hover {
            background: var(--accent-hover);
        }

        /* 响应式适配 */
        @media (max-width: 768px) {
            .bookshelf-page {
                padding: 12px;
            }
            .bookshelf-title {
                font-size: 20px;
            }
            .import-button {
                padding: 6px 14px;
                font-size: 13px;
            }
            .settings-button {
                width: 36px;
                height: 36px;
                font-size: 16px;
            }
            .book-item {
                padding: 12px;
            }
            .book-cover {
                width: 44px;
                height: 58px;
                font-size: 14px;
                margin-right: 12px;
            }
            .book-title {
                font-size: 14px;
            }
            .book-author {
                font-size: 12px;
            }
            .settings-page, .import-page {
                padding: 12px;
            }
            .settings-slider-group, .theme-section, .auto-font-section, .preview-section {
                padding: 16px;
            }
            .theme-options {
                gap: 10px;
            }
            .theme-card {
                height: 56px;
                font-size: 20px;
            }
            .nav-button {
                padding: 8px 20px;
                font-size: 13px;
            }
            .reader-content-container {
                padding: 16px 14px;
            }
        }

        @media (max-width: 480px) {
            .bookshelf-title {
                font-size: 18px;
            }
            .header-actions {
                gap: 8px;
            }
            .import-button {
                padding: 6px 12px;
                font-size: 12px;
            }
            .book-cover {
                width: 40px;
                height: 52px;
                font-size: 13px;
                margin-right: 10px;
            }
            .page-title {
                font-size: 16px;
            }
            .nav-button {
                padding: 8px 16px;
                font-size: 12px;
            }
        }
    </style>
</head>
<body>
    <div id="app"></div>
    
    <script src="js/storage.js"></script>
    <script src="js/bookshelf.js"></script>
    <script src="js/reader.js"></script>
    <script src="js/settings.js"></script>
    <script src="js/import.js"></script>
    <script src="js/app.js"></script>
</body>
</html>