h2 { counter-reset: h3counter; }
h3 { counter-reset: h4counter; }
h4 { counter-reset: h5counter; }
h5 { counter-reset: h6counter; }
h6 { }

/* 摘要等不编号区域 */
/*
    .no-tocnum 规则：
    1. 不显示编号
    2. 不触发计数器递增（通过覆盖 counter-increment）
*/
.no-tocnum h2:before,
.no-tocnum h3:before,
.no-tocnum h4:before,
.no-tocnum h5:before,
.no-tocnum h6:before,
h2.no-tocnum:before,
h3.no-tocnum:before,
h4.no-tocnum:before,
h5.no-tocnum:before,
h6.no-tocnum:before {
    content: none !important;
    counter-increment: none !important;
}

/* For TOC numbering */
.toc-number {
    display: inline-block;
    min-width: 25px;
    margin-right: 5px;
    font-weight: 600;
}

body { counter-reset: h2counter; }
/* 仅对未标记 no-tocnum 的标题应用自动编号 */
h2:not(.no-tocnum):before {
    counter-increment: h2counter;
    content: counter(h2counter) ".\00a0\00a0";
}
h3:not(.no-tocnum):before {
    counter-increment: h3counter;
    content: counter(h2counter) "." counter(h3counter) ".\00a0\00a0";
}
h4:not(.no-tocnum):before {
    counter-increment: h4counter;
    content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) ".\00a0\00a0";
}
h5:not(.no-tocnum):before {
    counter-increment: h5counter;
    content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) ".\00a0\00a0";
}
h6:not(.no-tocnum):before {
    counter-increment: h6counter;
    content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) "." counter(h6counter) ".\00a0\00a0";
}
