/* PDF图书阅读器 - 主样式文件 */

/* --- 全局和根样式 --- */
:root {
    --primary-bg: #f0f2f5;
    --secondary-bg: #ffffff;
    --primary-text: #333333;
    --secondary-text: #666666;
    --accent-color: #007bff;
    --hover-color: #e9ecef;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --toolbar-height: 56px;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--primary-bg);
    color: var(--primary-text);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- 图标和按钮基础样式 --- */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    vertical-align: middle;
}

.icon-button,
.nav-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.icon-button:hover,
.nav-button:hover {
    background-color: var(--hover-color);
    color: var(--accent-color);
}

.icon-button:disabled,
.nav-button:disabled {
    color: var(--border-color);
    cursor: not-allowed;
    background-color: transparent;
}

/* --- 工具栏布局 --- */
.bottom-bar {
    height: var(--toolbar-height);
    background-color: var(--secondary-bg);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 1000;
}

.bottom-bar-left,
.bottom-bar-center,
.bottom-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bottom-bar-center {
    flex-grow: 1;
    justify-content: center;
}

.bottom-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.desktop-controls {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
}

.mobile-controls {
    display: none;
}

/* --- 浮动搜索框 --- */
.floating-search {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 16px;
    z-index: 2000;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.floating-search.show {
    transform: translateY(0);
}

.search-container {
    display: flex;
    align-items: center;
    background-color: var(--secondary-bg);
    border-radius: 28px;
    padding: 0 20px;
    max-width: 600px;
    margin: 0 auto;
    height: 48px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.search-container:focus-within {
    box-shadow: 0 0 0 2px var(--accent-color), 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-container i {
    color: var(--secondary-text);
}

#floatingSearchInput {
    background: none;
    border: none;
    outline: none;
    font-size: 16px;
    margin-left: 12px;
    flex-grow: 1;
    color: var(--primary-text);
}

.close-search {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text);
    transition: background-color 0.2s ease, color 0.2s ease;
    margin-left: 8px;
}

.close-search:hover {
    background-color: var(--hover-color);
    color: var(--accent-color);
}

/* --- 底部工具栏组件 --- */
.pagination-controls,
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--primary-bg);
    padding: 4px 12px;
    border-radius: 24px;
}

.page-info-wrapper {
    display: flex;
    align-items: center;
    margin: 0 4px;
}

.page-input {
    width: 50px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
    padding: 4px;
    -moz-appearance: textfield;
    /* Firefox */
}

.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-separator,
.total-pages {
    margin: 0 4px;
    font-size: 16px;
    color: var(--secondary-text);
}

.zoom-level {
    font-size: 14px;
    width: 50px;
    text-align: center;
    color: var(--secondary-text);
}

.zoom-icon {
    color: var(--secondary-text);
    font-size: 20px;
    transition: color 0.2s ease;
}

.zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    margin: 0 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.zoom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.zoom-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.zoom-slider:focus {
    background: rgba(0, 123, 255, 0.1);
}

/* --- 主内容区 --- */
.container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    /* 确保翻书效果不溢出 */
    transition: height 0.3s ease-in-out;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 20px;
}

.book-container {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-container .tips {
    position: fixed;
    left: 50%;
    top: 5px;
    transform: translateX(-50%);
    font-size: 10px;
    padding: 5px 10px;
    /* background: #28a745; */
    opacity: 0.4;
    color: #000;
    border-radius: 10px;
}

/* 缩放和拖拽容器 */
.zoom-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    user-select: none;
    /* 禁用文本选择 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none;
    /* 禁用浏览器默认触摸动作 */
}

.zoom-container.dragging {
    cursor: grabbing;
}

.zoom-container.zoomed {
    cursor: move;
}

.zoom-container.zoomed:active {
    cursor: grabbing;
}

#flipbook {
    transition: margin-left 0.8s ease;
    position: relative;
}

.page {
    background-color: var(--secondary-bg) !important;
    will-change: transform;
}

.page,
.page-wrapper {
    /* background-color: var(--secondary-bg) !important; */
}

.page-wrapper {}

canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- 加载动画 --- */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    border: 4px solid var(--hover-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    font-size: 16px;
    color: var(--secondary-text);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    .bottom-bar {
        padding: 0 8px;
    }

    .search-container {
        max-width: 400px;
        height: 44px;
        padding: 0 16px;
    }

    .pagination-controls,
    .zoom-controls {
        gap: 4px;
        padding: 4px 8px;
    }

    .nav-button .material-icons {
        font-size: 22px;
    }

    .page-input {
        width: 40px;
    }

    .zoom-level {
        width: 40px;
    }

    .floating-search {
        padding: 12px;
    }

    .bottom-bar-right {
        gap: 8px;
    }

    .desktop-controls {
        display: none;
    }

    .mobile-controls {
        display: flex;
        width: 100%;
        justify-content: space-around;
        align-items: center;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--secondary-text);
        font-size: 11px;
    }

    .mobile-nav-item .material-icons {
        font-size: 24px;
    }

    .mobile-pagination {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-pagination .icon-button {
        padding: 4px;
    }

    .mobile-pagination span {
        font-size: 16px;
        font-weight: 500;
        min-width: 60px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .bottom-bar {
        padding: 0 4px;
    }

    .bottom-bar-right {
        gap: 4px;
    }

    .bottom-bar-right .icon-button {
        padding: 6px;
    }

    .search-container {
        max-width: 300px;
        height: 40px;
        padding: 0 12px;
    }

    .page-info-wrapper {
        margin: 0 2px;
    }

    .page-input {
        width: 35px;
        font-size: 14px;
    }

    .zoom-level {
        width: 35px;
        font-size: 12px;
    }

    /* 在极小屏幕上可以考虑隐藏部分功能按钮 */
    #menuBtn {
        display: none;
    }

    /* 移动端缩略图弹窗优化 */
    .modal-header {
        padding: 8px 12px;
        min-height: 56px;
    }

    .modal-search-wrapper {
        height: 40px;
        margin-right: 8px;
    }

    #closeModalBtn {
        width: 40px;
        height: 40px;
    }

    .modal-grid {
        display: flex;
        padding: 5px !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px;
    }

    .modal-grid .thumbnail-item {
        width: 30%;
        background: unset !important;
        box-shadow: unset !important;
        padding: 5px 0 !important;
        border-radius: 8px;
    }

    .modal-grid .thumbnail-item p {
        font-size: 12px;
        margin: 0;
    }

    .modal-grid .thumbnail-item canvas {
        /* width: 70% !important; */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: -moz-crisp-edges;
        image-rendering: crisp-edges;
        -ms-interpolation-mode: nearest-neighbor;
    }
}

/* --- 缩略图功能样式 --- */

/* 桌面端轮播栏 */
.thumbnails-bar {
    position: fixed;
    bottom: var(--toolbar-height);
    left: 0;
    right: 0;
    height: 140px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    align-items: center;
    padding: 0 50px;
    /* 为箭头留出空间 */
}

.thumbnails-bar.show {
    transform: translateY(0);
}

.thumbnails-container {
    width: 100%;
    height: 100%;
    overflow-x: scroll;
    overflow-y: hidden;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    scrollbar-width: none;
    /* Firefox */
}

.thumbnails-container::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.thumbnail-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    /* padding: 8px; */
    transition: all 0.2s ease;
    flex-shrink: 0;
    /* 防止缩放 */
}

.thumbnail-item:hover {
    transform: scale(1.05);
    border-color: rgba(0, 123, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.thumbnail-item.active {
    border-color: var(--accent-color);
    background-color: rgba(0, 123, 255, 0.1);
    box-shadow: 0 0 12px rgba(0, 123, 255, 0.4);
    transform: scale(1.02);
}

.thumbnail-item canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: opacity 0.3s ease;
    /* 添加淡入效果 */
}

.thumbnail-item p {
    margin-top: 6px;
    font-size: 12px;
    color: var(--primary-text);
    font-weight: 500;
    text-align: center;
    min-width: 20px;
}

.thumbnail-item.active p {
    color: var(--accent-color);
    font-weight: 600;
}

.scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-arrow:hover {
    background-color: var(--hover-color);
}

.scroll-arrow.left {
    left: 10px;
}

.scroll-arrow.right {
    right: 10px;
}

/* 移动端弹窗 */
.thumbnail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100%;
    background: var(--primary-bg);
    z-index: 3000;
    display: none;
    /* 默认隐藏 */
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.thumbnail-modal.show {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--secondary-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
}

.modal-search-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    background-color: var(--primary-bg);
    border-radius: 22px;
    padding: 0 16px;
    height: 44px;
    margin-right: 12px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-search-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.modal-search-wrapper i {
    color: var(--secondary-text);
    font-size: 20px;
}

#thumbnailSearchInput {
    flex-grow: 1;
    border: none;
    outline: none;
    background: transparent;
    margin-left: 12px;
    font-size: 16px;
    color: var(--primary-text);
}

#closeModalBtn {
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#closeModalBtn:hover {
    background-color: var(--hover-color);
    border-color: var(--accent-color);
}

.modal-grid {
    /* flex-grow: 1; */
    overflow-y: auto;
    padding: 20px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
    background: var(--primary-bg);
}

.modal-grid .thumbnail-item {
    width: 100%;
    padding: 10px 2px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--secondary-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.modal-grid .thumbnail-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 123, 255, 0.3);
}

.modal-grid .thumbnail-item.active {
    border-color: var(--accent-color);
    background-color: rgba(0, 123, 255, 0.05);
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.2);
}

.modal-grid .thumbnail-item canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 56/79;
    /* 保持A4比例 */
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
}

.modal-grid .thumbnail-item p {
    margin: 12px 0 0;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: var(--primary-text);
}

.modal-grid .thumbnail-item.active p {
    color: var(--accent-color);
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--secondary-text);
    background: var(--primary-bg);
    display: none;
    /* 默认隐藏 */
}

.modal-loading .loading-spinner {
    margin-bottom: 16px;
}

.modal-loading p {
    font-size: 16px;
    margin: 0;
}

/* --- 抽屉菜单样式 --- */

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.show {
    opacity: 1;
    visibility: visible;
}

.drawer-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100%;
    background-color: var(--primary-bg);
    z-index: 4000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
}

.drawer-menu.show {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px 0 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    height: var(--toolbar-height);
}

.drawer-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.drawer-search-wrapper {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    display: flex;
    align-items: center;
    gap: 12px;
}

#drawerSearchInput {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0 16px 0 40px;
    font-size: 15px;
    background-color: var(--primary-bg);
    transition: all 0.2s ease;
    outline: none;
}

#drawerSearchInput:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    background-color: var(--secondary-bg);
}

.drawer-search-wrapper>.material-icons {
    position: absolute;
    left: 30px;
    color: var(--secondary-text);
    transition: color 0.2s ease;
}

#drawerSearchInput:focus+.material-icons {
    color: var(--accent-color);
}

.drawer-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    flex-shrink: 0;
}

.tab-link {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
    font-weight: 500;
    color: var(--secondary-text);
    transition: all 0.2s ease;
}

.tab-link:hover {
    background-color: var(--hover-color);
    color: var(--primary-text);
}

.tab-link.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: 600;
}

.drawer-content {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
}

.tab-content {
    display: none;
    padding: 16px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--secondary-text);
    padding: 40px;
}

.empty-state .material-icons {
    font-size: 48px;
    margin-bottom: 16px;
    color: #bdc3c7;
}

.empty-state p {
    font-size: 16px;
    margin: 0 0 8px;
}

.empty-state span {
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.empty-state span .material-icons {
    font-size: 16px;
    margin: 0;
}

/* 目录样式 */
.toc-container ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.toc-container ul ul {
    padding-left: 24px;
    margin-top: 4px;
    border-left: 2px solid var(--border-color);
    position: relative;
}

.toc-container li {
    margin-bottom: 2px;
    position: relative;
}

.toc-container a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--primary-text);
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    gap: 12px;
}

.toc-container a:hover {
    background-color: var(--hover-color);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toc-container a:active {
    transform: translateX(2px);
}

.toc-container a .toc-title {
    flex: 1;
    line-height: 1.4;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.toc-container a .toc-page {
    color: var(--secondary-text);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    background-color: var(--primary-bg);
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    min-width: 32px;
    text-align: center;
}

.toc-container a:hover .toc-page {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* 不同层级的目录项样式 */
.toc-container ul ul a {
    font-size: 14px;
    padding: 10px 14px;
}

.toc-container ul ul ul a {
    font-size: 13px;
    padding: 8px 12px;
}

.toc-container ul ul a .toc-title {
    font-weight: 400;
}

.toc-container ul ul ul a .toc-title {
    font-weight: 300;
}

/* 层级指示线 */
.toc-container ul ul::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--border-color), transparent);
    opacity: 0.6;
}

/* 收藏夹和搜索结果样式 */

/* 收藏标签页顶部按钮 */
.bookmark-header {
    padding: 0 0 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.bookmark-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.bookmark-action-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.bookmark-action-btn:active {
    transform: translateY(0);
}

.bookmark-action-btn i {
    font-size: 20px;
}

.bookmarks-container,
.search-results-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bookmark-item,
.search-result-item {
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.bookmark-item:hover,
.search-result-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

.bookmark-content {
    flex: 1;
    padding: 16px 0 16px 16px;
    cursor: pointer;
}

.bookmark-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    margin-bottom: 4px;
}

.bookmark-label {
    flex: 1;
    color: var(--primary-text);
    font-size: 14px;
}

.bookmark-item-header .page-number {
    color: var(--accent-color);
    font-size: 12px;
    font-weight: 500;
}

.bookmark-time {
    font-size: 12px;
    color: var(--secondary-text);
    margin-top: 4px;
}

.bookmark-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border-left: 1px solid var(--border-color);
}

.bookmark-action-btn.edit-btn,
.bookmark-action-btn.delete-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bookmark-action-btn.edit-btn {
    color: var(--accent-color);
}

.bookmark-action-btn.edit-btn:hover {
    background-color: rgba(0, 123, 255, 0.1);
    border-color: var(--accent-color);
}

.bookmark-action-btn.delete-btn {
    color: #dc3545;
}

.bookmark-action-btn.delete-btn:hover {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
}

.bookmark-action-btn i {
    font-size: 16px;
}

.search-result-item {
    padding: 16px;
    cursor: pointer;
    flex-direction: column;
    align-items: stretch;
}

.search-result-item .page-number {
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.search-result-item .snippet {
    font-size: 14px;
    color: var(--secondary-text);
    line-height: 1.5;
}

.search-result-item .snippet b {
    background-color: #ffd700;
    color: #333;
    font-weight: normal;
    border-radius: 3px;
    padding: 1px 3px;
}

@media (max-width: 480px) {
    .drawer-menu {
        width: 100%;
    }
}

/* 【新】缩略图占位符和加载动画 */
.thumbnail-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #e9ecef;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.thumbnail-placeholder .loading-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ===================== 分享功能样式 ===================== */

/* Web端分享弹窗 */
.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.share-modal {
    background: white;
    border-radius: 12px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.share-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: #f5f5f5;
    padding: 1px;
}

.share-option {
    background: white;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.share-option:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
}

.share-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: white;
    font-size: 18px;
}

.share-option span {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-align: center;
}

/* 移动端分享弹窗 */
.mobile-share-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.mobile-share-modal {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 80vh;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
    animation: mobileModalSlideUp 0.3s ease-out;
}

.mobile-share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.mobile-share-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.mobile-share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: #f5f5f5;
    padding: 1px;
}

.mobile-share-option {
    background: white;
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.mobile-share-option:active {
    background: #f0f0f0;
    transform: scale(0.98);
}

.mobile-share-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: white;
    font-size: 20px;
}

.mobile-share-option span {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    text-align: center;
}

/* 海报分享弹窗 */
.poster-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
}

.poster-modal {
    background: white;
    border-radius: 12px;
    width: 600px;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

.poster-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.poster-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.poster-content {
    padding: 20px;
    text-align: center;
}

.poster-content img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.poster-actions {
    margin-top: 20px;
}

.poster-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.poster-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

/* 二维码分享弹窗 */
.qrcode-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
}

.qrcode-modal {
    background: white;
    border-radius: 12px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

.qrcode-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.qrcode-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.qrcode-content {
    padding: 30px;
    text-align: center;
}

.qrcode-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.qrcode-container canvas {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.qrcode-text {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
}

.qrcode-actions {
    margin-top: 20px;
}

.qrcode-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.qrcode-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

/* 动画效果 */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes mobileModalSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .share-modal {
        width: 90vw;
        margin: 20px;
    }

    .share-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .poster-modal {
        width: 95vw;
        margin: 20px;
    }

    .qrcode-modal {
        width: 90vw;
        margin: 20px;
    }

    .mobile-share-options {
        display: flex;
        /* grid-template-columns: repeat(2, 1fr); */
        justify-content: space-between;
        gap: 1px;
        padding: 1px;
        background: #fff;
    }

    .mobile-share-option {
        padding: 16px;
        background: #fff;
    }

    .mobile-share-option .mobile-share-icon {
        width: 34px;
        height: 34px;
    }

    .mobile-share-option .mobile-share-icon i {
        font-size: 14px;
    }

    .mobile-share-option span {
        font-size: 12px;
    }
}

/* =================== 分享功能样式结束 =================== */

/* 阅读进度提醒弹窗 */
.reading-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.reading-progress-overlay.show {
    display: flex;
}

.reading-progress-modal {
    background: white;
    border-radius: 16px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.progress-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-icon .material-icons {
    font-size: 48px;
    color: white;
}

.progress-content {
    padding: 32px 24px 24px;
}

.progress-content h3 {
    margin: 0 0 16px 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-text);
}

.progress-message {
    margin: 0 0 32px 0;
    font-size: 16px;
    line-height: 1.5;
    color: var(--secondary-text);
}

.progress-message span {
    font-weight: 600;
    color: var(--accent-color);
}

.progress-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.progress-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
    justify-content: center;
}

.progress-button.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.progress-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

.progress-button.primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.progress-button.secondary {
    background: var(--primary-bg);
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
}

.progress-button.secondary:hover {
    background: var(--hover-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-1px);
}

.progress-button.secondary:active {
    transform: translateY(0);
}

.progress-button .material-icons {
    font-size: 20px;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .reading-progress-modal {
        width: 95vw;
        margin: 20px;
    }

    .progress-content {
        padding: 24px 20px 20px;
    }

    .progress-content h3 {
        font-size: 20px;
    }

    .progress-message {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .progress-actions {
        flex-direction: column;
        gap: 12px;
    }

    .progress-button {
        min-width: auto;
        width: 100%;
    }
}

/* 防止弹窗时背景滚动 */
/* ===================== 收藏弹窗样式 ===================== */

.bookmark-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.bookmark-modal {
    background: white;
    border-radius: 12px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

.bookmark-modal.small {
    width: 320px;
}

.bookmark-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: var(--primary-bg);
}

.bookmark-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-text);
}

.bookmark-modal-content {
    padding: 20px;
}

.bookmark-modal-content p {
    margin: 0;
    color: var(--primary-text);
    line-height: 1.5;
}

.bookmark-field {
    margin-bottom: 16px;
}

.bookmark-field:last-child {
    margin-bottom: 0;
}

.bookmark-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--primary-text);
    font-size: 14px;
}

.bookmark-page-input,
.bookmark-remark-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--primary-text);
    background: var(--secondary-bg);
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.bookmark-page-input:focus,
.bookmark-remark-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.bookmark-page-input[readonly] {
    background: #f8f9fa;
    color: var(--secondary-text);
    cursor: not-allowed;
}

.bookmark-modal-actions {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #eee;
    background: var(--secondary-bg);
    justify-content: flex-end;
}

.bookmark-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    justify-content: center;
}

.bookmark-btn.primary {
    background: var(--accent-color);
    color: white;
}

.bookmark-btn.primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.bookmark-btn.secondary {
    background: transparent;
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
}

.bookmark-btn.secondary:hover {
    background: var(--secondary-bg);
    border-color: var(--accent-color);
    color: var(--primary-text);
}

.bookmark-btn.danger {
    background: #dc3545;
    color: white;
}

.bookmark-btn.danger:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.bookmark-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.bookmark-btn i {
    font-size: 16px;
}

/* ===================== Toast提示样式 ===================== */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #28a745;
    min-width: 280px;
    max-width: 400px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.toast-success {
    border-left-color: #28a745;
}

.toast.toast-error {
    border-left-color: #dc3545;
}

.toast.toast-info {
    border-left-color: var(--accent-color);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.toast-content i {
    font-size: 20px;
    color: inherit;
}

.toast.toast-success .toast-content i {
    color: #28a745;
}

.toast.toast-error .toast-content i {
    color: #dc3545;
}

.toast.toast-info .toast-content i {
    color: var(--accent-color);
}

.toast-content span {
    flex: 1;
    font-size: 14px;
    color: var(--primary-text);
    font-weight: 500;
}

@media (max-width: 768px) {
    .bookmark-modal {
        width: 95vw;
        margin: 0 10px;
    }

    .bookmark-modal.small {
        width: 85vw;
    }

    .bookmark-modal-actions {
        flex-direction: column-reverse;
    }

    .bookmark-btn {
        width: 100%;
    }

    .toast {
        top: 10px;
        left: 10px;
        right: 10px;
        min-width: auto;
        max-width: none;
        transform: translateY(-100%);
    }

    .toast.show {
        transform: translateY(0);
    }
}

body.modal-open {
    overflow: hidden;
}