:root {
  --paper: #efe5cf;
  --ink: #24180e;
  --ink-soft: rgba(36, 24, 14, 0.72);
  --border: rgba(70, 49, 21, 0.18);
  --border-strong: rgba(70, 49, 21, 0.34);
  --shadow: 0 16px 48px rgba(44, 30, 15, 0.1);
  --page-width: 72rem;
  --measure: 46rem;
  --topbar-height: 3.9rem;
  --font-body: "Century Old Style Std", "Century Old Style Std Regular", serif;
  --font-display: "Century Old Style Std", "Century Old Style Std Regular", serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  background: #efe3cd;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(120, 92, 55, 0.03), rgba(120, 92, 55, 0.03)),
    radial-gradient(rgba(80, 62, 36, 0.035) 0.8px, transparent 0.8px);
  background-size: auto, 12px 12px;
  content: "";
  opacity: 0.75;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.page-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(244, 236, 216, 0.9);
  backdrop-filter: blur(12px);
}

.wordmark {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
}

.wordmark-kicker {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.wordmark-title {
  font-size: 1.12rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.wordmark:hover,
.wordmark:focus-visible,
.book a:hover,
.book a:focus-visible {
  color: rgba(124, 78, 29, 1);
}

.main {
  width: min(calc(100% - 2rem), var(--page-width));
  margin: 0 auto;
  padding: 0 0 3rem;
}

.book {
  width: min(100%, var(--measure));
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: clamp(1.27rem, 1.32vw, 1.34rem);
  line-height: 1.42;
  font-family: var(--font-body);
  font-weight: 400;
  letter-spacing: normal;
  word-spacing: normal;
  text-shadow: none;
  font-variant-numeric: normal;
  font-feature-settings: normal;
}

.book > * {
  scroll-margin-top: 6rem;
}

.book-page {
  width: min(100%, 42rem);
  margin: 0 auto;
  padding: 0.25rem 0.5rem 0.75rem;
  font-size: clamp(1.27rem, 1.32vw, 1.34rem);
  line-height: 1.42;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.book-page p,
.book-page blockquote,
.book-page ul,
.book-page ol,
.book-page hr {
  margin: 0 0 0.5rem;
}

.book-page .split-after {
  margin-bottom: 0.2rem;
}

.book-page .continued {
  margin-top: 0.2rem;
}

.book-page p {
  text-align: justify;
  text-justify: inter-word;
  text-wrap: auto;
  hanging-punctuation: first last;
}

.book-page p[data-para]:not([data-para="1"]) {
  text-indent: 1.35em;
}

.page-break {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin: 2.5rem 0 1.55rem;
  color: var(--ink-soft);
}

.page-break-rule {
  display: block;
  height: 1px;
  width: 100%;
  background: rgba(70, 49, 21, 0.38);
}

.page-break-rule:last-child {
  display: none;
}

.page-label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: normal;
  white-space: nowrap;
}

.page-label-link {
  color: inherit;
  text-decoration: none;
}

.page-label-link:hover,
.page-label-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.book-page {
  scroll-margin-top: 6rem;
}

.book-page:target .page-label-link {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.page-break-continued {
  margin-top: 1.6rem;
}

.book-page--title-page {
  padding-top: 2rem;
  text-align: center;
}

.book-page--title-page p {
  max-width: none;
  margin-right: auto;
  margin-left: auto;
  text-align: center;
  text-indent: 0;
}

.book-page--title-page p[data-para="1"] {
  margin-top: 2.8rem;
  margin-bottom: 2.75rem;
  font-size: clamp(2.2rem, 4vw, 2.75rem);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

.book-page--title-page p[data-para="2"] {
  margin-bottom: 2.4rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.book-page--title-page p[data-para="3"] {
  margin-bottom: 1.9rem;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.book-page--title-page p[data-para="4"] {
  margin-bottom: 2rem;
  font-size: clamp(2rem, 3vw, 2.45rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.book-page--title-page p[data-para="5"] {
  max-width: 31rem;
  margin-bottom: 3.5rem;
  font-size: 1rem;
  line-height: 1.22;
  font-style: italic;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-page--title-page p[data-para="6"] {
  margin-bottom: 4.5rem;
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.book-page--title-page p[data-para="7"] {
  margin-bottom: 1rem;
  font-size: 1.08rem;
  line-height: 2.1;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.book-page--copyright-page {
  padding-top: 4rem;
}

.book-page--copyright-page p {
  max-width: 33rem;
  margin: 6.5rem auto 0;
  padding: 1.2rem 0;
  border-top: 1px solid rgba(70, 49, 21, 0.5);
  border-bottom: 1px solid rgba(70, 49, 21, 0.5);
  text-align: center;
  text-indent: 0;
  line-height: 1.65;
  font-size: 1rem;
}

.book-page--preface-page,
.book-page--preface-continued {
  width: min(100%, 43rem);
  font-size: clamp(0.92rem, 0.96vw, 0.98rem);
  line-height: 1.38;
}

.book-page--preface-page p[data-para="1"] {
  margin-top: 0.4rem;
  margin-bottom: 1.75rem;
  text-align: center;
  text-indent: 0;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.book-page--preface-page p[data-para="2"],
.book-page--preface-continued p[data-para="1"] {
  text-indent: 0;
}

.book-page--preface-continued p:last-of-type {
  margin-top: 1.8rem;
  text-align: right;
  text-indent: 0;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-page--narrative-opening,
.book-page--numbered-page {
  width: min(100%, 45rem);
  font-size: clamp(0.9rem, 0.92vw, 0.96rem);
  line-height: 1.28;
  column-count: 2;
  column-gap: 1.7rem;
}

.book-page--narrative-opening .page-break,
.book-page--numbered-page .page-break {
  column-span: all;
}

.book-page--narrative-opening p,
.book-page--numbered-page p {
  margin-bottom: 0.2rem;
}

.book-page--narrative-opening p[data-para="1"] {
  column-span: all;
  margin-top: 0.2rem;
  margin-bottom: 0.9rem;
  text-align: center;
  text-indent: 0;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.book-page--narrative-opening p[data-para="2"] {
  column-span: all;
  max-width: 38rem;
  margin: 0 auto 1.5rem;
  text-align: center;
  text-indent: 0;
  font-size: 0.98rem;
  line-height: 1.26;
  font-style: italic;
}

.book-page--narrative-opening p[data-para="3"],
.book-page--numbered-page p[data-para="1"] {
  text-indent: 0;
}

.book-page--source-087 {
  padding-bottom: 14rem;
}

.book-page--source-087 p[data-para="2"] {
  column-span: all;
  margin-top: 3.8rem;
  margin-bottom: 0;
  text-align: center;
  text-indent: 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.book-page--source-018 {
  padding-top: 2.8rem;
}

.book-page--source-018 p[data-para="1"] {
  column-span: all;
  margin-top: 2.4rem;
  margin-bottom: 1.15rem;
  text-align: center;
  text-indent: 0;
  font-size: 1rem;
  font-weight: 600;
}

.book-page--source-018 p[data-para="2"] {
  text-indent: 0;
}

.book blockquote {
  padding: 0.9rem 1.1rem;
  border-left: 3px solid rgba(124, 78, 29, 1);
  background: rgba(124, 78, 29, 0.12);
  color: var(--ink-soft);
}

.book hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.book figure {
  margin: 1.8rem auto 2rem;
  width: min(100%, 54rem);
}

.book figure button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.book figure img {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 0.35rem;
  box-shadow: 0 18px 34px rgba(50, 32, 18, 0.12);
}

.book figcaption {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.lightbox {
  width: min(92vw, 72rem);
  padding: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 1.2rem;
  background: rgba(248, 240, 221, 0.98);
}

.lightbox::backdrop {
  background: rgba(25, 18, 11, 0.72);
}

.lightbox-close {
  appearance: none;
  margin-left: auto;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.8);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.lightbox-figure {
  margin: 0;
}

.lightbox-figure img {
  max-height: calc(100vh - 8rem);
  margin: 0 auto;
  object-fit: contain;
}

.lightbox-figure figcaption {
  margin-top: 0.75rem;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 54rem) {
  .main {
    width: calc(100% - 1rem);
    padding: 0.75rem 0 2rem;
  }

  .book {
    padding: 0 0 2rem;
  }

  .book-page {
    width: 100%;
    padding: 0.2rem 0.2rem 0.6rem;
  }

  .book-page--title-page p[data-para="1"] {
    font-size: 1.8rem;
    letter-spacing: 0.24em;
  }

  .book-page--title-page p[data-para="4"] {
    font-size: 1.8rem;
    letter-spacing: 0.14em;
  }

  .book-page--narrative-opening,
  .book-page--numbered-page {
    column-count: 1;
    width: 100%;
    font-size: 0.98rem;
    line-height: 1.4;
  }

  .book-page--source-087 {
    padding-bottom: 8rem;
  }

  .book-page--source-087 p[data-para="2"] {
    margin-top: 2.6rem;
  }

  .book-page--source-018 {
    padding-top: 1rem;
  }

  .book-page--source-018 p[data-para="1"] {
    margin-top: 1.4rem;
  }
}

.editor-main {
  width: min(calc(100% - 1rem), 96rem);
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.editor-shell {
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: rgba(251, 246, 232, 0.88);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem;
  border-bottom: 1px solid var(--border);
  background: rgba(244, 236, 216, 0.82);
}

.editor-button,
.editor-file {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.86);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.editor-file {
  position: relative;
  overflow: hidden;
}

.editor-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.editor-button:hover,
.editor-button:focus-visible,
.editor-file:hover,
.editor-file:focus-within {
  border-color: rgba(124, 78, 29, 0.9);
  color: rgba(124, 78, 29, 1);
}

.editor-status {
  min-height: 1.4rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
}

.editor-pane {
  min-width: 0;
  background: rgba(251, 246, 232, 0.94);
}

.editor-source {
  width: 100%;
  min-height: calc(100vh - 12rem);
  padding: 1rem;
  border: 0;
  resize: vertical;
  background: rgba(255, 252, 244, 0.96);
  color: var(--ink);
  font: 0.95rem/1.55 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.editor-source:focus {
  outline: 2px solid rgba(124, 78, 29, 0.28);
  outline-offset: -2px;
}

.editor-preview {
  display: block;
  width: 100%;
  min-height: calc(100vh - 12rem);
  border: 0;
  background: white;
}

@media (max-width: 54rem) {
  .editor-main {
    width: calc(100% - 0.5rem);
    padding: 0.5rem 0 1rem;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .editor-source,
  .editor-preview {
    min-height: 24rem;
  }
}

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