.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 999;
    font-size: 1.5rem;
}

.back-to-top.visible {
    opacity: 1;
}

.back-to-top:hover {
    background-color: var(--secondary-color);
}

/* 导航菜单切换按钮 */
.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* 章节折叠功能 */
.collapsible {
    cursor: pointer;
    position: relative;
}

.toggle-icon {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    font-weight: bold;
}

.collapsed {
    display: none;
}

/* 目录样式 */
.toc-container {
    background-color: var(--section-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    padding: 1.5rem;
}

.toc-container h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-sublist {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.toc-subitem {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

/* 搜索功能样式 */
.search-container {
    margin-top: 1rem;
    position: relative;
    display: flex;
}

#search-input {
    flex-grow: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
    font-size: 0.9rem;
}

#search-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

#search-button:hover {
    background-color: var(--secondary-color);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--section-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.search-results.active {
    display: block;
}

.search-results ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-results li {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.search-results li:last-child {
    border-bottom: none;
}

.search-results li:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.more-results {
    font-style: italic;
    color: var(--secondary-color);
}

/* 高亮搜索结果 */
.highlight {
    background-color: rgba(255, 215, 0, 0.3);
    transition: background-color 0.5s ease;
}

/* 打印按钮 */
.print-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 1rem;
}

.print-button:hover {
    background-color: var(--secondary-color);
}

/* 主题切换按钮 */
.theme-toggle {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 1rem;
}

.theme-toggle:hover {
    background-color: var(--secondary-color);
}

/* 字体大小控制 */
.font-size-controls {
    display: flex;
    align-items: center;
}

.font-size-controls button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem;
    margin: 0 0.2rem;
    border-radius: 4px;
    cursor: pointer;
}

.font-size-controls button:hover {
    background-color: var(--secondary-color);
}

.font-size-reset {
    font-weight: bold;
}

/* 暗黑主题 */
body.dark-theme {
    --primary-color: #5c6bc0;
    --secondary-color: #ff4081;
    --background-color: #121212;
    --text-color: #e0e0e0;
    --heading-color: #bbdefb;
    --link-color: #90caf9;
    --link-hover-color: #ff4081;
    --section-bg: #1e1e1e;
    --border-color: #424242;
    --footer-bg: #0d1921;
    --footer-text: #e0e0e0;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    nav {
        display: none;
    }
    
    nav.active {
        display: block;
        margin-top: 1rem;
    }
    
    .search-container {
        margin-top: 0.5rem;
    }
    
    .toc-container {
        padding: 1rem;
    }
    
    .toggle-icon {
        right: 1rem;
    }
    
    .print-button, .theme-toggle {
        margin-bottom: 0.5rem;
        display: block;
        width: 100%;
        text-align: center;
    }
    
    .font-size-controls {
        justify-content: center;
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .toc-container {
        display: none;
    }
    
    .search-results {
        max-height: 200px;
    }
}
