:root {
  --desk: #e7e1d5;
  --paper: #f6f1e7;
  --ink: #1e1a16;
  --muted: #6e655c;
  --hairline: #ddd4c6;
  --mark: #f0c27a;
  --accent: #8f3d32;
  --sage: #2f5d50;
  --sans: "Source Sans 3", "Avenir Next", "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Palatino, "Palatino Linotype", Georgia, serif;
  --display: Fraunces, Palatino, Georgia, serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
}

::selection {
  background: var(--mark);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button,
input {
  border-radius: 0;
}

.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;
}

.desk {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.75rem 1.5rem 4.5rem;
}

.kicker {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sage);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.5rem, 7vw, 4.15rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}

.deck {
  margin: 0.8rem 0 0;
  max-width: 38rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--muted);
}

.masthead {
  margin-bottom: 1.35rem;
}

.search-dock {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--desk);
  padding: 0.7rem 0 0.85rem;
  border-bottom: 1px solid var(--hairline);
}

.search-row {
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
}

#q {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.85rem 1rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 1.35rem;
  line-height: 1.3;
  appearance: none;
}

#q::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-row button[type="submit"] {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 1.2rem;
  background: var(--accent);
  color: var(--paper);
  border: 1px solid var(--accent);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.search-row button[type="submit"]:hover {
  background: #7a342b;
  border-color: #7a342b;
}

.modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.modes button {
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms linear, color 120ms linear, border-color 120ms linear;
}

.modes button[aria-pressed="true"] {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--paper);
}

.hint {
  margin: 0.55rem 0 0;
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.95rem;
}

.examples {
  margin: 0.95rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.examples button {
  display: inline;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.16em;
  text-decoration-thickness: 1px;
  cursor: pointer;
}

.status {
  margin: 1.15rem 0 0.85rem;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 0.98rem;
}

.status.is-empty {
  font-family: var(--serif);
  font-style: italic;
}

.results {
  list-style: decimal;
  margin: 0;
  padding: 0 0 0 1.75rem;
}

.result {
  display: grid;
  grid-template-columns: 4.75rem minmax(0, 1fr);
  column-gap: 0.9rem;
  align-items: start;
  margin: 0 0 0.85rem;
  padding: 1rem 1.1rem 0.95rem;
  background: var(--paper);
  border: 1px solid var(--hairline);
}

.result:last-child {
  margin-bottom: 0;
}

.result::marker {
  color: var(--muted);
  font-family: var(--display);
}

.pages {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.2;
  font-variant-numeric: oldstyle-nums;
}

.chapter {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sage);
}

.heading {
  margin: 0.28rem 0 0;
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
}

.snippet {
  margin: 0.55rem 0 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.snippet mark {
  background: var(--mark);
  color: inherit;
  font-weight: inherit;
  font-style: inherit;
}

.passage-toggle {
  display: inline-block;
  margin: 0.65rem 0 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

.passage {
  margin: 0.7rem 0 0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.reasons {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 520px) {
  .desk {
    padding: 1.5rem 1rem 3rem;
  }

  .search-row {
    flex-direction: column;
  }

  #q {
    font-size: 1.125rem;
  }

  .search-row button[type="submit"] {
    min-height: 2.75rem;
  }

  .result {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.35rem;
  }

  .pages {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modes button {
    transition: none;
  }
}
