* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", Arial, sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: #f5f7fa;
}

img {
    max-width: 100%;
    height: auto;
}

/* 移动端基础字体放大 */
html {
    font-size: 15px;
}

@media (max-width: 768px) {
    html {
        font-size: 15px;  /* 手机基础字体增大 */
    }
}

/* 容器 - 添加响应式宽度 */
.container {
    width: 100%;
    max-width: 1050px;
    margin: 0 auto;
    padding: 0px;
}

/* ========== 左侧目录 - 移动端适配 ========== */
.sidebar {
    width: 320px;
    background-color: #2f3542;
    color: #fff;
    padding: 20px;
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    transition: transform 0.3s ease;
    z-index: 1000;
}

/* 移动端：目录默认隐藏，通过按钮打开 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #57606f;
}

.toc-list {
    list-style: none;
}

.toc-list li {
    margin: 8px 0;
}

.toc-list a {
    color: #dfe4ea;
    text-decoration: none;
    font-size: 14px;
    display: block;
    padding: 4px 8px;
    border-radius: 4px;
    word-wrap: break-word;
}

.toc-list a:hover {
    background-color: #57606f;
}

/* 二级目录 */
.toc-level-2 {
    margin-left: 15px;
}

/* 三级目录 */
.toc-level-3 {
    margin-left: 30px;
}

/* ========== 右侧内容 - 移动端适配 ========== */
.content {
    width: 730px;
    margin-left: 320px;
    padding: 40px;
    background-color: #fff;
    min-height: 100vh;
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* 移动端：内容区占满全宽，自动换行 */
@media (max-width: 768px) {
    .content {
        width: 100%;
        margin-left: 0;
        padding: 20px 15px;
        overflow-x: hidden;
    }
}

.content h1 {
    font-size: 26px;
    color: #2f3542;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 2px solid #70a1ff;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .content h1 {
        font-size: 22px;
        margin-bottom: 20px;
    }
}

.content h2 {
    font-size: 22px;
    color: #3742fa;
    margin: 25px 0 15px;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .content h2 {
        font-size: 19px;
    }
}

.content h3 {
    font-size: 18px;
    color: #5352ed;
    margin: 20px 0 10px;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .content h3 {
        font-size: 17px;
    }
}

.content p {
    font-size: 15px;
    line-height: 1.8;
    color: #333;
    margin-bottom: 15px;
    text-align: justify;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;  /* 强制长单词换行 */
}

@media (max-width: 768px) {
    .content p {
        font-size: 15px;
        text-align: left;
    }
}

.content ul, .content ol {
    margin-left: 20px;
    margin-bottom: 13px;
    padding-left: 0;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .content ul, .content ol {
        margin-left: 13px;
    }
}

.content li {
    line-height: 1.8;
    color: #333;
    word-wrap: break-word;
    word-break: break-word;
}

/* ========== 表格 - 移动端可横向滚动 ========== */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
}

table {
    width: 100%;
    min-width: 500px;  /* 保证表格有最小宽度，移动端可滚动 */
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    table {
        min-width: 100%;
        font-size: 12px;
    }
}

table th, table td {
    border: 1px solid #ddd;
    padding: 8px 6px;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
}

table th {
    background-color: #70a1ff;
    color: #fff;
}

table tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* ========== 代码块 - 移动端可横向滚动 ========== */
pre {
    background-color: #f1f2f6;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
    margin: 15px 0;
    white-space: pre;
    word-wrap: normal;
}

@media (max-width: 768px) {
    pre {
        font-size: 12px;
        padding: 12px;
    }
}

code {
    word-break: break-word;
}

/* 锚点定位 - 修复固定目录遮挡问题 */
:target {
    padding-top: 20px;
    margin-top: -20px;
}

/* ========== 移动端：目录开关按钮 ========== */
.menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: #70a1ff;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
}

/* 移动端遮罩层 */
.mask-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .mask-overlay.active {
        display: block;
    }
}