html {
    scroll-behavior: smooth;
}

/* 左侧目录容器：保持不变 */
#leftPanelContainer {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    pointer-events: none;
    z-index: 10;
    transition: left 0.3s ease;
}

#leftPanelContainer.hide {
    left: -260px;
}

#leftPanel {
    position: absolute;
    top: 100px;
    left: 0;
    width: 260px;
    background: #fff;
    border-right: 1px solid #eee;
    padding: 15px 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    max-height: 40vh;
    overflow-y: auto;
    pointer-events: auto;
    z-index: 10;
}

/* 按钮：保持不变 */
#tocBtn {
    position: absolute;
    top: 150px;
    left: calc(260px + 10px);
    width: 40px;
    height: 40px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease, transform 0.2s ease;
    pointer-events: auto;
    padding: 0;
    margin: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#tocBtn:hover {
    transform: scale(1.05);
}

/* 核心修复：正文响应式适配（分3个区间，覆盖所有屏幕） */
.content-wrap {
    /* 移除 Tailwind container 的固定最大宽度限制 */
    max-width: 100% !important;
    /* 基础样式：PC端（>1200px） */
    margin-left: 290px !important;
    width: calc(100% - 290px) !important;
    padding: 28px 12px !important;
    /* 保留左右内边距，避免内容贴边 */
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.container {
    max-width: 97% !important;
}

/* 窄屏PC/平板（768px~1200px）：缩小目录宽度，正文占满剩余空间 */
@media (max-width: 1200px) and (min-width: 769px) {
    #leftPanelContainer.hide {
        left: -220px;
    }

    #leftPanel {
        width: 220px;
        /* 缩小目录宽度 */
    }

    #tocBtn {
        left: calc(220px + 10px);
        /* 按钮跟随目录宽度调整 */
    }

    .content-wrap {
        margin-left: 240px !important;
        /* 目录宽度+20px间距 */
        width: calc(100% - 240px) !important;
        /* 占满剩余宽度 */
    }
}

/* 移动端（≤768px）：保持正文占满 */
@media (max-width: 768px) {
    #leftPanelContainer.hide {
        left: -200px;
    }

    #leftPanel {
        width: 200px;
        max-height: 40vh;
    }

    #tocBtn {
        left: calc(200px + 10px);
        top: 120px;
    }

    .content-wrap {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 28px 6px !important;
        /* 移动端内边距稍小 */
    }

    .content-wrap:not(.full-width) {
        margin-left: 220px !important;
        width: calc(100% - 220px) !important;
    }
}

/* 目录隐藏时：正文占满所有屏幕尺寸 */
.content-wrap.full-width {
    margin-left: 30px !important;
    width: calc(100% - 30px) !important;
    max-width: 100% !important;
}

/* 目录层级样式（不变） */
#toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc h2 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    color: #2563eb;
}

#toc li.level-1 {
    padding-left: 0;
    margin: 12px 0 6px 0;
    font-weight: 700;
}

#toc li.level-2 {
    padding-left: 1.2em;
    margin: 2px 0 4px 0;
}

#toc li.level-3 {
    padding-left: 2.4em;
    margin: 2px 0 3px 0;
}

#toc li.level-4 {
    padding-left: 3.6em;
    margin: 2px 0 2px 0;
    font-size: 0.95em;
}

#toc li.level-5 {
    padding-left: 4.8em;
    margin: 2px 0 2px 0;
    font-size: 0.9em;
}

#toc li.level-6 {
    padding-left: 6.0em;
    margin: 2px 0 2px 0;
    font-size: 0.85em;
}

#toc li {
    border-left: 2px solid transparent;
    transition: border-left-color 0.2s;
}

#toc li.active {
    border-left-color: #2563eb;
}

#toc li.active a {
    color: #2563eb;
    font-weight: 600;
}

#toc a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
    display: inline-block;
    padding: 2px 0;
}

#toc a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* 复制按钮样式（不变） */
.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: #1d4ed8;
}

pre {
    position: relative;
    padding: 15px !important;
    margin: 10px 0 !important;
}

/* 图片放大遮罩层样式 */
.img-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    position: relative;
    /* 修改：扩大容器最大尺寸（给图片放大空间） */
    max-width: 95%;
    max-height: 95%;
}

/* 弹窗容器样式（仅补充关闭逻辑，保留原有） */
.img-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    outline: none;
}

/* 弹窗显示（通过:focus-within触发，无需JS） */
.img-modal:focus-within {
    display: flex;
}

/* modal-img核心样式（含缩放+关闭触发） */
.modal-img {
    /* 基础适配：解决竖图溢出 */
    max-height: 90vh;
    width: auto;
    max-width: 95vw;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
    
    /* 缩放过渡（顺滑切换） */
    transition: transform 0.2s ease;
    /* 初始状态100% */
    transform: scale(1);
    
    /* 提示可点击 */
    cursor: pointer;
}

.close-btn {
    position: absolute;
    top: -40px;
    right: -10px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

.close-btn:hover {
    color: #ccc;
}