:root {
  --green: #1f5c3d;
  --green-dark: #143f2a;
  --green-soft: #e8f1ec;
  --gold: #c8912f;
  --bg: #f5f7f5;
  --card: #ffffff;
  --ink: #1a2420;
  --ink-soft: #566159;
  --line: #e2e8e4;
  --bot-bubble: #ffffff;
  --user-bubble: #1f5c3d;
  --radius: 16px;
  --maxw: 760px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--bg);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0));
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(20, 63, 42, 0.18);
  z-index: 2;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-badge {
  font-size: 26px;
  background: rgba(255, 255, 255, 0.15);
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
}
.brand-text {
  min-width: 0;
}
.brand-text h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-tag {
  flex: none;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gold);
  color: #3a2a05;
  padding: 5px 9px;
  border-radius: 999px;
}

/* Chat area */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 9px;
  max-width: 92%;
  animation: rise 0.22s ease-out;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.msg .avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  margin-top: 2px;
}
.msg.bot .avatar {
  background: var(--green-soft);
}
.msg.user {
  margin-left: auto;
  flex-direction: row-reverse;
}
.bubble {
  padding: 11px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 0.96rem;
  word-wrap: break-word;
}
.msg.bot .bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--line);
  border-top-left-radius: 5px;
  color: var(--ink);
}
.msg.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-top-right-radius: 5px;
}

/* Markdown-ish content inside bubbles */
.bubble p {
  margin: 0 0 8px;
}
.bubble p:last-child {
  margin-bottom: 0;
}
.bubble ul,
.bubble ol {
  margin: 6px 0 8px;
  padding-left: 20px;
}
.bubble li {
  margin: 3px 0;
}
.bubble strong {
  font-weight: 700;
}
.bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.86em;
}
.msg.user .bubble code {
  background: rgba(255, 255, 255, 0.2);
}
.bubble a {
  color: var(--green);
  text-decoration: underline;
}
.msg.user .bubble a {
  color: #fff;
}

/* Typing indicator */
.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}
.typing span {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  opacity: 0.4;
  animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Suggestion chips */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 14px 6px;
}
.chip {
  border: 1px solid var(--green);
  color: var(--green);
  background: #fff;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  line-height: 1.2;
}
.chip:hover {
  background: var(--green-soft);
}
.chip:active {
  transform: scale(0.97);
}

/* Composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0));
  background: var(--card);
  border-top: 1px solid var(--line);
}
.input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 11px 15px;
  font: inherit;
  font-size: 0.96rem;
  max-height: 140px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 92, 61, 0.12);
}
.send {
  flex: none;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.send:hover {
  background: var(--green-dark);
}
.send:active {
  transform: scale(0.94);
}
.send:disabled {
  background: #b9c6be;
  cursor: default;
}

.disclaimer {
  margin: 0;
  padding: 0 16px calc(10px + env(safe-area-inset-bottom, 0));
  background: var(--card);
  font-size: 0.68rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .brand-text p {
    font-size: 0.68rem;
  }
  .bubble {
    font-size: 0.94rem;
  }
}
