:root {
  --reading-size: 22px;
  --line-height: 1.65;

  --bg: #fbfaf6;
  --bg-elev: #ffffff;
  --bg-box: #f1ede2;
  --text: #1d1c1a;
  --text-muted: #66635c;
  --border: #d9d4c4;
  --rule: #ccc6b2;
  --accent: #9a5a1f;
  --shadow: 0 8px 28px rgba(40, 30, 10, 0.18);
}

html[data-theme="dark"] {
  --bg: #16181c;
  --bg-elev: #1d1f24;
  --bg-box: #23262d;
  --text: #e7e3da;
  --text-muted: #9a948a;
  --border: #353841;
  --rule: #2c2f37;
  --accent: #d2a36b;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { background: var(--bg); color: var(--text); scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Iowan Old Style", "Charter", "Source Serif Pro", Cambria, Georgia, serif;
  font-size: var(--reading-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", sans-serif;
  font-size: 14px;
}
.topbar a.home {
  color: var(--text); text-decoration: none; font-weight: 600;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px;
}
.topbar a.home:hover { background: var(--bg-box); }
.topbar .title { flex: 1; font-weight: 600; }
.topbar .controls { display: flex; gap: 6px; }
.btn {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 10px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--bg-box); }
.btn.icon { width: 32px; padding: 4px 0; text-align: center; font-weight: 600; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 2rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 5rem;
}

.toc {
  position: sticky;
  top: 4rem;
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding-right: 0.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  font-size: 0.88em;
}
.toc-head {
  font-variant: small-caps; letter-spacing: 0.06em;
  color: var(--accent); font-weight: 700;
  margin-bottom: 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--rule);
}
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-list li { margin: 0.15em 0; line-height: 1.4; }
.toc-list li a {
  color: var(--text); text-decoration: none;
  display: block;
  padding: 3px 6px; border-radius: 4px;
}
.toc-list li a:hover { background: var(--bg-box); color: var(--accent); }
.toc-list li.active a { color: var(--accent); font-weight: 600; }
.toc-list li.lvl0 { font-weight: 700; margin-top: 1.2em; }
.toc-list li.lvl1 { font-weight: 600; margin-top: 0.6em; padding-left: 0.4em; }
.toc-list li.lvl2 { padding-left: 1.4em; font-size: 0.96em; }
.toc-list li.lvl3 { padding-left: 2.4em; font-size: 0.92em; color: var(--text-muted); }

main {
  max-width: 44rem;
  padding-right: 1rem;
}
main img { max-width: 100%; height: auto; display: block; margin: 1.2em auto; border-radius: 6px; }

/* ---------- typography ---------- */
h1.heading_s {
  font-size: 2.4em; margin: 0 0 0.15em; letter-spacing: -0.01em;
  font-weight: 700;
}
.class_s3 {
  color: var(--text-muted); font-style: italic; margin: 0 0 1.6em;
  font-size: 0.98em;
}
.class_s4 { /* "Introduction" header */
  font-size: 1.5em; font-weight: 700; margin: 1.4em 0 0.5em;
  color: var(--accent);
}
.class_s5 { /* "Commentary", "Select Bibliography" */
  font-size: 1.7em; font-weight: 700; margin: 1.8em 0 0.6em;
  color: var(--accent); padding-top: 0.5em;
  border-top: 1px solid var(--rule);
}
.class_s7c { /* "Date and Historical Context", "Audience" */
  font-size: 1.15em; font-weight: 700; font-variant: small-caps;
  letter-spacing: 0.04em; margin: 1.6em 0 0.4em;
}
.class_s7c1 { /* "1. Introduction (1:1–17)" outline level 1 */
  font-size: 1.2em; font-weight: 700;
  margin: 1.8em 0 0.5em; color: var(--accent);
  padding-top: 0.6em;
}
.class_s7e {
  margin: 0 0 0.8em; text-align: justify; hyphens: auto;
  text-indent: 0;
}
.class_s2v { /* opening paragraph */
  margin: 0 0 1.2em; text-align: justify;
}
.caption_s7x {
  font-size: 0.85em; color: var(--text-muted); font-style: italic;
  text-align: center; max-width: 32rem; margin: 0.3em auto 1.5em;
  hyphens: none;
}
.class_s7k { text-align: center; margin: 1.4em 0; }
.class_sgu, .class_sgz, .class_sgr, .class_sgp { font-style: italic; }
.class_sgr { font-weight: 600; color: var(--accent); font-style: normal; }
.class_sgp { font-weight: 600; color: var(--text); font-style: normal; }
.class_sgy { font-weight: 600; color: var(--accent); }
.class_shc { font-style: italic; }
.class_set, .class_sev, .class_sf {
  margin: 0.3em 0;
  font-size: 0.95em;
  padding-left: 2em; text-indent: -2em;
  text-align: left; hyphens: none;
}

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .toc {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(20rem, 80vw);
    background: var(--bg-elev);
    border-left: 1px solid var(--border);
    padding: 4.5rem 1rem 1rem;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    z-index: 40;
    box-shadow: var(--shadow);
  }
  .toc.open { transform: translateX(0); }
  main { padding-right: 0; }
}
@media (min-width: 921px) {
  #toc-toggle { display: none; }
}
