:root {
  color-scheme: light dark;
  --paper: #f6f1e7;
  --raised: #fffdf8;
  --ink: #26211a;
  --muted: #6f6556;
  --line: #e0d7c6;
  --accent: #7a2e22;
  --accent-ink: #fffdf8;
  --care: #f3e4d4;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --column: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130f;
    --raised: #211d17;
    --ink: #ece4d6;
    --muted: #a0957f;
    --line: #342e25;
    --accent: #d98f72;
    --accent-ink: #16130f;
    --care: #2c2219;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Top bar */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: calc(var(--column) + 2rem);
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.wordmark {
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--serif);
  flex: none;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.library-link {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0;
  color: var(--ink);
  font-size: 0.875rem;
  text-decoration: none;
}

.library-link:hover {
  color: var(--accent);
}

.library-link svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.library-count {
  color: var(--muted);
  font-size: 0.8125rem;
}

.version {
  min-width: 0;
}

.version select {
  width: 100%;
  max-width: 13.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

/* Scrolling area */
main {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem;
  scroll-behavior: smooth;
}

.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 2rem 0;
  text-align: center;
}

.logo {
  height: clamp(5rem, 15vh, 7rem);
  margin-bottom: 1.5rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
}

.intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 500;
  line-height: 1.15;
}

.intro p {
  margin: 0.25rem 0 2.25rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-style: italic;
}

.prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: var(--column);
  margin: 0;
  padding: 0;
  list-style: none;
}

.prompts button {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.prompts button:hover {
  border-color: var(--accent);
}

/* Conversation */
.thread {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: var(--column);
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  list-style: none;
}

.thread:empty {
  display: none;
}

.turn {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* The whole thread re-renders on each change, so only the newest turn may animate. */
.turn:last-child {
  animation: rise 0.35s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.question {
  align-self: flex-end;
  max-width: 85%;
  margin: 0;
  padding: 0.55rem 0.9rem;
  border-radius: 1rem 1rem 0.25rem;
  background: var(--raised);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.verse {
  margin: 0;
  padding: 0 0.25rem;
}

.verse blockquote {
  margin: 0;
  white-space: pre-line; /* Licensed text keeps its poetic line breaks. */
  font-family: var(--serif);
  font-size: clamp(1.3rem, 3.6vw, 1.55rem);
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.verse figcaption {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.verse .ref {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
}

.copy {
  margin-left: auto;
  padding: 0.15rem 0.4rem;
  border: 0;
  border-radius: 0.35rem;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

.copy:hover {
  color: var(--ink);
}

.heart {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.75rem -0.65rem -0.75rem auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.copy + .heart {
  margin-left: -0.5rem;
}

.heart:hover,
.heart[aria-pressed='true'] {
  color: var(--accent);
}

.heart svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: fill 0.15s;
}

.heart[aria-pressed='true'] svg {
  fill: currentColor;
}

.short {
  font-size: 0.8125rem;
}

.missing {
  color: var(--muted);
  font-size: 1.05rem;
  font-style: italic;
}

.searching {
  margin: 0;
  padding: 0 0.25rem;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  animation: breathe 1.8s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    opacity: 0.45;
  }
}

.error {
  margin: 0;
  padding: 0 0.25rem;
  color: var(--accent);
  font-size: 0.95rem;
}

/* Shown alongside the verse when someone may be in danger */
.care {
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0.25rem 0.5rem 0.5rem 0.25rem;
  background: var(--care);
  font-size: 0.95rem;
}

.care p {
  margin: 0;
}

.care p + p {
  margin-top: 0.35rem;
}

.care strong {
  font-weight: 600;
}

.care a {
  color: inherit;
  font-weight: 600;
}

/* Verse library */
.library {
  max-width: var(--column);
  margin: 0 auto;
  padding: 1rem 0 2.5rem;
}

.library-back {
  color: var(--muted);
  font-size: 0.875rem;
}

.library h1 {
  margin: 1rem 0 0;
  font-family: var(--serif);
  font-size: clamp(1.9rem, 6vw, 2.5rem);
  font-weight: 500;
  line-height: 1.15;
}

.library h1:focus {
  outline: none;
}

.library-note {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.library-empty {
  margin: 2.5rem 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.25rem;
  font-style: italic;
}

.shelf {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.shelf:empty {
  display: none;
}

.shelf li + li {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}

.shelf .error {
  margin-top: 0.5rem;
}

.library-more {
  display: block;
  margin: 2rem auto 0;
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.library-more:hover {
  border-color: var(--accent);
}

/* Composer */
.composer {
  width: 100%;
  max-width: calc(var(--column) + 2rem);
  margin: 0 auto;
  padding: 0.5rem 1rem max(0.6rem, env(safe-area-inset-bottom));
}

.composer form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.4rem 0.4rem 0.4rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: var(--raised);
  transition: border-color 0.15s;
}

.composer form:focus-within {
  border-color: var(--accent);
}

textarea {
  flex: 1;
  min-width: 0;
  max-height: 9rem;
  padding: 0.4rem 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  resize: none;
}

/* The composer's border already shows focus. */
textarea:focus-visible {
  outline: none;
}

textarea::placeholder {
  color: var(--muted);
}

#send {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: opacity 0.15s;
}

#send:disabled {
  opacity: 0.35;
  cursor: default;
}

.fineprint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.fineprint a,
.notice a {
  color: inherit;
}

.help {
  position: relative;
  width: 1.05rem;
  height: 1.05rem;
  margin-left: 0.35rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.6875rem;
  line-height: 1;
  vertical-align: text-bottom;
  cursor: pointer;
}

/* The icon stays small, but it still has to be easy to tap. */
.help::after {
  content: '';
  position: absolute;
  inset: -0.85rem;
}

.help:hover {
  border-color: var(--muted);
  color: var(--ink);
}

/* Report a problem */
.report {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--raised);
  color: var(--ink);
}

.report::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.report h2 {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
}

.report p {
  margin: 0;
}

.report fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.report fieldset label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.9375rem;
  cursor: pointer;
}

.report input {
  accent-color: var(--accent);
}

.report textarea {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper);
  font-size: 0.9375rem;
}

.report textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.report-fine {
  margin-top: 0.6rem !important;
  color: var(--muted);
  font-size: 0.75rem;
}

.report .error {
  margin-top: 0.6rem;
  padding: 0;
}

.report .care {
  margin-top: 0.75rem;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.report-actions button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.report-actions button[type='submit'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.report-actions button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* The publisher requires this wherever its text appears. */
.notice {
  max-width: var(--column);
  margin: -1rem auto 1.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Copyright page */
body.legal {
  height: auto;
  min-height: 100dvh;
}

.legal .wordmark {
  text-decoration: none;
}

.legal main {
  overflow: visible;
}

.legal article {
  max-width: var(--column);
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.legal h1,
.legal h2 {
  font-family: var(--serif);
  font-weight: 500;
}

.legal h2 {
  margin-top: 2rem;
  font-size: 1.25rem;
}

@media (max-width: 30rem) {
  .library-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
