/* 章番号（auto-numbering for headings） */
:root {
  counter-reset: h1;
}
h1 { counter-reset: h2; }
h2 { counter-reset: h3; }
h3 { counter-reset: h4; }
h4 { counter-reset: h5; }
h5 { counter-reset: h6; }

h1::before {
  counter-increment: h1;
  content: counter(h1) ". ";
}
h2::before {
  counter-increment: h2;
  content: counter(h1) "." counter(h2) " ";
}
h3::before {
  counter-increment: h3;
  content: counter(h1) "." counter(h2) "." counter(h3) " ";
}
h4::before {
  counter-increment: h4;
  content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) " ";
}
h5::before {
  counter-increment: h5;
  content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " ";
}
h6::before {
  counter-increment: h6;
  content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) " ";
}

/* --- 目次（Table of Contents）を階層番号付きにする --- */
.toc {
  border: 1px solid #ddd;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #fafafa;
  font-size: 0.95rem;
}

.toc ul,
.toc ol {
  list-style: none !important;
  margin: 0.25rem 0 0.25rem 1.25rem;
  padding-left: 0;
  counter-reset: item;
}

.toc li {
  list-style: none !important;
  counter-increment: item;
  margin: 0.15rem 0;
}

.toc ul {
  list-style: none;
  margin: 0.25rem 0 0.25rem 1.25rem;
  padding-left: 0;
  /* 各ULでカウンタをリセット（reset counter per level） */
  counter-reset: item;
}

/* 各LIでカウンタを進め、先頭に 1. / 1.1 / 1.1.1 を表示 */
.toc li {
  counter-increment: item;
  margin: 0.15rem 0;
}
.toc li::before {
  content: counters(item, ".") ". ";
  margin-right: 0.25rem;
}

.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

:target { scroll-margin-top: 80px; }


