.chapter-pages-body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 15% 15%, #fffdf7 0%, #f6f1e4 44%, #eee3ca 100%);
}

.chapter-pages-wrap,
.chapter-page-wrap {
  width: min(1000px, 92vw);
  margin: 0 auto;
  padding: 2rem 0 2.5rem;
}

.chapter-pages-header,
.chapter-page-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(95, 63, 35, 0.22);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: 0 12px 28px rgba(45, 31, 19, 0.14);
}

.chapter-index-grid {
  margin-top: 1rem;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
}

.chapter-item {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(95, 63, 35, 0.2);
  border-radius: 12px;
  padding: 0.9rem;
}

.chapter-item h2 {
  margin: 0.45rem 0;
  font-size: 1.02rem;
}

.chapter-item p {
  margin: 0.35rem 0;
}

.chapter-item a,
.back-link,
.chapter-page-topnav a,
.chapter-page-bottomnav a {
  color: #1f4c40;
  font-weight: 700;
}

.chapter-item-tag {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1f4c40;
  background: #e3efe8;
}

.chapter-page-topnav,
.chapter-page-bottomnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.5rem 0 1rem;
}

.chapter-page-bottomnav {
  margin-top: 1rem;
}

.chapter-page-card h1 {
  margin: 0.45rem 0 0.65rem;
}

.chapter-page-card h2 {
  margin: 0.9rem 0 0.45rem;
  font-size: 1.08rem;
}

.chapter-page-card ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.chapter-feature {
  margin-top: 0.95rem;
  border: 1px solid rgba(95, 63, 35, 0.18);
  border-radius: 12px;
  background: rgba(255, 252, 244, 0.9);
  padding: 0.8rem;
}

.chapter-feature h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.chapter-feature ul,
.chapter-feature ol {
  margin: 0;
  padding-left: 1.05rem;
}

.chapter-feature li {
  margin: 0.28rem 0;
  line-height: 1.35;
}

.historical-sidebar-list {
  display: grid;
  gap: 0.55rem;
}

.historical-sidebar {
  margin: 0;
  border: 1px solid rgba(95, 63, 35, 0.2);
  border-left: 4px solid #8a4a2f;
  border-radius: 10px;
  background: #fffdf8;
  padding: 0.56rem 0.62rem;
}

.historical-sidebar p {
  margin: 0;
  line-height: 1.4;
}

.chapter-feature-note {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
  color: #4f3d2d;
}

.chapter-feature-table-wrap {
  overflow-x: auto;
}

.chapter-feature-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.chapter-feature-table th,
.chapter-feature-table td {
  border: 1px solid rgba(95, 63, 35, 0.2);
  padding: 0.34rem 0.42rem;
  text-align: left;
  vertical-align: top;
}

.chapter-feature-table th {
  background: #f3e9d4;
}

@media (max-width: 700px) {
  .chapter-page-topnav,
  .chapter-page-bottomnav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }
}

/* ── Dark mode overrides ─────────────────────────────── */
[data-theme="dark"] .chapter-pages-body {
  background: radial-gradient(circle at 15% 15%, #1a130a 0%, #1e160c 44%, #221a10 100%);
}

[data-theme="dark"] .chapter-pages-header,
[data-theme="dark"] .chapter-page-card {
  background: rgba(30, 22, 12, 0.92);
  border-color: rgba(200, 160, 80, 0.14);
  color: #e8dcc8;
}

[data-theme="dark"] .chapter-item {
  background: rgba(36, 27, 14, 0.88);
  border-color: rgba(200, 160, 80, 0.16);
  color: #e8dcc8;
}

[data-theme="dark"] .chapter-item-tag {
  background: rgba(47, 93, 80, 0.28);
  color: #8ecfb0;
}

[data-theme="dark"] .chapter-item a,
[data-theme="dark"] .back-link,
[data-theme="dark"] .chapter-page-topnav a,
[data-theme="dark"] .chapter-page-bottomnav a {
  color: #8ecfb0;
}

[data-theme="dark"] .chapter-feature {
  background: rgba(36, 27, 14, 0.88);
  border-color: rgba(200, 160, 80, 0.15);
  color: #e8dcc8;
}

[data-theme="dark"] .historical-sidebar {
  background: rgba(39, 29, 15, 0.92);
  border-color: rgba(200, 160, 80, 0.18);
  border-left-color: #b06c45;
}

[data-theme="dark"] .historical-sidebar p {
  color: #dfcfb5;
}

[data-theme="dark"] .chapter-feature-note {
  color: #c8b898;
}

[data-theme="dark"] .chapter-feature-table th,
[data-theme="dark"] .chapter-feature-table td {
  border-color: rgba(200, 160, 80, 0.18);
  color: #e8dcc8;
}

[data-theme="dark"] .chapter-feature-table th {
  background: rgba(50, 35, 18, 0.9);
}

[data-theme="dark"] .chapter-page-card h1,
[data-theme="dark"] .chapter-page-card h2,
[data-theme="dark"] .chapter-pages-header h1 {
  color: #f0e4cc;
}

[data-theme="dark"] .chapter-pages-header .eyebrow {
  color: #6fae93;
}
