*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    overflow-x: clip;
    width: 100%;
}

:root {
    --bg-color: #fbfaf8;
    --text-main: #2b2b2b;
    --text-muted: #888378;
    --accent-color: #6a2c2a;
    --line-color: #e3dec9;
    --header-height: 70px;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 40px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Noto Serif SC', 'Songti SC', 'STSong', 'Source Han Serif SC', serif;
    line-height: 1.85;
    font-size: 17px;
    margin: 0;
    text-align: justify;
}

/* 核心布局：居中三栏网格 */
.layout-container {
    display: grid;
    grid-template-columns: 1fr minmax(auto, 760px) 1fr;
    gap: 4rem;
    padding: 5vw 40px;
}

/* 左侧边注导航 (Marginalia) */
aside.editorial-index {
    position: relative;
    justify-self: end;
    width: 100%;
    max-width: 180px;
}

.toc-nav {
    position: sticky;
    top: 5vw;
    padding-left: 1rem;
    border-left: 1px solid rgba(227, 222, 201, 0.4);
}

.toc-nav ul { list-style: none; padding: 0; margin: 0; }
.toc-nav li { margin-bottom: 1.5rem; position: relative; }

.toc-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 1.05rem;
    transition: all 0.4s ease;
    display: block;
    letter-spacing: 1px;
}

.toc-nav a:hover { color: #4a4a4a; }

.toc-nav a.active {
    color: var(--accent-color);
    font-weight: 600;
    transform: translateX(4px);
}

.toc-nav a::before {
    content: "✦";
    position: absolute;
    left: -1.75rem;
    color: var(--accent-color);
    font-size: 0.8rem;
    opacity: 0;
    transition: all 0.4s ease;
    transform: scale(0.5);
}

.toc-nav a.active::before { opacity: 1; transform: scale(1); }

/* 右侧主体内容 (锁定在中间栏) */
main.content-area {
    grid-column: 2;
}

/* 标题与排版细节 */
.meta-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    display: block;
}

h1 {
    font-size: 2.2rem;
    line-height: 1.4;
    color: #1a1a1a;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 2.5rem;
    letter-spacing: 1px;
}

h2 {
    font-size: 1.4rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-top: 4rem;
    margin-bottom: 2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--line-color);
    letter-spacing: 0.5px;
}

h3 {
    font-size: 1.15rem;
    color: #111;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

h4 {
    font-size: 1.05rem;
    color: #333;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--line-color);
    padding-left: 10px;
}

p { margin-bottom: 1.5rem; letter-spacing: 0.3px; }
strong { font-weight: 600; color: #111; }
em { font-style: italic; color: var(--text-muted); }

ul, ol { padding-left: 1.5rem; margin-bottom: 1.5rem; }
li { margin-bottom: 0.8rem; padding-left: 0.5rem; }
li::marker { color: var(--accent-color); }

/* 首字下沉 */
.drop-cap::first-letter {
    font-size: 3.8rem;
    float: left;
    line-height: 1;
    margin-right: 12px;
    margin-top: 4px;
    color: var(--accent-color);
    font-weight: 700;
}

/* 优雅的分割线 */
.ornament-separator {
    text-align: center;
    margin: 4rem 0;
    color: #c4beaa;
    font-size: 1.2rem;
    letter-spacing: 1.5rem;
    user-select: none;
}
.ornament-separator::after {
    content: "✦ ✦ ✦";
    margin-left: 1.5rem;
}

/* 结尾特殊排版 */
.conclusion {
    margin-top: 5rem;
    padding: 3rem;
    background-color: rgba(227, 222, 201, 0.15);
    border-top: 1px solid var(--line-color);
    border-bottom: 1px solid var(--line-color);
}

.verse-highlight {
    display: block;
    margin-top: 2.5rem;
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--accent-color);
    text-align: center;
    line-height: 1.6;
    letter-spacing: 1px;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 3rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 2px;
    transition: color 0.3s;
}
.back-link:hover { color: var(--accent-color); }

/* =========================================
   全局顶部导航 (古典页眉)
========================================= */
.global-header {
    position: sticky;
    top: 0;
    width: 100%;
    height: 60px;
    background-color: rgba(251, 250, 248, 0.85); /* 象牙白底色，85%透明度 */
    backdrop-filter: blur(10px); /* 优雅的毛玻璃模糊效果 */
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-color);
    z-index: 999;
}

.header-container {
    max-width: 1160px; /* 控制最大宽度，使其与下方内容对齐 */
    margin: 0 auto;
    padding: 0 40px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 左侧：书名 */
.site-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 2px;
}

/* 右侧：卷宗链接 */
.volume-links {
    display: flex;
    gap: 2rem;
}

.volume-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    letter-spacing: 1px;
    transition: color 0.3s ease;
}

.volume-links a:hover {
    color: var(--text-main);
}

.volume-links a.active {
    color: var(--text-main);
    font-weight: 600;
    border-bottom: 1px solid var(--accent-color);
    padding-bottom: 4px;
}

/* 调整向下滚动的锚点缓冲，防止顶部导航挡住标题 */
html {
    scroll-padding-top: 100px; 
}

/* =========================================
   移动端响应式调整
========================================= */
@media (max-width: 900px) {
    /* 取消三栏网格布局 */
    .layout-container {
        display: block;
        padding: 0;
    }

    main.content-area {
        padding: 2rem 25px 4rem 25px;
    }

    /* 1. 顶部全局导航：取消悬浮，跟随页面滚走，释放空间 */
    .global-header {
        position: relative; /* 核心修改：取消 sticky */
        z-index: 1;
    }

    .header-container {
        padding: 0 25px;
    }

    .site-title {
        display: none; 
    }

    .volume-links {
        width: 100%;
        justify-content: space-between;
        gap: 0;
    }

    /* 2. 章节导航栏：变为移动端唯一悬浮的导航，吸附在屏幕最顶部 */
    aside.editorial-index {
        width: 100%;
        max-width: 100%;
        position: sticky;
        top: 0; /* 紧贴屏幕顶部 */
        background-color: rgba(251, 250, 248, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 100;
        border-bottom: 1px solid var(--line-color);
        height: 55px; /* 稍微调窄一点，更精致 */
        display: flex;
        align-items: center;
        /* 注意：删除了之前导致不对称的 mask-image 渐变遮罩 */
    }

    .toc-nav {
        position: relative;
        top: 0;
        width: 100%;
        padding: 0 25px;
        border-left: none;
    }

    .toc-nav ul {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        gap: 2rem;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .toc-nav ul::-webkit-scrollbar { display: none; }

    .toc-nav li { margin-bottom: 0; }
    .toc-nav a { font-size: 0.95rem; }
    
    .toc-nav a.active { 
        transform: none; 
        border-bottom: 2px solid var(--accent-color); 
        padding-bottom: 4px; 
    }
    .toc-nav a::before { display: none; }
    
    /* 排版细节微调 */
    h1 { font-size: 1.8rem; margin-top: 0; }
    .drop-cap::first-letter { font-size: 3.2rem; }
    .conclusion { padding: 2rem 1.5rem; }
    .verse-highlight { font-size: 1.15rem; }
    
    /* 修正锚点跳转时的缓冲高度，仅留出一个导航栏的高度 */
    html {
        scroll-padding-top: 80px; 
    }

    ul, ol {
        /* 极大地减少左侧缩进，仅保留容纳圆点/数字的空间 */
        padding-left: 1.1rem; 
        margin-bottom: 1.5rem;
    }

    li {
        /* 减少圆点与文字之间的距离 */
        padding-left: 0.1rem; 
        margin-bottom: 0.8rem;
    }

    /* 针对多层嵌套列表（比如 A 里面的 1 里面的 a）进一步压缩缩进 */
    ul ul, ol ol, ul ol, ol ul {
        padding-left: 1rem;
        margin-top: 0.5rem;
    }
}

.next-chapter-link {
    display: inline-block;
    margin-top: 3.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-color);
    text-decoration: none;
    letter-spacing: 2px;
    padding-bottom: 5px;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.next-chapter-link:hover {
    color: #1a1a1a;
    border-bottom: 1px solid var(--accent-color);
    transform: translateX(5px); /* 悬浮时微微向右移动，暗示“前进” */
}