:root {
  color-scheme: light;
  --navy: #102b47;
  --navy-2: #183e61;
  --ink: #192b3b;
  --muted: #607180;
  --paper: #f5f7f8;
  --white: #ffffff;
  --line: #d7e0e6;
  --gold: #c8933d;
  --gold-soft: #f3e7d0;
  --blue-soft: #e7f0f5;
  --focus: #0b6a91;
  --shadow: 0 14px 36px rgba(16, 43, 71, .09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(16, 43, 71, .025) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

button, input, select { font: inherit; }

button, select { cursor: pointer; }

a { color: var(--navy-2); text-underline-offset: 3px; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(11, 106, 145, .32);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: .7rem 1rem;
  color: var(--white);
  background: var(--navy);
}

.skip-link:focus { top: 1rem; }

.masthead {
  color: var(--white);
  background:
    radial-gradient(circle at 78% 20%, rgba(200, 147, 61, .22), transparent 28%),
    linear-gradient(120deg, #0b223a, var(--navy-2));
  border-bottom: 4px solid var(--gold);
}

.masthead-inner {
  width: min(1180px, calc(100% - 2rem));
  min-height: 220px;
  margin: 0 auto;
  padding: 2.5rem 0 2.2rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.6rem;
}

.brand-mark {
  width: 74px;
  height: 96px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .42);
  border-top: 4px solid var(--gold);
  color: #f1d8a6;
  font-family: Georgia, serif;
  font-size: 2.5rem;
}

.eyebrow {
  margin: 0 0 .4rem;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.15;
}

h1 { font-size: clamp(2.25rem, 5vw, 4.8rem); letter-spacing: -.035em; }
h1 span { color: #f0cf91; white-space: nowrap; }
.intro { margin: .7rem 0 0; color: #d8e4eb; font-size: 1.05rem; }

.chapter-signposts {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: .5rem;
}

.chapter-signposts span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, .24);
  color: #e9d3a8;
  font-family: Georgia, serif;
  font-size: 1.15rem;
}

.workspace {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  align-items: start;
  gap: 2.4rem;
}

.explorer {
  position: sticky;
  top: 1rem;
  padding: 1.25rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  box-shadow: var(--shadow);
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--navy);
}

.view-button {
  min-height: 44px;
  padding: .55rem .4rem;
  border: 0;
  color: var(--navy);
  background: var(--white);
  font-size: .84rem;
  font-weight: 750;
  line-height: 1.25;
}

.view-button + .view-button { border-left: 1px solid var(--navy); }
.view-button.active { color: var(--white); background: var(--navy); }

.control-group { margin-top: 1.4rem; }

.control-group label, .control-label {
  display: block;
  margin-bottom: .45rem;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 750;
}

.search-wrap { position: relative; }

input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #aebdc7;
  border-radius: 0;
  color: var(--ink);
  background: var(--white);
}

input { padding: .65rem 2.3rem .65rem .75rem; }
select { padding: .65rem 2rem .65rem .75rem; }
.search-glyph { position: absolute; right: .8rem; top: .55rem; color: var(--muted); font-size: 1.25rem; }

.chapter-filter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  border: 1px solid #aebdc7;
  background: #aebdc7;
}

.chapter-button {
  min-height: 42px;
  padding: .35rem;
  border: 0;
  border-right: 0;
  color: var(--navy);
  background: var(--white);
  font-weight: 800;
}

.chapter-button.active { color: var(--white); background: var(--navy-2); }

.reset-button {
  width: 100%;
  margin-top: 1rem;
  padding: .65rem;
  border: 1px solid var(--navy);
  color: var(--navy);
  background: transparent;
  font-weight: 750;
}

.reading-note { margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.reading-note-title { margin: 0 0 .25rem; color: var(--navy); font-weight: 800; }
.reading-note p:not(.reading-note-title) { margin: 0 0 .6rem; color: var(--muted); font-size: .9rem; }
.reading-note a { font-size: .9rem; font-weight: 750; }

.study-header {
  min-height: 78px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.study-header h2 { color: var(--navy); font-size: clamp(1.7rem, 3vw, 2.6rem); }
.result-count { margin: 0; color: var(--muted); white-space: nowrap; font-weight: 700; }

.active-context {
  margin: 1.15rem 0 0;
  padding: .85rem 1rem;
  border-left: 4px solid var(--gold);
  background: var(--gold-soft);
  color: #594421;
}

.section-block { margin-top: 2rem; }

.section-heading {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  margin-bottom: .9rem;
}

.section-heading h3 { color: var(--navy); font-size: 1.6rem; }
.section-heading span { color: var(--muted); font-size: .82rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.axis-intro {
  max-width: 720px;
  margin: -.25rem 0 1rem;
  color: var(--muted);
}

.theme-card {
  margin-bottom: .75rem;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 7px 22px rgba(16, 43, 71, .055);
}

.theme-card[open] { border-left: 4px solid var(--gold); }

.theme-card summary {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .85rem;
  min-height: 76px;
  padding: .9rem 3.2rem .9rem 1rem;
  list-style: none;
  cursor: pointer;
}

.theme-card summary::-webkit-details-marker { display: none; }

.theme-card summary::after {
  content: "+";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--navy-2);
  font-size: 1.55rem;
  line-height: 1;
}

.theme-card[open] summary::after { content: "−"; }

.chapter-badge {
  min-width: 48px;
  padding: .35rem .45rem;
  color: var(--white);
  background: var(--navy-2);
  text-align: center;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .04em;
}

.summary-title { min-width: 0; }
.summary-title h4 { color: var(--ink); font-size: 1.08rem; font-family: inherit; font-weight: 780; line-height: 1.35; }
.summary-title p { margin: .22rem 0 0; color: var(--muted); font-size: .86rem; }

.verse-ref {
  color: var(--navy-2);
  font-size: .82rem;
  font-weight: 750;
  white-space: nowrap;
}

.theme-body { padding: .1rem 1.25rem 1.35rem 4.95rem; }
.theme-body p { margin: .65rem 0 0; }

.theme-points { margin: .75rem 0 0; padding-left: 1.2rem; }
.theme-points li { margin: .35rem 0; }

.takeaway {
  margin-top: 1rem !important;
  padding: .8rem 1rem;
  border-left: 3px solid var(--navy-2);
  background: var(--blue-soft);
  color: var(--navy);
}

.caution { color: #66512f; font-size: .94rem; }

.axis-label {
  display: inline-block;
  margin-top: .9rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.prologue-mode .explorer .control-group,
.prologue-mode .explorer .reset-button { display: none; }

.prologue-hero {
  margin-top: 2rem;
  padding: clamp(1.5rem, 4vw, 2.8rem);
  color: var(--white);
  background:
    linear-gradient(110deg, rgba(200, 147, 61, .16), transparent 42%),
    var(--navy);
  border-top: 5px solid var(--gold);
}

.prologue-label,
.section-index {
  margin: 0 0 .45rem;
  color: var(--gold);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.prologue-hero h3,
.prologue-transition h3 { font-size: clamp(1.7rem, 3vw, 2.55rem); }
.prologue-hero > p:not(.prologue-label) { max-width: 760px; margin: .9rem 0 0; color: #dce7ed; }

.prologue-hero aside {
  max-width: 790px;
  margin-top: 1.35rem;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--gold);
  color: #ebf1f4;
  background: rgba(255, 255, 255, .075);
}

.prologue-hero aside strong { display: block; margin-bottom: .2rem; color: #f0cf91; }
.prologue-section { margin-top: 3rem; }

.structural-heading {
  align-items: end;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line);
}

.structural-heading > div { display: flex; align-items: baseline; gap: .75rem; }
.structural-heading .section-index { margin: 0; }

.movement-list {
  position: relative;
  display: grid;
  gap: .8rem;
}

.movement-card {
  display: grid;
  grid-template-columns: 115px minmax(0, 1fr);
  gap: 1.2rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy-2);
  background: var(--white);
  box-shadow: 0 7px 22px rgba(16, 43, 71, .045);
}

.movement-marker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-right: 1px solid var(--line);
}

.movement-marker span { color: var(--gold); font-family: Georgia, serif; font-size: 1.7rem; }
.movement-marker strong { margin-top: .2rem; color: var(--navy); font-size: .82rem; }
.movement-card h4 { color: var(--navy); font-family: inherit; font-size: 1.15rem; font-weight: 800; }
.movement-card p { margin: .4rem 0 0; }
.movement-outcome { color: var(--navy-2); font-weight: 700; }

.discourse-grid,
.interlude-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.discourse-card,
.interlude-card { padding: 1.2rem; background: var(--white); }
.discourse-card h4,
.interlude-card h4 { color: var(--navy); font-family: inherit; font-size: 1rem; font-weight: 800; }
.discourse-card p,
.interlude-card p { margin: .5rem 0 0; color: var(--muted); font-size: .92rem; }

.reference-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .85rem; }
.reference-list span,
.interlude-card > span {
  display: inline-block;
  padding: .18rem .45rem;
  color: var(--navy);
  background: var(--blue-soft);
  font-size: .78rem;
  font-weight: 800;
}

.subsection-title {
  margin: 1.8rem 0 .8rem;
  color: var(--navy);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 850;
}

.interlude-card { border-top: 3px solid var(--gold); }
.interlude-card h4 { margin-top: .7rem; }

.chapter-structure-list { border: 1px solid var(--line); background: var(--white); }
.chapter-structure + .chapter-structure { border-top: 1px solid var(--line); }
.chapter-structure summary { position: relative; display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 1rem; min-height: 70px; padding: .8rem 3.2rem .8rem 1rem; list-style: none; cursor: pointer; }
.chapter-structure summary::-webkit-details-marker { display: none; }
.chapter-structure summary::after { content: "+"; position: absolute; right: 1.2rem; color: var(--navy); font-size: 1.35rem; }
.chapter-structure[open] summary::after { content: "−"; }
.chapter-structure[open] summary { background: var(--blue-soft); }
.chapter-number { display: grid; place-items: center; width: 48px; height: 48px; color: var(--white); background: var(--navy-2); font-family: Georgia, serif; font-size: 1.15rem; }
.chapter-structure summary strong { display: block; color: var(--navy); font-family: Georgia, serif; font-size: 1.15rem; }
.chapter-structure summary small { display: block; margin-top: .18rem; color: var(--muted); font-size: .86rem; }

.structure-units { margin: 0; padding: .5rem 1.2rem 1.2rem 5.1rem; list-style: none; }
.structure-units li { display: grid; grid-template-columns: 84px 1fr; gap: .8rem; padding: .65rem 0; border-bottom: 1px solid #e8edef; }
.structure-units li:last-child { border-bottom: 0; }
.structure-units span { color: var(--navy-2); font-size: .82rem; font-weight: 850; }
.structure-units p { margin: 0; }

.theme-matrix-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--white); }
.theme-matrix { width: 100%; min-width: 920px; border-collapse: collapse; font-size: .82rem; }
.theme-matrix th,
.theme-matrix td { padding: .65rem .6rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.theme-matrix thead th { color: var(--white); background: var(--navy); text-align: center; }
.theme-matrix thead th:first-child { min-width: 230px; text-align: left; }
.theme-matrix tbody th { color: var(--ink); background: #f8fafb; }
.theme-matrix tbody th strong { display: block; line-height: 1.35; }
.theme-matrix tbody th small { display: block; margin-top: .2rem; color: var(--muted); font-weight: 600; }
.theme-matrix td { min-width: 90px; color: var(--navy-2); font-weight: 700; }

.completion-intro {
  max-width: 790px;
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.completion-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem;
  margin-top: 1.2rem;
}

.completion-stage {
  position: relative;
  min-height: 215px;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-top: 4px solid var(--navy-2);
  background: var(--white);
}

.completion-stage:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 46%;
  right: -1.55rem;
  z-index: 1;
  color: var(--gold);
  font-size: 1.45rem;
  font-weight: 850;
}

.completion-stage > span { color: var(--gold); font-family: Georgia, serif; font-size: 1.5rem; }
.completion-stage > p { margin: .1rem 0 .65rem; color: var(--navy-2); font-size: .8rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.completion-stage h4 { color: var(--navy); font-family: inherit; font-size: 1.08rem; font-weight: 850; }
.completion-stage small { display: block; margin-top: .5rem; color: var(--muted); font-size: .9rem; line-height: 1.55; }

.completion-chapters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.completion-chapter { border: 1px solid var(--line); background: var(--white); }
.completion-chapter header { display: grid; grid-template-columns: 58px 1fr; gap: 1rem; padding: 1.15rem; color: var(--white); background: var(--navy); }
.completion-chapter header > span { display: grid; place-items: center; height: 52px; border: 1px solid rgba(255, 255, 255, .42); color: #f0cf91; font-family: Georgia, serif; }
.completion-chapter h4 { color: var(--white); font-family: inherit; font-size: 1.02rem; font-weight: 800; }
.completion-chapter header p { margin: .4rem 0 0; color: #d5e2e9; font-size: .86rem; line-height: 1.5; }
.completion-chapter ol { margin: 0; padding: .75rem 1.15rem 1rem; list-style: none; }
.completion-chapter li { display: grid; grid-template-columns: 64px 1fr; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.completion-chapter li:last-child { border-bottom: 0; }
.completion-chapter li strong { color: var(--navy-2); font-size: .82rem; }
.completion-chapter li span { font-size: .9rem; line-height: 1.5; }

.closing-threads { display: grid; gap: .65rem; }
.closing-thread { display: grid; grid-template-columns: minmax(210px, .9fr) minmax(185px, .65fr) 1.4fr; align-items: center; gap: 1rem; padding: .9rem 1rem; border-left: 3px solid var(--gold); background: var(--white); box-shadow: 0 5px 16px rgba(16, 43, 71, .045); }
.closing-thread h4 { color: var(--navy); font-family: inherit; font-size: .94rem; font-weight: 800; line-height: 1.4; }
.closing-thread > div { display: flex; align-items: center; gap: .45rem; color: var(--navy-2); font-size: .8rem; font-weight: 800; }
.closing-thread > div span { padding: .2rem .4rem; background: var(--blue-soft); }
.closing-thread > div b { color: var(--gold); }
.closing-thread p { margin: 0; color: var(--muted); font-size: .87rem; line-height: 1.5; }

.prologue-transition {
  margin-top: 3rem;
  padding: 1.5rem;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
}

.prologue-transition h3 { color: var(--navy); }
.prologue-transition > p:not(.prologue-label) { max-width: 760px; }
.transition-links { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.transition-links a { padding: .55rem .8rem; color: var(--white); background: var(--navy); font-size: .9rem; font-weight: 800; text-decoration: none; }

.prologue-sources { margin-top: 2.2rem; padding-top: 1.3rem; border-top: 1px solid var(--line); }
.prologue-sources h3 { color: var(--navy); font-family: inherit; font-size: 1rem; font-weight: 850; }
.prologue-sources ul { margin: .65rem 0 0; padding-left: 1.2rem; }
.prologue-sources li { margin: .35rem 0; font-size: .88rem; }

.empty-state {
  margin-top: 2rem;
  padding: 2rem;
  border: 1px solid var(--line);
  background: var(--white);
  text-align: center;
}

.empty-state button {
  min-height: 44px;
  padding: .6rem 1rem;
  border: 0;
  color: var(--white);
  background: var(--navy);
  font-weight: 750;
}

footer {
  padding: 2.2rem 1rem 2.6rem;
  color: #d4e0e7;
  background: var(--navy);
  text-align: center;
}

footer p { margin: .2rem auto; max-width: 820px; }
.source-note { color: #aebfca; font-size: .86rem; }

@media (max-width: 850px) {
  .masthead-inner { grid-template-columns: auto 1fr; }
  .chapter-signposts { display: none; }
  .workspace { grid-template-columns: 1fr; gap: 1.6rem; }
  .explorer { position: static; }
  .control-group { margin-top: 1rem; }
  .reading-note { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
  .reading-note p:not(.reading-note-title) { flex: 1 1 280px; margin: 0; }
  .discourse-grid, .interlude-grid { grid-template-columns: 1fr; }
  .completion-chapters { grid-template-columns: 1fr; }
  .closing-thread { grid-template-columns: 1fr; gap: .5rem; }
}

@media (max-width: 560px) {
  .masthead-inner { min-height: 190px; padding: 1.8rem 0; gap: 1rem; }
  .brand-mark { width: 50px; height: 70px; font-size: 1.8rem; }
  h1 { font-size: 2.2rem; }
  .intro { font-size: .95rem; }
  .workspace { width: min(100% - 1rem, 1180px); padding-top: 1rem; }
  .study-header { align-items: start; flex-direction: column; }
  .result-count { white-space: normal; }
  .theme-card summary { grid-template-columns: auto minmax(0, 1fr); padding-right: 2.7rem; }
  .verse-ref { grid-column: 2; white-space: normal; }
  .theme-body { padding-left: 1.1rem; }
  .section-heading { flex-direction: column; gap: .15rem; }
  .structural-heading { align-items: flex-start; }
  .structural-heading > div { align-items: flex-start; flex-direction: column; gap: .2rem; }
  .movement-card { grid-template-columns: 1fr; gap: .6rem; }
  .movement-marker { flex-direction: row; align-items: baseline; gap: .8rem; padding-bottom: .55rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .structure-units { padding-left: 1rem; }
  .structure-units li { grid-template-columns: 72px 1fr; }
  .completion-overview { grid-template-columns: 1fr; gap: .75rem; }
  .completion-stage { min-height: 0; }
  .completion-stage:not(:last-child)::after { content: "↓"; top: auto; right: 50%; bottom: -1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
