:root {
  --paper: #F2F4F1;
  --surface: #FAFBF9;
  --ink: #1C2A2E;
  --muted: #5A6A6E;
  --rule: #C9D2CE;
  --evidence: #2E6A5C;
  --evidence-soft: #DCE9E4;
  --retrieve: #3D5A86;
  --embed: #8A9BA0;
  --danger: #9B2C2C;
  --focus: #2E6A5C;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141B1D;
    --surface: #1A2326;
    --ink: #E4EAE8;
    --muted: #9AABAE;
    --rule: #33413F;
    --evidence: #7CC0AD;
    --evidence-soft: #22352F;
    --retrieve: #8EA8D3;
    --embed: #6B7C80;
    --danger: #F09A9A;
    --focus: #7CC0AD;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 var(--sans);
}

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3rem 1rem 2rem;
}

.masthead h1 {
  font: 600 2.25rem/1.1 var(--serif);
  letter-spacing: -0.01em;
  margin: 0 0 0.75rem;
}

.lede {
  font: 1.125rem/1.6 var(--serif);
  color: var(--ink);
  max-width: 38rem;
  margin: 0 0 2rem;
}

.notice {
  border-left: 3px solid var(--evidence);
  border-radius: 0;
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 0 0 2.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
}
.notice h2 {
  font: 600 1rem/1.4 var(--sans);
  color: var(--ink);
  margin: 0 0 0.25rem;
}
.notice p { margin: 0 0 0.5rem; max-width: 38rem; }
.ref { font-variant-numeric: tabular-nums; color: var(--ink); word-break: break-all; }

a { color: var(--evidence); text-underline-offset: 0.15em; }

.thread { display: grid; gap: 1.75rem; margin-bottom: 1.5rem; }

.starter p { color: var(--muted); margin: 0 0 0.75rem; }
.suggestions { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.suggestions button {
  font: 1rem/1.4 var(--serif);
  text-align: left;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
}
.suggestions button:hover { border-color: var(--evidence); }

.turn-question {
  font: 600 1rem/1.5 var(--sans);
  margin: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  border-radius: 0;
}

.turn-answer {
  font: 1.0625rem/1.7 var(--serif);
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  max-width: 40rem;
}
.turn-answer.pending { color: var(--muted); font-style: italic; }
.turn-answer.error { color: var(--danger); font-family: var(--sans); font-size: 1rem; }

.cite {
  display: inline-block;
  font: 600 0.75rem/1.4 var(--sans);
  color: var(--evidence);
  background: var(--evidence-soft);
  border-radius: 3px;
  padding: 0 0.3rem;
  margin: 0 0.1rem;
  vertical-align: 0.15em;
  font-variant-numeric: tabular-nums;
}

/* The evidence block: the one element this page is built around. */
.evidence {
  margin-top: 0.85rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.6rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.evidence summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 600;
  width: fit-content;
}
.evidence[open] summary { margin-bottom: 0.75rem; }

.timing { margin: 0 0 1rem; }
.timing-bar {
  display: flex;
  height: 0.5rem;
  border-radius: 2px;
  overflow: hidden;
  background: var(--rule);
  margin: 0.35rem 0;
}
.timing-bar span { display: block; height: 100%; min-width: 2px; }
.seg-embed { background: var(--embed); }
.seg-retrieve { background: var(--retrieve); }
.seg-generate { background: var(--evidence); }
.timing-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-variant-numeric: tabular-nums; }
.timing-legend i { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: -0.05em; }

.sources { list-style: none; padding: 0; margin: 0 0 0.75rem; display: grid; gap: 0.35rem; }
.sources li { display: grid; grid-template-columns: 2.25rem 1fr; gap: 0.5rem; align-items: baseline; }
.sources li.cited { color: var(--ink); }
.sources li:not(.cited) .cite { background: transparent; color: var(--muted); border: 1px solid var(--rule); }
.source-where { overflow-wrap: anywhere; display: grid; }
.source-title { color: inherit; }
.source-section, .source-score { color: var(--muted); font-size: 0.8125rem; }
.source-score { font-variant-numeric: tabular-nums; }
.sources li:not(.cited) .source-title { color: var(--muted); }

.tokens { margin: 0; font-variant-numeric: tabular-nums; }

.composer {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding: 0.75rem 0 1rem;
  border-top: 1px solid var(--rule);
}
.composer textarea {
  width: 100%;
  font: 1rem/1.5 var(--serif);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  resize: vertical;
  min-height: 3.5rem;
}
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; }
.count { color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.composer button {
  font: 600 1rem/1 var(--sans);
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 6px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.55; cursor: progress; }
.form-error { color: var(--danger); font-size: 0.9375rem; margin: 0.5rem 0 0; }

.colophon { color: var(--muted); font-size: 0.8125rem; margin-top: 2rem; max-width: 38rem; }

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

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

@media (prefers-reduced-motion: no-preference) {
  .timing-bar span { transition: flex-grow 400ms ease-out; }
}

@media (max-width: 30rem) {
  .page { padding-top: 2rem; }
  .masthead h1 { font-size: 1.85rem; }
  .lede { font-size: 1.0625rem; }
}
