:root {
  color-scheme: light;
  --ink: #1f1b16;
  --muted: #665f56;
  --paper: #fffaf1;
  --panel: #ffffff;
  --accent: #7b3f00;
  --accent-dark: #4d2700;
  --line: #e5d7c4;
  --shadow: 0 24px 60px rgba(55, 35, 14, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(123, 63, 0, 0.14), transparent 34rem),
    linear-gradient(180deg, #fff8ea 0%, var(--paper) 42%, #f8efe1 100%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.6;
}

button,
textarea,
.button {
  font: inherit;
}

.hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 6rem 1.5rem 4rem;
  text-align: center;
}

.eyebrow,
.chapter-kicker {
  color: var(--accent);
  font-family: system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(4rem, 13vw, 8.5rem);
  line-height: 0.85;
  margin: 0;
}

.subtitle {
  color: var(--accent-dark);
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  margin: 1rem 0 0;
}

.lede {
  color: var(--muted);
  font-size: 1.2rem;
  margin: 1.5rem auto 2rem;
  max-width: 720px;
}

.button,
button {
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button,
.chapter-actions button,
.tool-actions button,
#save-reflection {
  background: var(--accent);
  color: #fff;
  display: inline-block;
  padding: 0.8rem 1.2rem;
}

.button:hover,
button:hover {
  box-shadow: 0 10px 22px rgba(77, 39, 0, 0.16);
  transform: translateY(-1px);
}

.reader {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 1.5rem 4rem;
}

.toc,
.chapter-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.toc {
  align-self: start;
  padding: 1.2rem;
  position: sticky;
  top: 1rem;
}

.toc h2 {
  margin: 0 0 0.8rem;
}

.toc nav {
  display: grid;
  gap: 0.45rem;
}

.chapter-link {
  background: transparent;
  color: var(--ink);
  padding: 0.65rem 0.8rem;
  text-align: left;
}

.chapter-link.active {
  background: #f3dfc5;
  border-color: var(--accent-dark);
  color: var(--accent-dark);
  font-weight: 700;
}

.chapter-card {
  min-height: 680px;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.chapter-card h2 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  margin: 0 0 1rem;
}

.chapter-section {
  border-top: 1px solid var(--line);
  margin-top: 1.6rem;
  padding-top: 1.2rem;
}

.chapter-section h3 {
  color: var(--accent-dark);
  margin-top: 0;
}

.passages {
  color: var(--muted);
  font-size: 0.98rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.passages li {
  border-left: 3px solid var(--line);
  margin: 0.35rem 0;
  padding-left: 0.7rem;
}

.tool-intro {
  color: var(--muted);
  margin-top: 0;
}

.tool-field {
  display: block;
  font-weight: 700;
  margin-top: 1rem;
}

#discernment-practice {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  display: block;
  margin: 0.5rem 0;
  padding: 0.7rem 0.9rem;
  width: 100%;
}

.criteria {
  display: grid;
  gap: 0.8rem;
  margin: 1rem 0;
}

.criterion {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 0;
  padding: 0.9rem 1rem;
}

.criterion legend {
  color: var(--accent-dark);
  font-weight: 700;
  padding: 0 0.4rem;
}

.criterion-q {
  color: var(--muted);
  margin: 0.2rem 0 0.7rem;
}

.ratings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ratings input[type="radio"] {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.ratings label {
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  padding: 0.35rem 0.9rem;
}

.ratings input[type="radio"]:checked + label {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}

.ratings input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.result {
  border-left: 4px solid var(--line);
  margin: 1rem 0;
  min-height: 1.5rem;
  padding: 0.6rem 0.9rem;
}

.result[data-state="incomplete"] {
  border-left-color: var(--line);
  color: var(--muted);
}

.result[data-state="receive"] {
  border-left-color: #2f7d32;
}

.result[data-state="revise"],
.result[data-state="pause"] {
  border-left-color: #b8860b;
}

.result[data-state="reject"] {
  border-left-color: #9b2226;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

#discernment-status {
  color: var(--muted);
  min-height: 1.5rem;
}

textarea {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  display: block;
  margin: 0.8rem 0;
  padding: 1rem;
  resize: vertical;
  width: 100%;
}

#save-status {
  color: var(--muted);
  min-height: 1.5rem;
}

.chapter-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  margin-top: 2rem;
}

.chapter-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

footer {
  color: var(--muted);
  padding: 2rem 1.5rem 4rem;
  text-align: center;
}

@media (max-width: 820px) {
  .reader {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }
}

.toc-details summary {
  align-items: center;
  color: var(--accent-dark);
  cursor: pointer;
  display: flex;
  font-family: system-ui, sans-serif;
  font-weight: 800;
  gap: 0.75rem;
  justify-content: space-between;
  list-style: none;
}

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

.toc-details summary::after {
  border: solid var(--accent);
  border-width: 0 2px 2px 0;
  content: "";
  height: 0.45rem;
  transform: rotate(45deg);
  transition: transform 160ms ease;
  width: 0.45rem;
}

.toc-details[open] summary::after {
  transform: rotate(-135deg);
}

#toc-current {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 13rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-details nav {
  margin-top: 0.9rem;
  max-height: min(68vh, 42rem);
  overflow: auto;
  padding-right: 0.2rem;
}

.didactic li + li {
  margin-top: 0.55rem;
}

@media (min-width: 981px) {
  .reader {
    grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  }

  .toc {
    padding: 0.9rem;
  }

  .chapter-link {
    font-size: 0.92rem;
    padding: 0.45rem 0.65rem;
  }
}

@media (max-width: 980px) {
  .reader {
    grid-template-columns: 1fr;
  }

  .toc {
    position: sticky;
    top: 0.5rem;
    z-index: 5;
  }
}
