:root {
  --bg: #faf6ef;
  --ink: #25302a;
  --muted: #6c7670;
  --line: #e7dfd2;
  --card: #ffffff;
  --forest: #2e5e46;
  --forest-2: #3f7a5c;
  --user: #2e5e46;
  --note: #fff7e6;
  --chip: #eef3ee;
  --radius: 18px;
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", "Sukhumvit Set", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--forest);
  font-size: 24px;
}
.top h1 { margin: 0; font-size: 18px; font-weight: 600; }
.top p { margin: 0; font-size: 13px; color: var(--muted); }
.human {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--forest);
  border-radius: 999px;
  color: var(--forest);
  font-size: 14px;
  text-decoration: none;
}
.human:hover { background: var(--forest); color: #fff; }

#log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg { max-width: 88%; line-height: 1.65; font-size: 15.5px; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg.user {
  align-self: flex-end;
  background: var(--user);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.bot {
  align-self: flex-start;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
}
.msg.bot::before {
  content: "🐱";
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chip);
  font-size: 18px;
}
.bubble {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  overflow-wrap: anywhere;
}

.card-title { font-weight: 600; margin-bottom: 6px; color: var(--forest); }
.card-body p { margin: 0 0 1em; }
.card-body ul { margin: -0.4em 0 1em; padding-left: 1.3em; }
.card-body li { margin-bottom: 0.35em; }
.card-body > :last-child { margin-bottom: 0; }
.card-body a, .bubble a { color: var(--forest-2); }
.note {
  margin-top: 10px !important;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--note);
  font-size: 14px;
}
.sources { margin-top: 10px; font-size: 13px; color: var(--muted); }
.sprinkle { margin-top: 10px !important; color: var(--muted); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chips-label { width: 100%; font-size: 13px; color: var(--muted); }
.chip {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip:hover { border-color: var(--forest-2); }
.chip.chip-hilite { background: #d2f4dd; border-color: var(--forest-2); }
.chip.chip-hilite:hover { background: #bdeecd; }

.rate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--muted);
}
.rate span { margin-right: 2px; }
.rate button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 16px;
  line-height: 1.6;
  cursor: pointer;
}
.rate button:hover { border-color: var(--forest-2); }
.rate .btn-human { margin-top: 4px; }

.btn-human {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--forest);
  color: #fff !important;
  text-decoration: none;
  font-size: 14px;
}

.typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.dock {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
#ask { display: flex; gap: 8px; }
#q {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
#q:focus { outline: 2px solid var(--forest-2); outline-offset: 1px; }
#ask button {
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--forest);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.fine { margin: 8px 4px 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

@media (max-width: 480px) {
  .msg { max-width: 96%; }
  .top p { display: none; }
}

.card-body ul.shops {margin:.2em 0 1em; padding-left:1.3em}
.shops li {margin-bottom:.45em}
.shop-name {margin-right:.35em}
a.shop-link {display:inline-block; margin-right:.3em; padding:.14em .65em; border:0; border-radius:999px; font-size:.86em; font-weight:600; text-decoration:none; color:#fff}
a.shop-link.shopee {background:#ff7d3c}  /* ส้มโทนสว่าง ตามที่เจ้าของแบรนด์เลือก 20 ก.ย. 2569 */
a.shop-link.lazada {background:#7b2ff2}
a.shop-link:hover, a.shop-link:focus-visible {filter:brightness(.92); color:#fff}
