:root {
  --stone: #E8ECE9;
  --stone-raised: #F2F5F3;
  --ink: #1D2B2F;
  --ink-soft: #4A5A5E;
  --verdigris: #2E6B60;
  --verdigris-soft: #D3E1DC;
  --rule: #B9C4C0;
  --alert: #8A3B2E;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --measure: 42rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --stone: #141E21;
    --stone-raised: #1B272B;
    --ink: #DCE4E1;
    --ink-soft: #9AAAA6;
    --verdigris: #7DB3A6;
    --verdigris-soft: #24383A;
    --rule: #33454A;
    --alert: #E09A88;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--stone);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--verdigris); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Top bar */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 1.1rem 1rem 0.6rem;
}

.mark {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
  visibility: hidden;
}
body.has-conversation .mark { visibility: visible; }

.topnav { display: flex; gap: 1.25rem; align-items: baseline; font-size: 0.9rem; }
.topnav a { color: var(--ink-soft); text-decoration: none; }
.topnav a:hover { color: var(--ink); }

.link-button {
  font: inherit;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.link-button:hover { color: var(--ink); }

/* Main column */

main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* Empty state */

.intro { padding-top: clamp(3rem, 14vh, 9rem); }
body.has-conversation .intro { display: none; }

.wordmark {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(3.4rem, 13vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
  margin-left: -0.05em;
}

.lede {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.5;
  max-width: 34rem;
  margin: 0 0 3rem;
  color: var(--ink);
}

.starters { border-top: 1px solid var(--rule); max-width: 34rem; }

.starters-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0.9rem 0 0.4rem;
}

.starter {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 0.75rem 0;
  cursor: pointer;
}
.starter:hover { color: var(--verdigris); }

/* Conversation */

.conversation { list-style: none; margin: 0; padding: 1.5rem 0 0; }

.turn { margin: 0 0 2.25rem; }

.speaker {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}

.turn.user .body {
  font-family: var(--sans);
  font-size: 0.98rem;
  white-space: pre-wrap;
  border-left: 3px solid var(--verdigris);
  padding: 0.1rem 0 0.1rem 0.9rem;
  color: var(--ink);
}

.turn.model .speaker { color: var(--verdigris); }

.turn.model .body {
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.65;
}

.turn.model .body > :first-child { margin-top: 0; }
.turn.model .body p { margin: 0 0 0.9em; }
.turn.model .body ol,
.turn.model .body ul { padding-left: 1.4em; margin: 0 0 0.9em; }
.turn.model .body li { margin-bottom: 0.3em; }
.turn.model .body blockquote {
  margin: 0 0 0.9em;
  padding-left: 1em;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
}
.turn.model .body h1,
.turn.model .body h2,
.turn.model .body h3 { font-size: 1.1rem; font-weight: 500; margin: 1.2em 0 0.4em; }
.turn.model .body code {
  font-size: 0.9em;
  background: var(--verdigris-soft);
  padding: 0.05em 0.3em;
  border-radius: 3px;
}

.thinking {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
}
@media (prefers-reduced-motion: no-preference) {
  .thinking { animation: breathe 2.4s ease-in-out infinite; }
  @keyframes breathe { 50% { opacity: 0.45; } }
}

.turn.model .body .katex { font-size: 1.05em; }
.turn.model .body .katex-display { margin: 0.4em 0 1em; overflow-x: auto; overflow-y: hidden; }

.error-text { color: var(--alert); font-family: var(--sans); font-size: 0.95rem; }

/* Feedback under each reply */

.feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: baseline;
  margin-top: 0.6rem;
  font-size: 0.85rem;
}
.feedback button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
}
.feedback button:hover { color: var(--ink); text-decoration-color: currentColor; }
.feedback .done { color: var(--ink-soft); }

.report { width: 100%; margin-top: 0.4rem; }
.report textarea {
  width: 100%;
  min-height: 4.5rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--stone-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  resize: vertical;
}
.report .actions { display: flex; gap: 1.1rem; margin-top: 0.45rem; }

/* Composer */

.composer-wrap {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to bottom, transparent, var(--stone) 1.25rem);
  padding: 1.25rem 1rem 0.9rem;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--stone-raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.55rem 0.55rem 0.55rem 0.9rem;
}
.composer:focus-within { border-color: var(--verdigris); }

.composer textarea {
  flex: 1;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  border: 0;
  resize: none;
  max-height: 14rem;
  padding: 0.35rem 0;
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--ink-soft); }

.send {
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--stone);
  background: var(--verdigris);
  border: 0;
  border-radius: 7px;
  padding: 0.55rem 1rem;
  cursor: pointer;
}
.send:hover { filter: brightness(1.08); }
.send:disabled { opacity: 0.5; cursor: default; filter: none; }

.caveat {
  max-width: var(--measure);
  margin: 0.55rem auto 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
}
.caveat a { color: var(--ink-soft); }

/* First-visit notice */

.notice {
  max-width: 30rem;
  width: calc(100% - 2rem);
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--stone-raised);
  color: var(--ink);
  padding: 1.6rem 1.6rem 1.4rem;
}
.notice::backdrop { background: rgba(20, 30, 33, 0.55); }
.notice h2 { font-family: var(--serif); font-weight: 400; font-size: 1.6rem; margin: 0 0 0.8rem; }
.notice p { margin: 0 0 0.9rem; font-size: 0.95rem; }
.notice form { margin: 1.2rem 0 0; }

/* Remaining messages */

.allowance { display: block; margin-bottom: 0.2rem; color: var(--ink); }
.allowance.low { color: var(--alert); }

.composer.closed { opacity: 0.6; }

/* Public landing page */

.landing {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: clamp(3rem, 14vh, 9rem) 1rem 3rem;
}

.landing .lede { margin-bottom: 2.25rem; }

.landing-body {
  max-width: 34rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
}
.landing-body p {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.65;
  margin: 0 0 1em;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1.5rem;
  margin: 1.75rem 0 0;
}
a.send { display: inline-block; text-decoration: none; }
.quiet-link { font-size: 0.95rem; color: var(--ink-soft); }
.quiet-link:hover { color: var(--ink); }

.landing-footer {
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.landing-footer a { color: var(--ink-soft); }

/* Privacy page */

.page { padding-top: 2.5rem; }
.page h1 { font-family: var(--serif); font-weight: 300; font-size: clamp(2.4rem, 8vw, 3.4rem); line-height: 1.05; margin: 0 0 1.5rem; }
.page h2 { font-family: var(--serif); font-weight: 500; font-size: 1.25rem; margin: 2rem 0 0.5rem; }
.page p, .page li { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; }
.page .updated { font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft); }
.page .back { font-family: var(--sans); font-size: 0.9rem; }

@media (max-width: 480px) {
  .turn.model .body { font-size: 1.05rem; }
  .lede { font-size: 1.12rem; }
}
