* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; width: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f0e8;
    color: #3a2e1f;
    line-height: 1.8;
    overflow: hidden;
}
.app { display: flex; height: 100vh; width: 100%; }

/* ========== 左侧菜单 ========== */
.sidebar {
    width: 300px;
    background: #2c241b;
    color: #d4c5a9;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    overflow-y: scroll;
    overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: #2c241b; }
.sidebar::-webkit-scrollbar-thumb { background: #5a4a35; border-radius: 3px; }
.sidebar { scrollbar-width: thin; scrollbar-color: #5a4a35 #2c241b; }

.sidebar-header {
    padding: 22px 20px;
    text-align: center;
    font-size: 20px;
    letter-spacing: 8px;
    color: #e8d5b7;
    border-bottom: 1px solid #4a3d2e;
    flex-shrink: 0;
    background: #2c241b;
    position: sticky;
    top: 0;
    z-index: 2;
    font-weight: bold;
}
.sidebar-header a { color: inherit; text-decoration: none; }

.nav-tree { padding: 0 0 30px 0; flex: 1; }

.tree-label.lv1 {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; font-size: 15px; font-weight: bold;
    color: #e8d5b7; background: #2c241b;
    cursor: pointer; user-select: none;
    border-bottom: 1px solid #3a3024; transition: background 0.2s;
}
.tree-label.lv1:hover { background: #3d3225; }
.tree-label.lv2 {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px 10px 35px; font-size: 14px; color: #b8a88a;
    background: #262018; cursor: pointer; user-select: none;
    border-bottom: 1px solid #322a20; transition: background 0.2s;
}
.tree-label.lv2:hover { background: #3d3225; }
.tree-label.lv3 {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px 8px 50px; font-size: 13px; color: #9a8a70;
    background: #262018; cursor: pointer; user-select: none;
    border-bottom: 1px solid #322a20; transition: background 0.2s;
}
.tree-label.lv3:hover { background: #3d3225; }
.tree-label.lv4 {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 20px 7px 65px; font-size: 13px; color: #8a7a60;
    background: #262018; cursor: pointer;
    border-bottom: 1px solid #322a20;
}

.toggle-icon {
    font-style: normal; font-size: 11px; color: #b8a88a;
    transition: transform 0.2s; display: inline-block;
    flex-shrink: 0; margin-left: 8px;
}
.tree-label.open .toggle-icon { transform: rotate(90deg); }

.tree-leaf.lv1 a, .tree-leaf.lv1 .leaf-text {
    display: block; padding: 14px 20px; font-size: 15px; font-weight: bold;
    color: #e8d5b7; background: #2c241b; text-decoration: none;
    border-bottom: 1px solid #3a3024;
}
.tree-leaf.lv2 a, .tree-leaf.lv2 .leaf-text {
    display: block; padding: 10px 20px 10px 35px; font-size: 14px;
    color: #b8a88a; background: #262018; text-decoration: none;
    border-bottom: 1px solid #322a20;
}
.tree-leaf.lv3 a, .tree-leaf.lv3 .leaf-text {
    display: block; padding: 8px 20px 8px 50px; font-size: 13px;
    color: #9a8a70; background: #262018; text-decoration: none;
    border-bottom: 1px solid #322a20;
}
.tree-leaf.lv4 a, .tree-leaf.lv4 .leaf-text {
    display: block; padding: 7px 20px 7px 65px; font-size: 13px;
    color: #8a7a60; background: #262018; text-decoration: none;
    border-bottom: 1px solid #322a20;
}
.tree-leaf a:hover { background: #3d3225; color: #fff; }
.tree-leaf a.active {
    background: #5a4a35; color: #fff;
    border-left: 3px solid #c9a96e;
}

.sidebar-footer {
    padding: 15px 20px 20px;
    border-top: 1px solid #3a3024;
    flex-shrink: 0; background: #2c241b;
}
.sidebar-footer ul {
    list-style: none; display: flex;
    justify-content: center; align-items: center;
    gap: 40px; padding: 0;
}
.sidebar-footer li { margin: 0; }
.sidebar-footer a {
    color: #9a8a70; text-decoration: none; font-size: 13px;
    padding: 8px 0; transition: color 0.2s; white-space: nowrap;
}
.sidebar-footer a:hover { color: #e8d5b7; }
.sidebar-footer .copyright {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px dashed #3a3024;
    font-size: 12px; color: #6a5a45;
    line-height: 1.6; text-align: center;
}

/* ========== 右侧正文 ========== */
.main-content {
    flex: 1; height: 100vh; overflow-y: auto;
    padding: 40px 80px;
}
.main-content::-webkit-scrollbar { width: 8px; }
.main-content::-webkit-scrollbar-track { background: #f5f0e8; }
.main-content::-webkit-scrollbar-thumb { background: #d4c5a9; border-radius: 4px; }
.main-content { scrollbar-width: thin; scrollbar-color: #d4c5a9 #f5f0e8; }

.content-inner { max-width: 780px; margin: 0 auto; }

.breadcrumb {
    font-size: 13px; color: #8a7a60;
    margin-bottom: 20px; padding-bottom: 15px;
    border-bottom: 1px dashed #d4c5a9;
}
.content-title {
    font-size: 26px; text-align: center;
    margin-bottom: 30px; color: #2c241b;
    letter-spacing: 2px; font-weight: bold;
}
.content-body { font-size: 17px; line-height: 2.2; color: #3a2e1f; }
.content-body p { margin-bottom: 1em; text-indent: 2em; }
.content-body h1, .content-body h2, .content-body h3, .content-body h4 {
    margin: 20px 0 10px; color: #2c241b;
}
.content-body h5 {
    text-align: center;
    color: #9a8a70;
    font-weight: normal;
    font-size: 15px;
    margin: 10px 0 25px;
    letter-spacing: 1px;
}
.content-body pre {
    background: #ebe3d5; padding: 15px 20px;
    border-radius: 6px; overflow-x: auto;
    font-family: "KaiTi", "STKaiti", "楷体", serif;
    font-size: 16px; line-height: 2; margin: 15px 0;
    white-space: pre-wrap; word-wrap: break-word;
}
.content-body code { font-family: inherit; }
.empty-tip {
    text-align: center; padding: 100px 20px;
    color: #8a7a60; font-size: 16px;
}

.page-nav {
    display: flex; justify-content: space-between;
    gap: 15px; margin-top: 50px;
    padding-top: 30px; border-top: 1px dashed #d4c5a9;
}
.page-nav-btn {
    flex: 1; display: flex; align-items: center; gap: 10px;
    padding: 15px 20px; background: #ebe3d5; border-radius: 8px;
    text-decoration: none; color: #3a2e1f;
    transition: background 0.2s, transform 0.2s;
    min-height: 70px;
}
.page-nav-btn:hover { background: #e0d5c0; transform: translateY(-2px); }
.page-nav-btn.next { justify-content: flex-end; text-align: right; }
.page-nav-btn.disabled { visibility: hidden; }
.nav-arrow { font-size: 24px; color: #8a7a60; }
.nav-text { display: flex; flex-direction: column; }
.nav-label { font-size: 12px; color: #8a7a60; }
.nav-title { font-size: 14px; color: #2c241b; font-weight: bold; margin-top: 4px; }

/* ==================== 首页 ==================== */
.home-content { font-size: 17px; line-height: 2.2; color: #3a2e1f; }
.home-content h1 {
    font-size: 26px; text-align: center;
    margin-bottom: 15px; color: #2c241b;
    letter-spacing: 6px; font-weight: bold;
}
.home-content .home-subtitle {
    text-align: center;
    color: #8a7a60;
    text-indent: 0;
    letter-spacing: 4px;
    margin-bottom: 35px;
    font-size: 14px;
}
.home-content h2 {
    font-size: 16px; color: #8a7a60;
    margin: 40px 0 18px; font-weight: normal;
    text-align: center;
    letter-spacing: 4px;
}
.home-content p { margin-bottom: 1em; text-indent: 2em; }
.home-content .quote {
    font-family: "KaiTi", "STKaiti", serif;
    font-size: 18px; text-align: center;
    color: #8a2a2a; padding: 20px 0 5px;
    letter-spacing: 2px; line-height: 2; text-indent: 0;
}
.home-content .verse {
    font-family: "KaiTi", "STKaiti", serif;
    font-size: 15px; text-align: center;
    color: #8a7a60; line-height: 2;
    padding: 0 0 20px; text-indent: 0;
}

/* 返回顶部 */
.back-top {
    position: fixed; right: 30px; bottom: 30px;
    width: 46px; height: 46px;
    background: #2c241b; color: #e8d5b7;
    border: none; border-radius: 50%;
    font-size: 20px; cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.2s;
    z-index: 900;
}
.back-top.show { opacity: 1; visibility: visible; }
.back-top:hover { background: #5a4a35; transform: translateY(-3px); }

/* 移动端 */
.menu-toggle {
    display: none; position: fixed;
    top: 15px; left: 15px; z-index: 1001;
    width: 42px; height: 42px;
    background: #2c241b; color: #e8d5b7;
    border: none; border-radius: 6px;
    font-size: 20px; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.mobile-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 999;
}
@media (max-width: 800px) {
    .app {
        display: block;
        height: auto;
        min-height: 100vh;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s;
        overflow-y: auto;
    }
    .sidebar.open { left: 0; }
    .menu-toggle { display: block; }
    .mobile-overlay.show { display: block; }

    .main-content {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding: 70px 20px 40px;
        overflow-y: visible;
    }
    .content-inner {
        max-width: 100%;
    }
    .content-title { font-size: 20px; }
    .content-body { font-size: 16px; line-height: 2; }
    .home-content { font-size: 16px; line-height: 2; }
    .home-content h1 { font-size: 22px; }
    .home-content h2 { font-size: 17px; }
    .home-content .card-grid {
        grid-template-columns: 1fr;
        max-width: 100%;
    }
    .home-content .card { padding: 12px 14px; min-height: 48px; }
    .home-content .card-title { font-size: 14px; }
    .home-content .card-category { min-height: 90px; }
    .home-content .card-category .card-title { font-size: 15px; }
    .back-top { right: 15px; bottom: 15px; }
    .page-nav { flex-direction: column; }
}



/* ==================== 首页卡片样式 ==================== */
.home-content .card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
    margin: 0 auto 30px;
    max-width: 660px;
    border-top: 1px dashed #d4c5a9;
}
.home-content .card-grid > * {
    border-bottom: 1px dashed #d4c5a9;
}
.home-content .card-grid > *:nth-child(odd) {
    border-right: 1px dashed #d4c5a9;
}

.home-content .card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-radius: 0;
    text-decoration: none;
    color: #3a2e1f;
    transition: background 0.2s;
    min-height: 56px;
}
.home-content .card:hover {
    background: #ebe3d5;
}

.home-content .card-num {
    font-size: 11px;
    color: #b8a88a;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    line-height: 1;
}

.home-content .card-title {
    font-size: 15px;
    font-weight: normal;
    color: #3a2e1f;
    line-height: 1.5;
    flex: 1;
    word-break: break-word;
}

/* 经典分类的卡片：竖排 */
.home-content .card-category {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 16px 20px;
    min-height: 90px;
}
.home-content .card-category .card-title {
    font-size: 16px;
    color: #2c241b;
    margin-bottom: 2px;
    flex: none;
}
.home-content .card-category .card-desc {
    font-size: 12px;
    color: #8a7a60;
    line-height: 1.6;
    font-weight: normal;
}
.home-content .card-category .card-count {
    font-size: 12px;
    color: #b87a3a;
    font-weight: normal;
    letter-spacing: 1px;
    margin-top: 4px;
}
/* ========== 移动端滚动修复（追加）========== */
@media (max-width: 800px) {
    html, body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: 100% !important;
    }
    body {
        overflow-y: auto !important;
    }
    .app {
        height: auto !important;
        min-height: 100vh !important;
        display: block !important;
    }
    .main-content {
        overflow-y: visible !important;
        height: auto !important;
        min-height: 100vh !important;
    }
}
