* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    display: flex;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

table {
    border-collapse: collapse;
    /* 合并边框，避免双线 */
    width: 100%;
}

table,
th,
td {
    border: 1px solid #ccc;
    /* 设置边框颜色和粗细 */
}

p img {
    width: 100%;
    max-width: 100%;
    /* 确保图片不超出容器 */
    height: auto;
    /* 保持宽高比 */
}

/* 目录侧边栏样式 */
.toc-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 300px;
    /* --- 关键修复点 --- */
    height: 100vh;
    height: 100dvh;
    /* 现代浏览器会使用此行，完美适配手机 */
    /* --- 关键修复点 --- */
    background: linear-gradient(180deg, #2c3e50 0%, #1a1a2e 100%);
    color: #fff;
    padding: 20px 0;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toc-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.toc-header h2 {
    color: #fff;
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.toc-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toc-list {
    list-style-type: none;
    padding: 0 20px;
}

.toc-item {
    margin-bottom: 8px;
}

.toc-link {
    color: #ddd;
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.toc-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.toc-link.active {
    background-color: #3498db;
    color: white;
    font-weight: 600;
}

.toc-h1 {
    font-weight: 600;
    margin-left: 0;
    border-left: 3px solid #3498db;
}

.toc-h2 {
    font-weight: normal;
    margin-left: 20px;
    font-size: 0.9rem;
    border-left: 2px solid #2ecc71;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    padding: 40px 60px;
    margin-left: 300px;
    max-width: 900px;
    background-color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

#write {
    width: 100%;
}

/* 文章内容样式 - 针对您提供的HTML结构 */
#write h1 {
    color: #2c3e50;
    font-size: 2rem;
    margin: 40px 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

#write h2 {
    color: #34495e;
    font-size: 1.6rem;
    margin: 30px 0 15px;
}

#write p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

#write h1:first-child,
#write h2:first-child {
    margin-top: 0;
}

/* 密码弹窗样式 */
.password-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 10px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.modal-content h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 1rem;
}

.password-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 4px;
    font-family: monospace;
    margin-bottom: 10px;
    transition: border-color 0.3s ease;
}

.password-input:focus {
    outline: none;
    border-color: #3498db;
}

.error-message {
    color: #e74c3c;
    font-size: 0.9rem;
    min-height: 20px;
    margin-bottom: 15px;
}

.submit-btn {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 25px;
    font-size: 1.1rem;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s ease;
}

.submit-btn:hover {
    background-color: #2980b9;
}

.weapp-tip {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.weapp-tip img {
    width: 150px;
    height: 150px;
    margin: 10px auto;
    display: block;
    border: 1px solid #eee;
    padding: 5px;
    background-color: white;
}

.weapp-tip p {
    color: #666;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* 内容模糊遮罩 - 密码验证前的内容模糊效果 */
.blur-content {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}

/* 水印样式 */
.watermark-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* 使用视口宽度 */
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden; /* 关键：隐藏内部溢出 */
}

.watermark {
    position: absolute;
    opacity: 0.08;
    font-size: 18px;
    color: #3498db;
    transform: rotate(-30deg);
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.watermark-highlight {
    color: #e74c3c;
    font-weight: 600;
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #3498db;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 999;
}

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

/* 响应式设计 */
@media (max-width: 1024px) {
    .toc-sidebar {
        transform: translateX(-100%);
    }

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

    .toc-toggle {
        display: block;
    }

    /* --- 关键修复点 --- */
    .main-content {
        margin-left: 0;
        /* 修复：移除左侧空白导致的缩放 */
        padding: 40px 30px;
    }

    /* --- 关键修复点 --- */
    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .watermark {
        font-size: 16px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 30px 20px;
    }

    #write h1 {
        font-size: 1.8rem;
    }

    #write h2 {
        font-size: 1.5rem;
    }

    .watermark {
        font-size: 14px;
    }
}

@media print {
    .watermark {
        opacity: 0.15;
    }
}

/* 进度指示器 */
.progress-container {
    position: fixed;
    top: 0;
    left: 300px;
    width: calc(100% - 300px);
    height: 5px;
    background-color: transparent;
    z-index: 999;
}

.progress-bar {
    height: 5px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    width: 0%;
    transition: width 0.2s ease;
}

@media (max-width: 1024px) {
    .progress-container {
        left: 0;
        width: 100%;
    }
}