/* A High Guide — whimsical theme.
   Rounded, sunny, playful. Serious answers wrapped in good vibes. */

:root {
  --cream:   #fff7ec;
  --paper:   #fffdf8;
  --ink:     #3a2e4d;              /* warm plummy near-black */
  --ink-soft:#6a5d7a;
  --muted:   #9b8fa8;
  --line:    #efe2d6;

  --leaf:    #43b968;             /* joyful green */
  --leaf-dk: #2f9a53;
  --grape:   #7c5cbf;             /* playful purple */
  --sun:     #ffb13c;             /* sunny orange */
  --berry:   #ff6b9d;             /* pink pop */
  --sky:     #4cc3e0;             /* aqua */
  --mint:    #d9f5e4;

  --display: 'Fredoka', system-ui, sans-serif;
  --body:    'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius:   22px;
  --radius-sm:14px;
  --radius-pill: 999px;
  --shadow-soft: 0 10px 30px rgba(58,46,77,0.10);
  --shadow-pop:  0 6px 0 rgba(58,46,77,0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, #fff0d6 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ffe4ef 0%, transparent 50%),
    radial-gradient(1000px 700px at 50% 120%, #e2f7ea 0%, transparent 55%),
    var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- FLOATING BLOBS ---------- */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
  animation: float 14s ease-in-out infinite;
}
.blob-1 { width: 320px; height: 320px; background: #ffd59e; top: 8%;  left: -80px; animation-delay: 0s; }
.blob-2 { width: 260px; height: 260px; background: #cdb8f2; top: 55%; right: -70px; animation-delay: -4s; }
.blob-3 { width: 240px; height: 240px; background: #a8ebc4; bottom: -60px; left: 30%; animation-delay: -8s; }
@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(20px,-25px) scale(1.06); }
  66%     { transform: translate(-15px,15px) scale(0.96); }
}

/* ---------- HERO ---------- */
.hero { position: relative; z-index: 1; padding: 34px 20px 10px; }
.hero-inner {
  max-width: 820px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 6px;
}
.brand {
  display: inline-flex; align-items: center; gap: 14px;
  font-family: var(--display);
  font-size: 42px; font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-words {
  background: linear-gradient(100deg, var(--leaf-dk) 0%, var(--leaf) 40%, var(--grape) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand-mark {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle at 36% 34%, #ffe08a 0 22%, transparent 24%),
    radial-gradient(circle at 66% 64%, #a8ebc4 0 26%, transparent 28%),
    linear-gradient(135deg, var(--leaf) 0%, var(--leaf-dk) 100%);
  box-shadow: 0 6px 0 rgba(47,154,83,0.35), inset 0 0 0 3px rgba(255,255,255,0.5);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1);
}
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.08); }
.tagline {
  margin: 2px 0 0; font-size: 19px; font-weight: 600; color: var(--ink-soft);
}
.tagline-pop {
  color: var(--berry); font-weight: 700;
}

/* ---------- MAIN CHAT ---------- */
#chat {
  position: relative; z-index: 1;
  flex: 1; width: 100%; max-width: 820px;
  margin: 0 auto; padding: 6px 20px 20px;
  display: flex; flex-direction: column; min-height: 0;
}
#messages {
  list-style: none; padding: 0; margin: 18px 0 12px;
  display: flex; flex-direction: column; gap: 18px; min-height: 0;
}

/* ---------- WELCOME ---------- */
#welcome {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  margin: 14px 0 8px;
  box-shadow: var(--shadow-soft);
  position: relative;
}
#welcome h2 {
  font-family: var(--display);
  font-size: 30px; font-weight: 700; line-height: 1.15;
  margin: 0 0 12px; color: var(--ink);
}
#welcome p { margin: 0 0 14px; color: var(--ink-soft); font-size: 16px; }
.welcome-nudge {
  font-weight: 700; color: var(--grape);
  font-size: 15px; margin-bottom: 12px !important;
}
.prompt-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 2px solid transparent;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--body); font-size: 14.5px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(.34,1.56,.64,1), box-shadow 0.15s ease, filter 0.15s ease;
  box-shadow: var(--shadow-pop);
}
.chip:hover { transform: translateY(-3px) rotate(-1deg); filter: brightness(1.03); }
.chip:active { transform: translateY(0); }
.chip-a { background: #eaf6ee; color: var(--leaf-dk); border-color: #bfe8cd; }
.chip-b { background: #f1ecfb; color: var(--grape);   border-color: #d8caf2; }
.chip-c { background: #fff3dc; color: #b9791a;         border-color: #ffdfa0; }
.chip-d { background: #fde8f0; color: #c94b7a;         border-color: #f9c6da; }

/* ---------- MESSAGES ---------- */
.message { display: flex; flex-direction: column; max-width: 88%; }
.message.user      { align-self: flex-end;   align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.tier-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: var(--radius-pill);
  font-family: var(--display);
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  margin-bottom: 8px; border: 2px solid transparent;
}
.tier-badge.tier1 { background: var(--mint);   color: var(--leaf-dk); border-color: #bfe8cd; }
.tier-badge.tier2 { background: #f1ecfb;        color: var(--grape);   border-color: #d8caf2; }

.bubble {
  padding: 15px 19px; border-radius: 20px;
  font-size: 16px; line-height: 1.6;
  box-shadow: var(--shadow-soft);
  overflow-wrap: break-word; word-break: break-word; white-space: pre-wrap;
}
.bubble strong { color: var(--leaf-dk); font-weight: 800; }
.bubble code {
  background: rgba(124,92,191,0.10); color: var(--grape);
  padding: 1px 6px; border-radius: 6px; font-size: 0.9em;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.message.user .bubble {
  background: linear-gradient(135deg, var(--leaf) 0%, var(--leaf-dk) 100%);
  color: #fff; border-bottom-right-radius: 6px;
}
.message.user .bubble strong { color: #eaf6ee; }
.message.assistant .bubble {
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--line); border-bottom-left-radius: 6px;
}

/* ---------- CITATIONS ---------- */
.citations {
  margin-top: 14px; padding: 15px 17px;
  background: #fffdf8;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px; max-width: 100%;
}
.citations-header {
  font-family: var(--display);
  font-size: 13px; font-weight: 600; color: var(--grape);
  margin-bottom: 12px;
}
.citation {
  margin: 0 0 13px; padding-bottom: 13px;
  border-bottom: 1px dashed var(--line);
}
.citation:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.citation-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase;
  background: #fff; border: 2px solid var(--line); color: var(--ink-soft);
}
.source-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; }
.source-chip.src-fda::before        { background: var(--sky); }
.source-chip.src-pmc::before        { background: var(--grape); }
.source-chip.src-ocm::before        { background: var(--sun); }
.source-chip.src-canndir::before    { background: var(--berry); }
.source-chip.src-greg-tier1::before { background: var(--leaf); }
.source-chip.src-greg-tier2::before { background: var(--leaf-dk); }
.source-chip.src-unknown::before    { background: var(--muted); }

.citation-label { font-family: var(--display); color: var(--ink); font-weight: 600; font-size: 13.5px; }
.citation-link {
  font-size: 12px; color: var(--grape); text-decoration: none;
  border-bottom: 1px dotted var(--grape); word-break: break-all;
}
.citation-link:hover { color: var(--berry); border-bottom-color: var(--berry); }
.citation-snippet { color: var(--ink-soft); font-size: 12.5px; line-height: 1.55; margin-top: 6px; }
.citation-snippet b { color: var(--berry); background: rgba(255,107,157,0.12); padding: 0 3px; border-radius: 4px; font-weight: 800; }

/* ---------- FEEDBACK ---------- */
.feedback-buttons { display: flex; gap: 8px; margin-top: 12px; }
.feedback-buttons button {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius-pill);
  padding: 5px 15px; cursor: pointer; font-family: var(--body);
  font-size: 14px; font-weight: 700; color: var(--ink-soft);
  transition: transform 0.15s cubic-bezier(.34,1.56,.64,1), background 0.15s ease, border-color 0.15s ease;
}
.feedback-buttons button:hover { transform: translateY(-2px); border-color: var(--leaf); }
.feedback-buttons button.active { background: var(--leaf); color: #fff; border-color: var(--leaf); }

/* ---------- COMPOSER ---------- */
#composer {
  display: flex; gap: 10px;
  padding: 12px 12px 12px 20px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  position: sticky; bottom: 14px; margin-top: auto;
}
#messageInput {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 16.5px; font-weight: 600;
  padding: 11px 4px;
}
#messageInput::placeholder { color: var(--muted); font-weight: 600; }
#sendBtn {
  border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--leaf) 0%, var(--grape) 130%);
  color: #fff; font-family: var(--display); font-weight: 600; font-size: 16px;
  padding: 11px 22px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 0 rgba(47,154,83,0.30);
  transition: transform 0.12s cubic-bezier(.34,1.56,.64,1), box-shadow 0.12s ease, filter 0.12s ease;
}
#sendBtn:hover { filter: brightness(1.05); transform: translateY(-2px); }
#sendBtn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(47,154,83,0.30); }
#sendBtn:disabled { background: var(--muted); box-shadow: none; cursor: wait; opacity: 0.75; }
#sendBtn svg { transition: transform 0.2s ease; }
#sendBtn:hover svg { transform: translateX(3px) rotate(8deg); }

/* ---------- THINKING DOTS ---------- */
.thinking .bubble {
  color: var(--muted); font-style: italic;
  display: inline-flex; gap: 6px; align-items: center;
}
.thinking .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); animation: bounce 1.1s infinite ease-in-out; }
.thinking .dot:nth-child(2) { background: var(--sun);   animation-delay: 0.15s; }
.thinking .dot:nth-child(3) { background: var(--berry); animation-delay: 0.3s; }
@keyframes bounce {
  0%,80%,100% { opacity: 0.35; transform: translateY(0) scale(0.85); }
  40%         { opacity: 1;    transform: translateY(-5px) scale(1.15); }
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message { animation: fadeUp 0.3s cubic-bezier(.34,1.56,.64,1); }

/* ---------- FOOTER ---------- */
footer {
  position: relative; z-index: 1;
  padding: 12px 20px 24px; text-align: center;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
  max-width: 820px; margin: 0 auto;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 600px) {
  .hero { padding: 26px 16px 6px; }
  .brand { font-size: 34px; gap: 10px; }
  .brand-mark { width: 40px; height: 40px; }
  .tagline { font-size: 17px; }
  #welcome { padding: 22px 20px 18px; }
  #welcome h2 { font-size: 25px; }
  .bubble { font-size: 15.5px; padding: 13px 15px; }
  .message { max-width: 94%; }
  #chat { padding: 6px 12px 16px; }
  .blob { opacity: 0.35; }
}
