:root {
  --ff-green: #0a9d57;
  --ff-green-dark: #078048;
  --ff-black: #1a1a1a;
  --ff-bg: #f5f7f6;
  --ff-card: #ffffff;
  --ff-border: #e3e7e5;
  --ff-muted: #6b7570;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--ff-bg);
  color: var(--ff-black);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ff-card);
  box-shadow: 0 0 40px rgba(0,0,0,0.05);
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ff-border);
  position: sticky;
  top: 0;
  background: var(--ff-card);
  z-index: 5;
}

header.topbar img { height: 34px; }

header.topbar .title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

header.topbar .title strong { font-size: 15px; }
header.topbar .title span { font-size: 12.5px; color: var(--ff-muted); }

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { display: flex; gap: 10px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot { align-self: flex-start; }

.bubble {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.msg.user .bubble {
  background: var(--ff-green);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.bot .bubble {
  background: #f0f2f1;
  color: var(--ff-black);
  border-bottom-left-radius: 4px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ff-green);
  color: white;
  font-size: 13px;
  font-weight: 600;
}

.msg.user .avatar { background: #333; }

.cards { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; width: 100%; }

.card {
  border: 1px solid var(--ff-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: white;
}

.card.preferred { border-color: var(--ff-green); }
.card .name { font-weight: 700; font-size: 14.5px; margin-bottom: 2px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .name-text { overflow-wrap: anywhere; }
.pref-badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: white;
  background: var(--ff-green);
  border-radius: 999px;
  padding: 3px 11px;
}
.card .cat { font-size: 12.5px; color: var(--ff-green-dark); font-weight: 600; margin-bottom: 6px; }
.card .desc { font-size: 13px; color: #444; margin-bottom: 8px; }
.card .meta { font-size: 12.5px; color: var(--ff-muted); display: flex; flex-wrap: wrap; gap: 10px; }
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.card .funds { font-size: 11.5px; color: var(--ff-muted); margin-top: 6px; }
.card .funds b { color: #333; }

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ff-muted);
  animation: blink 1.2s infinite ease-in-out;
}
.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.2; } 40% { opacity: 1; } }

form#composer {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--ff-border);
  background: var(--ff-card);
}

form#composer input {
  flex: 1;
  border: 1px solid var(--ff-border);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 14.5px;
  outline: none;
}

form#composer input:focus { border-color: var(--ff-green); }

form#composer button {
  border: none;
  background: var(--ff-green);
  color: white;
  border-radius: 999px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

form#composer button:disabled { opacity: 0.5; cursor: default; }
form#composer button:hover:not(:disabled) { background: var(--ff-green-dark); }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 14px; }
.suggestions button {
  border: 1px solid var(--ff-border);
  background: white;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--ff-black);
}
.suggestions button:hover { border-color: var(--ff-green); color: var(--ff-green-dark); }

.feedback { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.feedback-label { font-size: 11.5px; color: var(--ff-muted); }
.fb-btn {
  border: 1px solid var(--ff-border);
  background: white;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.fb-btn:hover { border-color: var(--ff-green); }
.fb-btn:disabled { opacity: 0.5; cursor: default; }

.error-banner {
  background: #fdecec;
  color: #9c1f1f;
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f3caca;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ff-bg: #14161a;
    --ff-card: #1c1f24;
    --ff-border: #2b2f35;
    --ff-black: #f0f1f2;
    --ff-muted: #9aa2a0;
  }
  .msg.bot .bubble { background: #262a30; color: #f0f1f2; }
  .card { background: #20242a; }
  .suggestions button { background: #20242a; color: #eee; }
  .fb-btn { background: #20242a; }
}
