/* 段落间距 */
#cnblogs_post_body p {
    margin-bottom: 1.2em !important;
    line-height: 1.8 !important;
}

/* 标题前后间距 */
#cnblogs_post_body h1 {
    margin-top: 40px !important;
    margin-bottom: 20px !important;
}
#cnblogs_post_body h2 {
    margin-top: 35px !important;
    margin-bottom: 18px !important;
}
#cnblogs_post_body h3 {
    margin-top: 28px !important;
    margin-bottom: 14px !important;
}
#cnblogs_post_body h4 {
    margin-top: 22px !important;
    margin-bottom: 10px !important;
}

/* ---------- 浮动按钮 ---------- */
.floating-btn {
    position: fixed;
    z-index: 1000;
}
#top-btn {
    right: 20px;
    top: 120px;
}
#toc-toggle-btn {
    right: 20px;
    top: 162px;
}
.floating-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    color: #555;
    transition: all .2s;
    user-select: none;
}
.floating-btn:hover {
    background: #f5f5f5;
    color: #165dff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.floating-btn.active {
    color: #fff;
    background: #165dff;
    border-color: #165dff;
}

/* ---------- 目录面板 ---------- */
#custom-toc {
    position: fixed;
    right: 20px;
    top: 166px;
    width: max-content;
    min-width: 160px;
    max-width: min(50vw, 420px);
    max-height: calc(70vh - 60px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #eef0f2;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    font-size: 13px;
    z-index: 999;
    line-height: 1.6;
    transform-origin: top right;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95) translateY(-8px);
    transition: opacity .2s, visibility .2s, transform .2s;
    pointer-events: none;
}
#custom-toc.open {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}
#custom-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
#custom-toc li {
    margin: 4px 0;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#custom-toc a {
    color: #4e5969;
    text-decoration: none;
    transition: color .2s;
}
#custom-toc a:hover { color: #165dff; }
#custom-toc a.active { color: #165dff; font-weight: 500; }

/* 窄屏隐藏 */
@media (max-width: 768px) {
    #toc-btn-group { display: none; }
    #custom-toc { display: none; }
}

/* ---------- 代码折叠按钮 ---------- */
.code-collapse-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: #f9f9f9;
    border: 1px dashed #dcdcdc;
    color: #888;
    cursor: pointer;
    padding: 6px 0;
    margin-top: 5px;
    font-size: 13px;
    transition: background .3s;
}
.code-collapse-btn:hover {
    background: #eee;
    color: #333;
}
.code-folded pre,
.code-folded .cnblogs_code {
    max-height: 260px;
    overflow: hidden !important;
}
