:root {
  --bg: #f4f7ee;
  --paper: #fffef9;
  --ink: #203021;
  --muted: #647064;
  --green: #496e45;
  --soft: #dcebd4;
  --sun: #f1cf72;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(circle at 50% 0, #fffdf3 0, var(--bg) 48%);
  min-height: 100vh;
}
button,
textarea {
  font: inherit;
}
.ai-shell {
  width: min(760px, calc(100% - 40px));
  margin: auto;
  min-height: 100vh;
  padding-bottom: 170px;
}
.ai-shell > header {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-shell > header a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--green);
  color: #fff;
  font: 24px Georgia;
}
.ai-intro {
  text-align: center;
  padding: 30px 0 22px;
}
.ai-intro p {
  margin: 14px 0 8px;
  color: var(--green);
  font-weight: 750;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.ai-intro h1 {
  font:
    500 clamp(2.4rem, 8vw, 4.5rem) / 1.05 Georgia,
    serif;
  letter-spacing: -0.045em;
  margin: 0 0 12px;
}
.ai-intro small {
  color: var(--muted);
}
.ai-intro blockquote {
  max-width: 560px;
  margin: 24px auto 0;
  color: var(--ink);
  font:
    400 15px/1.55 Georgia,
    serif;
}
.ai-intro cite {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font:
    12px -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
.sun {
  width: 84px;
  height: 84px;
  margin: auto;
  border-radius: 52% 48% 49% 51%;
  background: var(--sun);
  position: relative;
  box-shadow: 18px 16px 0 var(--soft);
}
.sun i {
  position: absolute;
  width: 18px;
  height: 9px;
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  left: 33px;
  top: 44px;
}
.quick-prompts {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 4px 1px 22px;
  scrollbar-width: none;
}
.quick-prompts button {
  flex: none;
  border: 1px solid #d6dfce;
  background: #fffdf8;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  cursor: pointer;
}
.conversation {
  display: grid;
  gap: 14px;
}
.message {
  max-width: 82%;
  padding: 13px 16px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 8px 28px rgb(43 65 40/0.06);
  white-space: pre-wrap;
}
.message.user {
  justify-self: end;
  background: var(--green);
  color: white;
  border-bottom-right-radius: 6px;
}
.message.ai {
  border-bottom-left-radius: 6px;
}
.message small,
.message-files {
  display: block;
  margin-top: 7px;
  opacity: 0.7;
  font-size: 12px;
}
.message-files {
  display: grid;
  gap: 7px;
  opacity: 1;
}
.message-file-name {
  display: inline-block;
  width: fit-content;
  padding: 5px 8px;
  border-radius: 9px;
  background: rgb(255 255 255 / 0.18);
  font-size: 12px;
}
.message-media {
  width: min(100%, 360px);
  margin: 0;
  overflow: hidden;
  border-radius: 13px;
  background: rgb(255 255 255 / 0.16);
}
.message-media img {
  display: block;
  width: 100%;
  max-height: 310px;
  object-fit: contain;
  background: #f2f3ed;
}
.message-media.audio { padding: 8px; }
.message-media.audio audio { display: block; width: 100%; height: 38px; }
.message-media > span { display: block; padding: 9px; font-size: 11px; }
.composer {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 44px 44px 1fr 48px;
  gap: 7px;
  align-items: end;
  background: rgb(255 254 249/0.94);
  backdrop-filter: blur(18px);
  padding: 10px;
  border: 1px solid #dbe2d4;
  border-radius: 24px;
  box-shadow: 0 18px 60px rgb(43 65 40/0.14);
  transition:
    border-color 0.16s,
    transform 0.16s;
}
.composer.dragging {
  border-color: var(--green);
  transform: translateX(-50%) translateY(-2px);
}
.composer textarea {
  resize: none;
  border: 0;
  background: transparent;
  padding: 12px 5px;
  min-height: 48px;
  max-height: 130px;
  color: var(--ink);
  outline: 0;
}
.attach-button,
.record-button,
.send-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 15px;
  background: var(--soft);
  color: var(--green);
  cursor: pointer;
}
.attach-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.attach-button span {
  font-size: 22px;
}
.record-button {
  font-size: 13px;
}
.record-button.recording {
  background: #d76156;
  color: #fff;
  animation: pulse 1s ease-in-out infinite;
}
.send-button {
  width: 48px;
  height: 48px;
  background: var(--green);
  color: #fff;
  font-size: 22px;
}
.send-button:disabled {
  opacity: 0.5;
}
.composer > span {
  grid-column: 1/-1;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.attachment-tray {
  grid-column: 1/-1;
  display: flex;
  gap: 6px;
  overflow: auto;
}
.attachment-tray[hidden] {
  display: none;
}
.attachment-tray button {
  border: 0;
  border-radius: 999px;
  background: #eef2e8;
  padding: 7px 10px;
  color: var(--ink);
  font-size: 11px;
  white-space: nowrap;
}
.attachment-tray b {
  margin-right: 5px;
  color: var(--green);
}
.mobile-nav {
  display: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 3px solid #bd8ee6;
  outline-offset: 3px;
}
@keyframes pulse {
  50% {
    transform: scale(0.9);
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation: none !important;
  }
}
@media (max-width: 640px) {
  .ai-shell {
    width: calc(100% - 28px);
    padding-bottom: 205px;
  }
  .ai-shell > header {
    height: 64px;
  }
  .ai-intro {
    padding: 18px 0;
  }
  .sun {
    width: 68px;
    height: 68px;
  }
  .sun i {
    left: 25px;
    top: 35px;
  }
  .ai-intro h1 {
    font-size: 2.55rem;
  }
  .ai-intro blockquote {
    margin-top: 18px;
  }
  .message {
    max-width: 90%;
  }
  .composer {
    bottom: calc(72px + env(safe-area-inset-bottom));
    border-radius: 20px;
    grid-template-columns: 42px 42px 1fr 46px;
  }
  .mobile-nav {
    position: fixed;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    background: rgb(255 254 249/0.96);
    border-top: 1px solid #dbe2d4;
  }
  .mobile-nav a {
    text-align: center;
    padding: 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
  }
  .mobile-nav a.active {
    color: var(--green);
  }
}

.embedded body { background: var(--bg); }
.embedded .ai-shell {
  width: 100%;
  min-height: 100vh;
  padding: 14px 14px 108px;
}
.embedded .ai-shell > header,
.embedded .ai-intro,
.embedded .mobile-nav { display: none; }
.embedded .quick-prompts { padding: 2px 0 14px; }
.embedded .quick-prompts button { padding: 8px 11px; font-size: 12px; }
.embedded .composer {
  bottom: 10px;
  width: calc(100% - 20px);
  grid-template-columns: 40px 40px minmax(0, 1fr) 44px;
  padding: 8px;
  border-radius: 18px;
}
.embedded .attach-button,
.embedded .record-button { width: 40px; height: 40px; }
.embedded .send-button { width: 44px; height: 44px; }
.embedded .message { max-width: 92%; font-size: 14px; }
.ai-shell > header nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.sync-state {
  color: var(--muted);
  font-size: 12px;
}
.load-earlier {
  display: block;
  margin: 18px auto 0;
  padding: 9px 14px;
  border: 1px solid #d6dfce;
  border-radius: 999px;
  background: #fffdf8;
  color: var(--green);
  cursor: pointer;
}
.load-earlier[hidden] {
  display: none;
}
@media (max-width: 640px) {
  .sync-state {
    display: none;
  }
}
.ai-shell > header nav button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #d6dfce;
  border-radius: 999px;
  background: #fffdf8;
  color: var(--green);
  cursor: pointer;
}
.memory-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 28px;
  border: 1px solid #d6dfce;
  border-radius: 26px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgb(31 48 32 / 0.2);
}
.memory-dialog::backdrop {
  background: rgb(32 48 33 / 0.28);
  backdrop-filter: blur(7px);
}
.memory-dialog h2 {
  margin: 3px 0 8px;
  font:
    500 2rem/1.1 Georgia,
    serif;
}
.memory-kicker {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.memory-intro,
.memory-empty {
  color: var(--muted);
  line-height: 1.5;
}
.memory-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--green);
  font-size: 24px;
  cursor: pointer;
}
.memory-dialog form {
  display: grid;
  gap: 8px;
  margin: 22px 0 12px;
}
.memory-dialog form label {
  font-size: 13px;
  font-weight: 700;
}
.memory-dialog textarea {
  min-height: 90px;
  resize: vertical;
  padding: 13px;
  border: 1px solid #d6dfce;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}
.memory-dialog form button,
.memory-import {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 13px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.memory-import {
  background: var(--soft);
  color: var(--green);
}
.memory-import input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.memory-list {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}
.memory-list article {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #e1e7db;
  border-radius: 14px;
  background: #fff;
}
.memory-list p {
  margin: 0;
  line-height: 1.4;
}
.memory-list small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.memory-list button {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
@media (max-width: 640px) {
  .ai-shell > header nav {
    gap: 10px;
  }
  .ai-shell > header nav button {
    padding: 0 11px;
  }
  .memory-dialog {
    padding: 24px 18px;
    border-radius: 22px;
  }
}
