:root {
  --bg: #fbfaf6;
  --surface: #ffffff;
  --text: #1f1b16;
  --muted: #6b6258;
  --accent: #540808;
  --accent-soft: #f3e7e2;
  --rule: #fcba03;
  --border: #ddd5c8;
  --row: #edf6ed;
  --breakout: #e6f0e6;
  --link: #8a1c1c;
  --sidebar-width: 17rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #201c16;
    --text: #e9e3d8;
    --muted: #a39a8c;
    --accent: #e08a7a;
    --accent-soft: #2e2219;
    --rule: #b8890a;
    --border: #3b342a;
    --row: #1f2a1f;
    --breakout: #1d271d;
    --link: #f0a090;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
}

a { color: var(--link); }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.site-nav {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.site-title {
  display: block;
  margin-bottom: 1rem;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
}
.site-nav summary {
  cursor: pointer;
  padding: 0.25rem 0;
  list-style-position: outside;
}
.nav-version { margin-bottom: 0.5rem; }
.nav-version > summary {
  font-weight: 700;
  color: var(--accent);
}
.nav-group { margin-left: 0.75rem; }
.nav-group > summary { font-weight: 600; }
.site-nav ul {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0 0 0 0.75rem;
  border-left: 1px solid var(--border);
}
.site-nav li a {
  display: block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
}
.site-nav li a:hover { background: var(--accent-soft); }
.site-nav li a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Content */
.content {
  width: 100%;
  max-width: 50rem;
  padding: 2rem 2.5rem 4rem;
}
.content h2, .content h3, .content h4, .content h5 {
  color: var(--accent);
  line-height: 1.25;
  scroll-margin-top: 1rem;
}
.content h2 {
  font-size: 2rem;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--rule);
}
.content h2:first-child { margin-top: 0; }
.content h3 { font-size: 1.45rem; margin: 2rem 0 0.75rem; }
.content h4 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
.content h5 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
.content img { max-width: 100%; height: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1.25rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}
th, td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
th {
  border-bottom: 2px solid var(--accent);
  font-weight: 700;
}
tbody tr:nth-child(even) { background: var(--row); }

.dndtab { margin: 1.5rem 0; overflow-x: auto; }
.dndtab-title {
  margin: 0;
  font-variant-caps: small-caps;
  font-weight: 700;
  font-size: 1.15rem;
}

.flush-block ul, .flush-block ol { list-style: none; padding-left: 0; }
.flush-block li { margin-bottom: 0.5rem; }

.breakoutbox {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border-top: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  background: var(--breakout);
}
.breakoutbox-title {
  margin-top: 0;
  font-variant-caps: small-caps;
}

.boxed-text {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  background: var(--surface);
}

/* Monster stat blocks */
.statbox {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.95rem;
  line-height: 1.45;
}
.statbox h4 { margin: 0; font-size: 1.35rem; }
.statbox > p { margin: 0.4rem 0; }
.statbox > p + p { padding-top: 0.4rem; border-top: 2px solid var(--accent); }
.statbox strong { color: var(--accent); }
.statbox table {
  margin: 0.4rem 0;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  text-align: center;
}
.statbox td { text-align: center; padding: 0.15rem; }
.statbox tr:first-child td { color: var(--accent); font-weight: 700; }
.statbox tbody tr:nth-child(even) { background: none; }
.statbox-section {
  margin: 1rem 0 0.4rem;
  border-bottom: 1px solid var(--rule);
  color: var(--accent);
  font-variant-caps: small-caps;
  font-size: 1.2rem;
}

/* Footer */
.site-footer {
  padding: 1rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
}
.site-footer p { margin: 0; }
.site-footer a { color: inherit; }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .site-nav {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content, .site-footer { padding-left: 1rem; padding-right: 1rem; }
  .content h2 { font-size: 1.6rem; }
}
