:root {
  --bg0: #e7f1ea;
  --bg1: #f4f7f2;
  --bg2: #dce9e1;
  --ink: #173028;
  --ink-soft: #3d554c;
  --muted: #5f746a;
  --leaf: #1f6b4f;
  --leaf-deep: #14523c;
  --mist: rgba(255, 255, 255, 0.62);
  --line: rgba(23, 48, 40, 0.1);
  --user-bg: #1f6b4f;
  --user-ink: #f4faf6;
  --bot-bg: rgba(255, 255, 255, 0.72);
  --accent-honey: #b8892d;
  --danger-soft: #8a4b3a;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(23, 48, 40, 0.08);
  --font-brand: 'Unbounded', 'Manrope', sans-serif;
  --font-ui: 'Manrope', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(88, 160, 126, 0.28), transparent 60%),
    radial-gradient(700px 480px at 92% 8%, rgba(184, 137, 45, 0.12), transparent 55%),
    radial-gradient(600px 400px at 70% 100%, rgba(31, 107, 79, 0.12), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, var(--bg2));
  animation: drift 18s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

@keyframes drift {
  from {
    filter: hue-rotate(0deg) saturate(1);
    transform: scale(1);
  }
  to {
    filter: hue-rotate(8deg) saturate(1.05);
    transform: scale(1.03);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  color: var(--leaf-deep);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.clear-chat {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(23, 48, 40, 0.14);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.clear-chat:hover:not(:disabled) {
  color: var(--leaf-deep);
  border-color: rgba(31, 107, 79, 0.32);
  background: rgba(31, 107, 79, 0.05);
}

.clear-chat.armed {
  color: var(--danger-soft);
  border-color: rgba(138, 75, 58, 0.35);
  background: rgba(138, 75, 58, 0.06);
}

.clear-chat:disabled {
  opacity: 0.45;
  cursor: wait;
}

.clear-chat:focus-visible {
  outline: 2px solid rgba(31, 107, 79, 0.45);
  outline-offset: 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  animation: sprout 1.1s ease-out both;
}

.brand-word {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0.25rem 1rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.hero {
  padding: 1.4rem 0 0.4rem;
  animation: rise 0.8s ease-out both;
}

.eyebrow {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.brand-hero {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--leaf-deep);
}

.lede {
  margin: 1rem 0 0;
  max-width: 36rem;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.donate {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  padding: 0.35rem 1.6rem 0.35rem 0.15rem;
  border: 0;
  border-top: 1px solid rgba(23, 48, 40, 0.06);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: rise 0.55s ease-out both;
}

/* Author display:flex would otherwise override the HTML hidden attribute. */
.donate[hidden] {
  display: none !important;
}

.donate-copy {
  margin: 0;
  flex: 1 1 auto;
  min-width: 10rem;
  padding-right: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.donate-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.donate-btn {
  appearance: none;
  border: 1px solid rgba(23, 48, 40, 0.12);
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  padding: 0.18rem 0.48rem;
  font: inherit;
  font-weight: 500;
  font-size: 0.72rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.donate-btn:hover {
  color: var(--leaf-deep);
  border-color: rgba(31, 107, 79, 0.35);
  background: rgba(31, 107, 79, 0.05);
}

.donate-dismiss {
  position: absolute;
  top: 0.15rem;
  right: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
}

.donate-dismiss:hover {
  opacity: 0.9;
}

.chat {
  display: flex;
  flex-direction: column;
  min-height: min(62vh, 640px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: rgba(255, 255, 255, 0.48);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.95s ease-out both;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.msg {
  max-width: min(92%, 34rem);
  display: grid;
  gap: 0.45rem;
  animation: bubble 0.35s ease-out both;
}

.msg.user {
  align-self: flex-end;
}

.msg.assistant {
  align-self: flex-start;
}

.bubble {
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.98rem;
}

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

.msg.assistant .bubble {
  background: var(--bot-bg);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  color: var(--ink);
}

.msg.assistant .bubble.typing {
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.01em;
  animation: typing-pulse 1.2s ease-in-out infinite;
}

.msg.assistant .bubble.typing[data-stage='thinking'] {
  animation-duration: 1.55s;
}

.msg.assistant .bubble.typing[data-stage='typing'] {
  animation-duration: 1.05s;
}

@keyframes typing-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.msg.notice .bubble {
  background: rgba(184, 137, 45, 0.12);
  border: 1px solid rgba(184, 137, 45, 0.28);
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.msg.error .bubble {
  background: rgba(95, 116, 106, 0.08);
  border: 1px solid rgba(23, 48, 40, 0.08);
  color: var(--muted);
  font-size: 0.86rem;
  padding: 0.55rem 0.75rem;
}

.partner {
  margin-top: 0.2rem;
  padding: 0.55rem 0 0.15rem 0.75rem;
  border-left: 2px solid rgba(31, 107, 79, 0.35);
  background: transparent;
  border-radius: 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.partner-title {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.partner-body {
  margin: 0;
  line-height: 1.4;
}

.partner a {
  color: var(--leaf-deep);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.partner-promo {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.partner-promo code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
  color: var(--leaf-deep);
}

.partner .tiny {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.feedback {
  display: flex;
  gap: 0.35rem;
}

.feedback button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.feedback button[aria-pressed='true'] {
  background: var(--leaf);
  color: #fff;
  border-color: transparent;
}

.mode-bar {
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem 0.15rem;
  border-top: 1px solid rgba(23, 48, 40, 0.06);
  background: rgba(255, 255, 255, 0.35);
}

.mode-hint {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.mode-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.mode-chip {
  appearance: none;
  border: 1px solid rgba(23, 48, 40, 0.12);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.32rem 0.62rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mode-chip:hover {
  color: var(--leaf-deep);
  border-color: rgba(31, 107, 79, 0.28);
  background: rgba(31, 107, 79, 0.04);
}

.mode-chip[aria-checked='true'] {
  color: var(--leaf-deep);
  border-color: rgba(31, 107, 79, 0.4);
  background: rgba(31, 107, 79, 0.08);
}

.mode-chip:focus-visible {
  outline: 2px solid rgba(31, 107, 79, 0.45);
  outline-offset: 2px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.composer textarea {
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  min-height: 48px;
  max-height: 140px;
  outline: none;
}

.composer textarea:focus {
  border-color: rgba(31, 107, 79, 0.45);
  box-shadow: 0 0 0 3px rgba(31, 107, 79, 0.12);
}

.send {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--leaf);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.send:hover:not(:disabled) {
  background: var(--leaf-deep);
  transform: translateY(-1px);
}

.send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.legal {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.legal p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.legal-link {
  color: var(--leaf-deep);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  font-weight: 500;
}

.legal-link:hover {
  color: var(--leaf);
}

.legal-link:focus-visible {
  outline: 2px solid rgba(31, 107, 79, 0.45);
  outline-offset: 2px;
  border-radius: 2px;
}

.brand-home {
  color: inherit;
  text-decoration: none;
}

.brand-home:hover .brand-word {
  color: var(--leaf);
}

.brand-home:focus-visible {
  outline: 2px solid rgba(31, 107, 79, 0.45);
  outline-offset: 4px;
  border-radius: 8px;
}

.back-chat {
  flex: 0 0 auto;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid rgba(23, 48, 40, 0.14);
  border-radius: 10px;
  padding: 0.35rem 0.7rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.back-chat:hover {
  color: var(--leaf-deep);
  border-color: rgba(31, 107, 79, 0.32);
  background: rgba(31, 107, 79, 0.05);
}

.back-chat:focus-visible {
  outline: 2px solid rgba(31, 107, 79, 0.45);
  outline-offset: 2px;
}

.privacy-shell {
  padding-top: 0.6rem;
  padding-bottom: 1.5rem;
}

.privacy-card {
  background: var(--mist);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.35rem 1.2rem;
  backdrop-filter: blur(10px);
  animation: rise 0.7s ease-out both;
}

.privacy-title {
  margin: 0.15rem 0 0.55rem;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
}

.privacy-lede {
  margin: 0 0 1.15rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
  max-width: 36em;
}

.privacy-block {
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line);
}

.privacy-block h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-brand);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--leaf-deep);
}

.privacy-block p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
  max-width: 38em;
}

.privacy-close {
  margin: 1.25rem 0 0;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.privacy-return {
  display: inline-block;
  color: var(--user-ink);
  background: var(--leaf);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 12px;
  padding: 0.55rem 1rem;
  transition: background 0.15s ease, transform 0.15s ease;
}

.privacy-return:hover {
  background: var(--leaf-deep);
}

.privacy-return:focus-visible {
  outline: 2px solid rgba(31, 107, 79, 0.45);
  outline-offset: 3px;
}

.page-privacy .hero,
.page-privacy .chat {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bubble {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sprout {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 520px) {
  .shell {
    padding-inline: 0.75rem;
  }

  .top {
    padding-inline: 0.75rem;
    gap: 0.5rem;
  }

  .clear-chat {
    font-size: 0.72rem;
    padding: 0.32rem 0.55rem;
  }

  .chat {
    min-height: 58vh;
    border-radius: 16px;
  }

  .brand-hero {
    font-size: clamp(2.15rem, 11vw, 2.8rem);
  }

  .mode-bar {
    padding-inline: 0.65rem;
  }

  .mode-chip {
    font-size: 0.74rem;
    padding: 0.3rem 0.52rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
