.chapter-toc {
  background: #f5f7fa;
  border: 1px solid #e3e7ee;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  margin: 0 0 0.8rem 0;
}
.chapter-toc__title {
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.chapter-toc__controls {
  display: inline-flex;
  gap: 6px;
}
.chapter-toc__controls button {
  font-size: 0.85rem;
  padding: 2px 6px;
  border: 1px solid #c8ced8;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}
.chapter-toc__controls button:hover {
  background: #f0f0f0;
}
.chapter-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.chapter-toc__list > li {
  margin: 0.15rem 0;
}
.chapter-toc__list a {
  color: #0366d6;
  text-decoration: none;
}
.chapter-toc__list a:hover {
  text-decoration: underline;
}
.chapter-toc__sublist {
  list-style: disc;
  padding-left: 1.2rem;
  margin-top: 0.1rem;
}
.chapter-toc--collapsed .chapter-toc__list { display: none; }
html.dark-mode .chapter-toc {
  background: #2b2b2b;
  border-color: #3a3a3a;
}
html.dark-mode .chapter-toc__title { color: #f0f0f0; }
html.dark-mode .chapter-toc__list a { color: #66b3ff; }
html.dark-mode .chapter-toc__controls button {
  border-color: #4a4a4a;
  background: #404040;
  color: #fff;
}
html.dark-mode .chapter-toc__controls button:hover {
  background: #4a4a4a;
}

/* Collapsible sections */
.chapter-section.collapsed { display: none; }
.chapter-section__toggle {
  margin-left: 8px;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 4px;
  border: 1px solid #c8ced8;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}
html.dark-mode .chapter-section__toggle {
  border-color: #4a4a4a;
  background: #404040;
  color: #fff;
}
