:root {
  color-scheme: light dark;
  --paper: #f7f7f5;
  --ink: #20242b;
  --muted: #626a75;
  --accent: #0f766e;
  --display: "Fraunces", Georgia, serif;
  --text: "Source Serif 4", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1e1f22;
    --ink: #eae6dd;
    --muted: #a09b90;
    --accent: #8fc0b8;
  }
}

* {
  margin: 0;
  box-sizing: border-box;
}

body {
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  line-height: 1.7;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 2.5rem;
  padding: 3rem 1.5rem;
}

::selection {
  background: var(--accent);
  color: var(--paper);
}

.masthead {
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  font-size: 0.9375rem;
}

.masthead::after {
  content: "";
  width: 5rem;
  height: 3px;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
}

main,
.hero {
  display: grid;
  justify-items: center;
  gap: 2.5rem;
}

.hero {
  align-content: center;
  min-height: calc(100svh - 12rem);
}

h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.3rem, 7vw, 4rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  max-width: 15ch;
  text-wrap: balance;
}

.sub {
  color: var(--muted);
  font-style: italic;
  font-size: 1.125rem;
  max-width: 40ch;
  text-wrap: pretty;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.75rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 1px;
}

#ask,
#adrs {
  width: min(100%, 38rem);
  display: grid;
  gap: 2rem;
  padding-top: 3.5rem;
  border-top: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
}

#ask[hidden],
#adrs[hidden] {
  display: none;
}

#ask {
  gap: 1.25rem;
}

form {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

label {
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

textarea,
button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--muted) 55%, transparent);
  border-radius: 2px;
}

textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  resize: vertical;
}

button {
  padding: 0.4rem 1.75rem;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.5;
}

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

.thread {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}

.thread:empty,
.progress:empty,
.answer:empty,
.sources:empty {
  display: none;
}

.question {
  justify-self: end;
  max-width: 85%;
  padding: 0.5rem 1rem;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 2px;
}

.reply {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
  text-align: left;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
}

.progress {
  color: var(--muted);
  font-style: italic;
}

.answer {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sources {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  font-size: 0.875rem;
}

h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.75rem;
  line-height: 1.2;
}

.lede {
  color: var(--muted);
  font-style: italic;
  text-wrap: pretty;
}

#adrs ol {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 2rem;
  text-align: left;
}

#adrs li {
  display: grid;
  gap: 0.35rem;
}

.label {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
}

.status {
  color: var(--muted);
  text-transform: uppercase;
}

h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.3;
  text-wrap: balance;
}

.generated,
.note {
  font-size: 0.8125rem;
  color: var(--muted);
  font-style: italic;
}

footer {
  font-size: 0.875rem;
  color: var(--muted);
  font-style: italic;
}
