/* Abundance Economics — an interactive book in progress
   The red one: deep red, warm gold, cream paper. Light reading page,
   serif quotes. Carlito UI. Mobile-first. Sibling of Cornucopia Interactive. */

:root {
  --ink: #2b1a17;
  --ink-soft: #7d6a64;
  --paper: #fdfcf9;
  --paper-warm: #f7f2ec;
  --line: #e8dcd2;
  --accent: #1e7a3c;        /* lush green */
  --accent-2: #9aa919;      /* yellow-green (quote borders) */
  --accent-3: #145229;      /* deep green, reserve */
  --accent-soft: #e9f5e2;   /* light green tint (user bubbles) */
  --coach-bg: #eff4e7;      /* green parchment (author bubbles) */
  --quote-bg: #fbffee;      /* pale spring for quotes */
  --radius: 14px;
  --font: "Carlito", Calibri, "Segoe UI", -apple-system, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

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

html { height: 100%; }

body {
  font-family: var(--font);
  font-size: 18.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px env(safe-area-inset-bottom);
}

/* ---------- header ---------- */
header { padding: 28px 4px 14px; text-align: center; border-bottom: 1px solid var(--line); }

.brand {
  font-size: 15px;
  letter-spacing: 0.3em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }

.tagline {
  color: var(--ink-soft);
  font-size: 16px;
  margin-top: 6px;
}

/* ---------- chat ---------- */
main#chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 2px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.msg.coach { background: var(--coach-bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user  { background: var(--accent-soft); align-self: flex-end; border-bottom-right-radius: 4px; }

/* quotes rendered inside coach messages */
.msg.coach .quote {
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.55;
  font-style: italic;
  background: var(--quote-bg);
  border-left: 3px solid var(--accent-2);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 8px 0;
  white-space: pre-wrap;
}

.msg.coach .quote .attribution {
  display: block;
  font-family: var(--font);
  font-style: normal;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin-top: 8px;
}

.msg.typing { color: var(--ink-soft); }
.msg.typing span { animation: blink 1.2s infinite; }
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.msg.error {
  background: none;
  border: 1px dashed var(--line);
  color: var(--ink-soft);
  font-size: 15px;
  align-self: center;
  text-align: center;
}

/* ---------- starter chips ---------- */
#chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 4px 0 10px;
}

#chips[hidden] { display: none; }

#chips button {
  font-family: var(--font);
  font-size: 14.5px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: none;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#chips button:hover { background: var(--accent); color: #fff; }

/* ---------- composer ---------- */
#composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 0 14px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  bottom: 0;
}

#input {
  flex: 1;
  font-family: var(--font);
  font-size: 18.5px;
  line-height: 1.4;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  resize: none;
  max-height: 130px;
  background: var(--paper-warm);
  color: var(--ink);
}

#input:focus { outline: none; border-color: var(--accent); }

#send {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

#send:disabled { opacity: 0.4; cursor: default; }

/* ---------- footer ---------- */
footer {
  padding: 6px 4px 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-soft);
}

footer a { color: inherit; }

@media (min-width: 480px) {
  header { padding-top: 40px; }
  h1 { font-size: 32px; }
}
