@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Inter+Tight:wght@400;500;600;700&family=Jost:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
  --font-ui: "Jost";
  --bg: #f5fbf5;
  --panel: #ffffff;
  --panel-2: #eef8ef;
  --text: #16321f;
  --muted: #5f7b68;
  --border: #c7ddcb;
  --accent: #2f9e44;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  font-family: var(--font-ui), "Inter Tight", "DM Sans", Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.chat-main {
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hero {
  text-align: left;
  padding: 18px 20px 14px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  transition: background 220ms ease, backdrop-filter 220ms ease;
  pointer-events: none;
}

.hero .prompt {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50vh;
  top: 50dvh;
  transform: translate(-50%, -145px);
  width: min(900px, calc(100% - 32px));
  transition: opacity 280ms ease, transform 360ms ease;
}

.hero .brand {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 600;
}

.messages {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  padding: 122px 20px var(--composer-pad, 96px);
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge legacy */
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.msg {
  max-width: 100%;
  line-height: 1.6;
  white-space: pre-wrap;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px 16px;
  background: var(--panel-2);
  scroll-margin-top: 128px;
  scroll-margin-bottom: 96px;
}

.msg.enter {
  animation: riseIn 220ms cubic-bezier(.2, .8, .2, 1);
}

.msg.user {
  align-self: flex-end;
  max-width: 78%;
  background: #ffffff;
  border-color: #71b57f;
  box-shadow: 0 0 0 1px #2f9e4438;
  color: var(--text);
}

.msg.bot {
  align-self: stretch;
  background: transparent;
  border-color: transparent;
  padding-left: 2px;
  padding-right: 2px;
}

.composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 16px 20px;
  background: linear-gradient(180deg, transparent, rgba(245, 251, 245, 0.97) 24%);
  z-index: 4;
  transition: transform 360ms ease, background 220ms ease;
}

.composer textarea {
  display: block;
  width: 100%;
  margin: 0;
  border-radius: 28px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  resize: none;
  min-height: 56px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 16px 64px 16px 22px;
  outline: none;
  transition: background-color 140ms ease;
}

.composer-input {
  display: block;
  width: min(880px, 100%);
  margin: 0 auto;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: inset 0 0 0 1px transparent;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
  position: relative;
}

.composer textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.composer-input:focus-within {
  border-color: #71b57f;
  box-shadow: 0 0 0 1px #2f9e4438;
}

.send-btn {
  position: absolute;
  right: 9px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  background: #2f9e44;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.send-btn:hover {
  background: #27843a;
}

.send-btn:active {
  transform: translateY(1px);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-main.init .composer {
  top: 50%;
  bottom: auto;
  transform: translateY(-20px);
  background: transparent;
}

.chat-main.init .hero .prompt {
  opacity: 1;
  transform: translate(-50%, -145px);
}

.chat-main.init .messages {
  opacity: 0;
  pointer-events: none;
}

.chat-main:not(.init) .hero .prompt {
  opacity: 0;
  transform: translate(-50%, -168px);
}

/* Active chat mode: hero sticks at top with a readable backdrop */
.chat-main:not(.init) .hero {
  background: linear-gradient(
    180deg,
    rgba(245, 251, 245, 0.98) 58%,
    rgba(245, 251, 245, 0.92) 76%,
    rgba(245, 251, 245, 0) 100%
  );
  backdrop-filter: blur(4px);
}

.typing { display: inline-flex; gap: 6px; align-items: center; }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2f9e44;
  animation: pulse 1s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }

@media (max-width: 768px) {
  .composer {
    /* Avoid jumpy first-submit transitions with mobile keyboard viewport changes. */
    transition: background 220ms ease;
  }
}

@keyframes pulse {
  0%, 100% { transform: translateY(0); opacity: .35; }
  50% { transform: translateY(-4px); opacity: 1; }
}

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