:root {
  color-scheme: light dark;
  --bg: #f4efe6;
  --paper: #fffdf8;
  --ink: #28231e;
  --muted: #6b6258;
  --line: #d8cdbd;
  --accent: #7a3527;
  --accent-soft: #f2ded5;
  --evidence: #365f59;
  --evidence-soft: #e2efeb;
  --shadow: 0 18px 48px rgb(64 47 34 / 12%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-underline-offset: .18em; }
button, input, select { font: inherit; }
button { color: inherit; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; padding: .75rem 1rem; background: var(--ink); color: var(--paper); }
.skip-link:focus { top: 1rem; }

.site-header { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 92%, transparent); }
.site-header nav { display: flex; gap: 1rem; font-size: .9rem; }
.brand { color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: 1.18rem; font-weight: 700; text-decoration: none; }
main { width: min(1380px, 100%); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2.5rem) 4rem; }
.work-intro { max-width: 830px; padding: clamp(2.5rem, 7vw, 6rem) 0 2rem; }
.eyebrow { margin: 0 0 .6rem; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h1 { max-width: 800px; margin: 0; font-size: clamp(2.6rem, 7vw, 5.8rem); font-weight: 500; line-height: .97; letter-spacing: -.045em; }
.dek { max-width: 720px; margin: 1.4rem 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.15rem, 2vw, 1.45rem); line-height: 1.55; }
.scope-note { max-width: 760px; padding: 1rem 1.1rem; border-left: 4px solid var(--evidence); background: var(--evidence-soft); line-height: 1.55; }

.reader-shell { display: grid; grid-template-columns: minmax(210px, 270px) minmax(0, 1fr); min-height: 720px; border: 1px solid var(--line); border-radius: 18px; overflow: clip; background: var(--paper); box-shadow: var(--shadow); }
.contents { padding: 1.25rem; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 55%, var(--paper)); overflow: auto; max-height: 900px; }
.contents-heading { display: flex; align-items: center; justify-content: space-between; }
.contents h2 { margin: 0; font-size: 1.25rem; }
.icon-button { display: none; width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.8rem; }
.search-label { display: block; margin: 1rem 0 .35rem; color: var(--muted); font-size: .78rem; font-weight: 700; }
#chapterSearch { width: 100%; min-height: 42px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.chapter-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin: .8rem 0 0; padding: 0; list-style: none; }
.chapter-list button, .salutation-link { width: 100%; min-height: 42px; border: 1px solid transparent; border-radius: 7px; background: transparent; cursor: pointer; }
.salutation-link { margin-top: .75rem; text-align: left; padding-inline: .6rem; }
.chapter-list button:hover, .salutation-link:hover { border-color: var(--line); background: var(--paper); }
.chapter-list button[aria-current="page"], .salutation-link[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 800; }

.reading-column { min-width: 0; }
.reader-toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .55rem; min-height: 62px; padding: .65rem clamp(.8rem, 2vw, 1.4rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(12px); }
.toolbar-button, .chapter-footer button { min-height: 42px; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); cursor: pointer; }
.toolbar-button:hover, .chapter-footer button:hover { border-color: var(--accent); }
#openContents { display: none; }
.chapter-picker-label { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 700; }
#chapterPicker { min-height: 42px; padding: .45rem 2rem .45rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.status { padding: 3rem; color: var(--muted); }
.chapter-header, .chapter-text, .evidence-card, .chapter-footer { width: min(760px, calc(100% - 2rem)); margin-inline: auto; }
.chapter-header { padding-top: clamp(2.5rem, 6vw, 5rem); }
.chapter-header h2 { margin: 0 0 1.6rem; font-size: clamp(2.2rem, 5vw, 4.25rem); font-weight: 500; letter-spacing: -.035em; }
.chapter-text { padding-bottom: 3rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.08rem, 1.5vw, 1.25rem); line-height: 1.78; }
.section { position: relative; margin: 0 0 1.1rem; padding-left: 2.6rem; scroll-margin-top: 80px; }
.section-number { position: absolute; left: 0; top: .12em; color: var(--accent); font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: .68em; font-weight: 800; }
.section.audio-range { padding: .45rem .6rem .45rem 2.6rem; border-radius: 7px; }
.section.audio-active { background: var(--accent-soft); }
.audio-cue { border-radius: 3px; transition: background .15s ease; }
.audio-cue.active { background: #f2bf7c; color: #25180b; }
.evidence-card { margin-top: .25rem; margin-bottom: 2rem; padding: 1.1rem 1.2rem; border: 1px solid color-mix(in srgb, var(--evidence) 45%, var(--line)); border-radius: 12px; background: var(--evidence-soft); }
.evidence-card h3 { margin: 0 0 .5rem; font-size: 1.2rem; }
.evidence-card p { margin: .45rem 0; line-height: 1.5; }
.evidence-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; margin-top: .8rem; }
.evidence-card audio { width: min(100%, 420px); height: 42px; }
.outline-link { display: inline-flex; min-height: 42px; align-items: center; padding: .55rem .75rem; border-radius: 8px; background: var(--evidence); color: white; font-weight: 750; text-decoration: none; }
.audio-status { min-height: 1.25em; color: var(--muted); font-size: .82rem; }
.chapter-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.25rem 0 4rem; border-top: 1px solid var(--line); }

.edition-panel { margin: clamp(3rem, 7vw, 6rem) 0 0; padding: clamp(1.5rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.edition-panel > h2 { margin: 0 0 1.5rem; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 500; }
.edition-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 2rem; }
.edition-grid h3 { margin-bottom: .25rem; }
.edition-grid p { margin-top: 0; color: var(--muted); line-height: 1.55; }
.edition-panel details { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.edition-panel summary { cursor: pointer; font-weight: 800; }
.citation { display: grid; grid-template-columns: minmax(150px, .55fr) minmax(0, 2fr) auto; align-items: start; gap: 1rem 1.5rem; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.citation h3 { margin: 0; font-size: 1.2rem; }
.citation p { margin: 0; color: var(--muted); line-height: 1.65; }
.citation button { min-height: 42px; padding: .55rem .8rem; border: 1px solid var(--accent); border-radius: 8px; background: transparent; color: var(--accent); cursor: pointer; font-weight: 750; }
.citation button:hover { background: var(--accent-soft); }
.backdrop { position: fixed; inset: 0; z-index: 8; background: rgb(20 16 12 / 46%); }

@media (prefers-color-scheme: dark) {
  :root { --bg: #181614; --paper: #24211e; --ink: #f2ebe1; --muted: #b8aea2; --line: #4a4239; --accent: #eda98e; --accent-soft: #503126; --evidence: #75b6aa; --evidence-soft: #243a36; --shadow: 0 18px 48px rgb(0 0 0 / 28%); }
}

@media (max-width: 760px) {
  .site-header nav a:first-child { display: none; }
  main { padding-inline: .75rem; }
  .work-intro { padding-inline: .35rem; }
  .reader-shell { display: block; min-height: 680px; }
  .contents { position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(86vw, 340px); max-height: none; border-right: 1px solid var(--line); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .contents.open { transform: translateX(0); }
  .icon-button, #openContents { display: inline-flex; align-items: center; justify-content: center; }
  .reader-toolbar { gap: .35rem; overflow-x: auto; }
  .reader-toolbar > #previousChapter, .reader-toolbar > #nextChapter, .chapter-picker-label { display: none; }
  #chapterPicker { margin-left: auto; }
  .chapter-header, .chapter-text, .evidence-card, .chapter-footer { width: min(100% - 1.4rem, 700px); }
  .section { padding-left: 2rem; }
  .edition-grid { grid-template-columns: 1fr; }
  .citation { grid-template-columns: 1fr; }
  .citation button { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .contents, .audio-cue { transition: none; }
}
