/* Self-hosted, no CDN, no webfonts — matches the project's no-build-step brief.
   Light and dark are both first-class; the palette is one warm accent against
   near-neutral greys so the citations and search indicator read as chrome. */

:root {
  color-scheme: light dark;

  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-alt: #f2efea;
  --ink: #1c1a17;
  --ink-soft: #56514a;
  --ink-faint: #8a837a;
  --line: #e2ddd5;
  --accent: #9a3f1c;
  --accent-soft: #f4e6de;
  --user-bubble: #26221e;
  --user-ink: #faf8f5;
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --surface: #1e1d23;
    --surface-alt: #26252c;
    --ink: #ece9e4;
    --ink-soft: #b3ada4;
    --ink-faint: #7d766d;
    --line: #33313a;
    --accent: #e08a5f;
    --accent-soft: #33251d;
    --user-bubble: #3b3944;
    --user-ink: #f4f2ef;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.shell {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.masthead h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.masthead h1::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 1.1em;
  margin-right: 0.6rem;
  vertical-align: -0.15em;
  background: var(--accent);
  border-radius: 2px;
}

.masthead__blurb {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 42rem;
}

.masthead__links {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.85rem;
}

.masthead__links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.masthead__links a:hover,
.masthead__links a:focus-visible {
  border-bottom-color: currentColor;
}

/* ---------- chat ---------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
}

.intro__lead {
  margin: 0 0 0.75rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.starters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.starter {
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.starter:hover,
.starter:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.turn {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.turn--user {
  align-items: flex-end;
}

.bubble {
  max-width: 90%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble--user {
  background: var(--user-bubble);
  color: var(--user-ink);
  border-bottom-right-radius: 4px;
}

.bubble--assistant {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  max-width: 100%;
}

.bubble--error {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--ink);
  max-width: 100%;
}

/* Blinking caret while the answer streams in. */
.bubble--streaming::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble--streaming::after {
    animation: none;
  }
}

/* ---------- search indicator ---------- */

.searches {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.search {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.search__label {
  color: var(--accent);
  flex-shrink: 0;
}

.search__query {
  overflow-wrap: anywhere;
}

/* ---------- sources ---------- */

.sources {
  border-top: 1px dashed var(--line);
  padding-top: 0.6rem;
  font-size: 0.8rem;
}

.sources__title {
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  margin: 0 0 0.4rem;
}

.sources__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sources__item {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

.sources__file {
  color: var(--accent);
}

/* ---------- composer ---------- */

.composer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.composer textarea {
  font: inherit;
  width: 100%;
  resize: none;
  max-height: 9rem;
  padding: 0.75rem 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.composer textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.composer__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.counter {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.counter--warn {
  color: var(--accent);
}

#send {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--user-ink);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
}

#send:hover:not(:disabled) {
  filter: brightness(1.08);
}

#send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- footnote ---------- */

.footnote {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.footnote p {
  margin: 0 0 0.5rem;
}

.footnote code {
  font-family: var(--mono);
  font-size: 0.95em;
  background: var(--surface-alt);
  padding: 0.05em 0.35em;
  border-radius: 4px;
}

/* ---------- utilities ---------- */

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

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