:root {
  color-scheme: light;
  --paper: #f1ead9;
  --paper-light: #f8f4e9;
  --ink: #25251f;
  --muted: #716d60;
  --rule: #cec4ae;
  --red: #8e3028;
  --red-dark: #70231e;
  --gold: #9d7739;
  --secondary-ink: #514e45;
  --italic-ink: #47443d;
  --glow: rgb(255 255 255 / 48%);
  --grain: rgb(75 58 28 / 1.5%);
  --current: rgb(142 48 40 / 4%);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Arial, Helvetica, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171713;
  --paper-light: #22221c;
  --ink: #e8e1d1;
  --muted: #aaa392;
  --rule: #474439;
  --red: #dc7969;
  --red-dark: #ed8a79;
  --gold: #c9a66a;
  --secondary-ink: #c5bdac;
  --italic-ink: #d0c7b5;
  --glow: rgb(117 98 66 / 9%);
  --grain: rgb(255 246 220 / 1.7%);
  --current: rgb(220 121 105 / 7%);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, var(--glow), transparent 28rem),
    repeating-linear-gradient(90deg, transparent 0, transparent 4px, var(--grain) 5px),
    var(--paper);
  font-family: var(--serif);
  min-height: 100vh;
}

a { color: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }

.site-header {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
  font-size: 17px;
  letter-spacing: .02em;
}

.wordmark i { color: var(--red); font-weight: normal; }

.wordmark-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 12px;
  letter-spacing: .12em;
}

.site-header nav { display: flex; gap: 32px; }

.theme-picker {
  display: flex;
  align-items: center;
}

.theme-picker select {
  width: 75px;
  padding: 6px 16px 6px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav-link {
  position: relative;
  padding: 12px 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: .14em;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  height: 1px;
  background: var(--red);
  transform: scaleX(0);
  transition: transform 180ms ease;
}

.nav-link:hover, .nav-link.active { color: var(--ink); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }

.reader-shell {
  width: min(1080px, calc(100% - 48px));
  margin: 0 auto;
  padding: 72px 0 48px;
  display: grid;
  grid-template-columns: 150px minmax(0, 700px) 150px;
  gap: 40px;
  align-items: start;
}

.reader-rail {
  position: sticky;
  top: 32px;
  padding-top: 12px;
}

.eyebrow, .book-label, .chapter-number, .book-heading p {
  margin: 0;
  color: var(--red);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .17em;
  line-height: 1.5;
  text-transform: uppercase;
}

.progress-track {
  height: 2px;
  margin: 17px 0 13px;
  overflow: hidden;
  background: var(--rule);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--red);
  transition: width 300ms ease;
}

.progress-copy {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.5;
}

.reading-card { min-width: 0; }

.chapter-header {
  text-align: center;
  padding: 8px 24px 46px;
  border-bottom: 1px solid var(--rule);
}

.book-label { color: var(--gold); }

.chapter-number { margin-top: 30px; }

.chapter-header h1, .contents-hero h1 {
  margin: 13px auto 18px;
  max-width: 680px;
  font-size: clamp(36px, 5vw, 59px);
  font-weight: normal;
  letter-spacing: -.035em;
  line-height: 1.08;
  text-wrap: balance;
}

.ornament { color: var(--red); font-size: 12px; }

.chapter-body {
  padding: 48px 18px 22px;
  font-size: clamp(18px, 2vw, 20px);
  line-height: 1.85;
}

.chapter-body p { margin: 0 0 1.25em; }

.chapter-body p:not(.poem, .footnote, .noindent, .center)::first-letter {
  padding-left: 1.2em;
}

.chapter-body p:first-child:not(.poem, .footnote, .noindent, .center)::first-letter {
  float: left;
  padding: .1em .1em 0 0;
  color: var(--red);
  font-size: 3.4em;
  line-height: .75;
}

.chapter-body .poem {
  margin: 2em 8%;
  color: var(--secondary-ink);
  font-style: italic;
}

.chapter-body .center {
  margin: 2.2em 0;
  color: var(--gold);
  font-size: .75em;
  letter-spacing: .12em;
  text-align: center;
  text-transform: uppercase;
}

.chapter-body .footnote {
  margin-top: 3em;
  padding-top: 1.4em;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .78em;
  line-height: 1.65;
}

.chapter-body i { color: var(--italic-ink); }

.chapter-actions {
  margin-top: 34px;
  padding: 42px 0;
  text-align: center;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.complete-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 36px;
  min-width: 250px;
  padding: 17px 20px;
  border: 1px solid var(--red);
  color: var(--paper-light);
  background: var(--red);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}

.complete-button:hover { background: var(--red-dark); }
.complete-button.is-complete { color: var(--red); background: transparent; }

.completion-note { margin: 16px 0 0; color: var(--muted); font-size: 14px; }

.chapter-nav {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  margin-top: 0;
  padding-top: 22px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.chapter-nav a { text-decoration: none; }
.chapter-nav #previous-chapter { grid-column: 1; }
.chapter-nav a:nth-child(2) { grid-column: 2; text-align: center; color: var(--muted); }
.chapter-nav #next-chapter { grid-column: 3; text-align: right; }

.site-footer {
  width: min(1180px, calc(100% - 48px));
  margin: 56px auto 0;
  padding: 26px 0 36px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .06em;
  line-height: 1.5;
  text-transform: uppercase;
}

.site-footer p { margin: 0; }
.site-footer a:hover { color: var(--red); }

.contents-main {
  width: min(920px, calc(100% - 48px));
  margin: 0 auto;
  padding: 76px 0 60px;
}

.contents-hero { max-width: 700px; }

.contents-hero h1 { margin: 13px 0 15px; }

.contents-hero > p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.resume-link {
  display: inline-flex;
  gap: 30px;
  margin-top: 32px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--red);
  color: var(--red);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .12em;
  text-decoration: none;
  text-transform: uppercase;
}

.contents-progress {
  margin: 72px 0 64px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.contents-progress .progress-track { margin-top: 13px; }

.book-section { margin-bottom: 72px; }

.book-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--ink);
}

.book-heading h2 {
  margin: 5px 0 0;
  max-width: 650px;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: normal;
  line-height: 1.15;
}

.book-heading > span {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .1em;
}

.chapter-list { margin: 0; padding: 0; list-style: none; }

.chapter-list li { border-bottom: 1px solid var(--rule); }

.chapter-list a {
  display: grid;
  grid-template-columns: 58px 1fr 54px;
  gap: 22px;
  align-items: center;
  min-height: 82px;
  padding: 12px 0;
  text-decoration: none;
  transition: padding 150ms ease, color 150ms ease;
}

.chapter-list a:hover { padding-left: 8px; color: var(--red); }

.day-number, .chapter-status {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: .1em;
}

.toc-title { font-size: 18px; line-height: 1.35; }

.toc-title small {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.chapter-status { text-align: right; text-transform: uppercase; }
.chapter-list .is-complete .chapter-status { color: var(--red); }
.chapter-list .is-complete .toc-title { color: var(--muted); }
.chapter-list .is-current { background: var(--current); }

@media (max-width: 900px) {
  .reader-shell { grid-template-columns: 1fr; max-width: 720px; }
  .reader-rail { position: static; }
  .chapter-nav { grid-column: 1; }
}

@media (max-width: 600px) {
  .site-header, .reader-shell, .site-footer, .contents-main { width: min(100% - 32px, 920px); }
  .site-header { min-height: 76px; }
  .wordmark > span:last-child { display: none; }
  .site-header nav { gap: 14px; }
  .reader-shell { padding-top: 38px; gap: 22px; }
  .chapter-header { padding: 6px 0 34px; }
  .chapter-header h1 { font-size: 38px; }
  .chapter-body { padding: 36px 0 12px; font-size: 18px; line-height: 1.75; }
  .chapter-body p:not(.poem, .footnote, .noindent, .center)::first-letter { padding-left: .65em; }
  .chapter-nav span { display: none; }
  .site-footer { flex-direction: column; margin-top: 24px; }
  .contents-main { padding-top: 48px; }
  .contents-progress { margin: 48px 0; }
  .book-section { margin-bottom: 52px; }
  .chapter-list a { grid-template-columns: 42px 1fr; gap: 12px; min-height: 76px; }
  .chapter-status { display: none; }
  .toc-title { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
