:root {
  --green-deep: #0f3d2e;
  --green-mid: #166534;
  --green-bright: #22c55e;
  --green-soft: #dcfce7;
  --gold: #ca8a04;
  --gold-soft: #fef9c3;
  --gold-pale: #fefce8;
  --bubble-assistant: #fffbeb;
  --bubble-assistant-border: rgba(202, 138, 4, 0.28);
  --bubble-user: #15803d;
  --ink: #0f172a;
  --muted: #64748b;
  --card: #ffffff;
  --shadow: 0 4px 24px rgba(15, 61, 46, 0.08);
  --shadow-lift: 0 8px 28px rgba(15, 61, 46, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, #ecfdf5 0%, #f7fee7 45%, #fefce8 100%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

#intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, rgba(15, 61, 46, 0.92), rgba(22, 101, 52, 0.88));
  backdrop-filter: blur(8px);
  animation: introFadeIn 0.6s ease-out;
}

#intro.hidden { display: none; }
#intro.leaving { animation: introFadeOut 0.35s ease-in forwards; }
#intro.leaving .intro-card { animation: cardSink 0.35s var(--ease-out) forwards; }

@keyframes introFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes introFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes cardSink {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0.85; transform: translateY(12px) scale(0.97); }
}
@keyframes cardPop {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes appIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes avatarGlow {
  0%, 100% { box-shadow: 0 4px 20px rgba(34, 197, 94, 0.25); }
  50% { box-shadow: 0 4px 28px rgba(202, 138, 4, 0.35); }
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.9); }
}
@keyframes pulseFast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
@keyframes barPop {
  from { transform: scaleY(0.15); opacity: 0.4; }
  to { transform: scaleY(1); opacity: 0.9; }
}

@keyframes barWaveIdle {
  0%, 100% { transform: scaleY(0.72); opacity: 0.82; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes barWaveThink {
  0%, 100% { transform: scaleY(0.42); opacity: 0.75; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes barWaveWarn {
  0%, 100% { transform: scaleY(0.65); opacity: 0.72; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes barFlashOnce {
  0%, 100% { transform: scaleY(1); filter: brightness(1); }
  35% { transform: scaleY(1.22); filter: brightness(1.18); }
  70% { transform: scaleY(0.95); filter: brightness(1.06); }
}

@keyframes statusPillPulse {
  0%, 100% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.04); box-shadow: 0 4px 14px rgba(202, 138, 4, 0.22); }
}

@keyframes offlineShimmer {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 0.62; }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes avatarNudge {
  from { transform: scale(0.9) rotate(-4deg); opacity: 0.6; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes dots {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.45; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

.intro-card {
  max-width: 420px;
  width: 100%;
  background: var(--card);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  animation: cardPop 0.55s var(--ease-out) 0.1s both;
}

.intro-card h2 {
  margin: 0.35rem 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-deep);
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green-mid);
  background: var(--green-soft);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.intro-card p {
  margin: 0.65rem 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.intro-steps {
  margin: 1rem 0 1.25rem;
  padding: 0;
  list-style: none;
}

.intro-steps li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
  color: #334155;
}

.intro-steps .num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-bright), var(--green-mid));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.intro-actions { display: flex; flex-direction: column; gap: 0.5rem; }

.btn-primary,
.btn-ghost,
.icon-btn,
.send-btn,
.chip {
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--green-mid), var(--green-deep));
  color: #fff;
  box-shadow: 0 4px 14px rgba(22, 101, 52, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(22, 101, 52, 0.4); }

.btn-ghost {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.intro-warn {
  margin-top: 1rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--gold-pale);
  border-left: 4px solid var(--gold);
  font-size: 0.8rem;
  color: #713f12;
  line-height: 1.45;
}

#app {
  max-width: 740px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.85rem 0.8rem;
  animation: appIn 0.45s ease-out;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0 0.45rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--green-bright), var(--green-mid));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  animation: avatarGlow 3s ease-in-out infinite;
  color: #f8fff7;
}

.leaf-icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.brand-text h1 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--green-deep);
  letter-spacing: -0.02em;
}

.brand-text .sub {
  margin: 0.1rem 0 0;
  font-size: 0.66rem;
  color: var(--muted);
  font-weight: 500;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-cluster.graph-flash .trust-strip .bar {
  animation-name: barFlashOnce !important;
  animation-duration: 0.52s !important;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1) !important;
  animation-iteration-count: 1 !important;
}

.status-cluster.graph-flash .trust-strip .bar:nth-child(1) { animation-delay: 0ms !important; }
.status-cluster.graph-flash .trust-strip .bar:nth-child(2) { animation-delay: 45ms !important; }
.status-cluster.graph-flash .trust-strip .bar:nth-child(3) { animation-delay: 90ms !important; }
.status-cluster.graph-flash .trust-strip .bar:nth-child(4) { animation-delay: 135ms !important; }
.status-cluster.graph-flash .trust-strip .bar:nth-child(5) { animation-delay: 180ms !important; }
.status-cluster.graph-flash .trust-strip .bar:nth-child(6) { animation-delay: 225ms !important; }

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--green-mid);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(22, 101, 52, 0.15);
  transition: border-color 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.status-cluster.thinking .status-pill .status-dot {
  background: var(--gold);
  animation: pulseFast 0.8s ease-in-out infinite;
}

.status-cluster.thinking .status-pill {
  color: #854d0e;
  border-color: rgba(202, 138, 4, 0.35);
  animation: statusPillPulse 1.05s ease-in-out infinite;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-bright);
  animation: pulseDot 2s ease-in-out infinite;
}

.status-cluster.offline .status-dot {
  background: #94a3b8;
  animation: offlineShimmer 2.5s ease-in-out infinite;
}

.status-cluster.offline .status-pill {
  color: var(--muted);
  border-color: rgba(100, 116, 139, 0.35);
}

.status-cluster.index-missing:not(.thinking) .status-pill {
  color: #92400e;
  border-color: rgba(202, 138, 4, 0.45);
}

.trust-strip {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 28px;
  padding: 0 0.15rem;
}

.activity-graph {
  cursor: pointer;
  border-radius: 10px;
  padding: 2px 4px;
  margin: -2px -4px;
  outline: none;
  transition: background 0.2s ease, transform 0.12s ease;
}

.activity-graph:hover {
  background: rgba(255, 255, 255, 0.55);
}

.activity-graph:focus-visible {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.45);
}

.activity-graph:active {
  transform: scale(0.97);
}

.trust-strip .bar {
  width: 7px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--green-bright), var(--green-mid));
  opacity: 0.92;
  transform-origin: bottom center;
  animation: barWaveIdle 2.65s ease-in-out infinite;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

.trust-strip .bar:nth-child(1) { animation-delay: 0s; }
.trust-strip .bar:nth-child(2) { animation-delay: 0.12s; }
.trust-strip .bar:nth-child(3) { animation-delay: 0.24s; }
.trust-strip .bar:nth-child(4) { animation-delay: 0.36s; }
.trust-strip .bar:nth-child(5) { animation-delay: 0.48s; }
.trust-strip .bar:nth-child(6) { animation-delay: 0.6s; }

.activity-graph:hover .bar {
  filter: brightness(1.1) saturate(1.08);
}

.status-cluster.thinking .trust-strip .bar {
  animation-name: barWaveThink;
  animation-duration: 0.58s;
  animation-timing-function: ease-in-out;
}

.status-cluster.thinking .trust-strip .bar:nth-child(1) { animation-delay: 0s; }
.status-cluster.thinking .trust-strip .bar:nth-child(2) { animation-delay: 0.06s; }
.status-cluster.thinking .trust-strip .bar:nth-child(3) { animation-delay: 0.12s; }
.status-cluster.thinking .trust-strip .bar:nth-child(4) { animation-delay: 0.18s; }
.status-cluster.thinking .trust-strip .bar:nth-child(5) { animation-delay: 0.24s; }
.status-cluster.thinking .trust-strip .bar:nth-child(6) { animation-delay: 0.3s; }

.status-cluster.offline .trust-strip .bar {
  animation: none;
  transform: scaleY(0.38);
  opacity: 0.45;
  filter: grayscale(0.35);
}

.status-cluster.index-missing:not(.thinking) .trust-strip .bar {
  animation-name: barWaveWarn;
  animation-duration: 3.1s;
}

.trust-strip .bar.small { height: 36%; }
.trust-strip .bar.mid { height: 62%; }
.trust-strip .bar.tall { height: 90%; }
.trust-strip .bar.gold { background: linear-gradient(180deg, #fde047, var(--gold)); }

@media (prefers-reduced-motion: reduce) {
  .status-cluster.graph-flash .trust-strip .bar {
    animation: none !important;
  }

  .trust-strip .bar {
    animation: none !important;
    transform: none !important;
    opacity: 0.9;
  }

  .status-cluster.thinking .trust-strip .bar {
    opacity: 1;
  }

  .status-cluster.thinking .status-pill {
    animation: none;
  }

  .activity-graph:active {
    transform: none;
  }
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.7);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 0.9rem;
  color: var(--green-mid);
  transition: background 0.15s, transform 0.15s;
}

.icon-btn:hover { background: #fff; transform: scale(1.05); }
.icon-btn:focus-visible {
  outline: 2px solid var(--green-bright);
  outline-offset: 2px;
}

.icon-label {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--green-mid);
  padding: 0 0.25rem;
}

.status-card {
  margin: 0.2rem 0 0.75rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.95));
  color: #f8fafc;
  padding: 1rem 1rem 0.95rem;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: none;
}

.status-card.open { display: block; animation: msgIn 0.28s var(--ease-out); }

.status-card h3 {
  margin: 0 0 0.7rem;
  font-size: 1.2rem;
  color: #fff;
}

.status-card .line {
  font-size: 0.95rem;
  line-height: 1.55;
  margin-top: 0.32rem;
  color: rgba(248, 250, 252, 0.96);
}

.status-card .status-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.95rem;
  flex-wrap: wrap;
}

.status-card .status-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 220px;
  transition: transform 0.12s ease, background 0.15s ease;
}

.status-card .status-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.08); }
.status-card .status-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.status-card .footnote {
  margin-top: 0.8rem;
  font-size: 0.88rem;
  color: rgba(241, 245, 249, 0.86);
  line-height: 1.5;
}

#chat-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 0.35rem 0 0.75rem;
  min-height: 200px;
  max-height: calc(100dvh - 240px);
}

.msg {
  margin-bottom: 0.7rem;
  animation: msgIn 0.48s var(--ease-out) both;
}

.msg-cloud {
  display: flex;
  width: 100%;
  align-items: flex-end;
  gap: 0.4rem;
}

.msg.user .msg-cloud { justify-content: flex-end; }
.msg.assistant .msg-cloud { justify-content: flex-start; }

.msg-avatar {
  flex-shrink: 0;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin-bottom: 1px;
  background: linear-gradient(145deg, var(--green-bright), var(--green-mid));
  border: 1px solid rgba(22, 101, 52, 0.22);
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.22);
  animation: avatarNudge 0.6s var(--ease-out) both;
  color: #f8fff7;
}

.bubble-wrap {
  max-width: min(82%, 465px);
  position: relative;
  filter: drop-shadow(0 2px 10px rgba(15, 61, 46, 0.06));
}

.bubble {
  padding: 0.72rem 0.82rem;
  border-radius: var(--radius);
  line-height: 1.42;
  font-size: 0.82rem;
  position: relative;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s ease;
}

.msg.assistant .bubble-wrap:hover .bubble {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}

.msg.assistant .bubble {
  background: var(--bubble-assistant);
  color: #1e293b;
  border: 1px solid var(--bubble-assistant-border);
  border-radius: 16px 16px 16px 6px;
  box-shadow: var(--shadow);
}

.msg.assistant .bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 10px;
  width: 12px;
  height: 12px;
  background: var(--bubble-assistant);
  border-left: 1px solid var(--bubble-assistant-border);
  border-bottom: 1px solid var(--bubble-assistant-border);
  transform: rotate(45deg);
  border-bottom-left-radius: 4px;
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--bubble-user), var(--green-mid));
  color: #fff;
  border-radius: 16px 16px 6px 16px;
  box-shadow: 0 6px 18px rgba(22, 101, 52, 0.18);
}

.msg.user .bubble::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 10px;
  width: 12px;
  height: 12px;
  background: var(--bubble-user);
  transform: rotate(45deg);
  border-bottom-right-radius: 4px;
}

.bubble-title {
  margin: 0 0 0.28rem;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.72;
}

.bubble-text {
  margin: 0;
  white-space: pre-wrap;
}

.bubble-meta {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(15, 61, 46, 0.08);
  font-size: 0.72rem;
}

.meta-line {
  margin-top: 0.12rem;
  color: #475569;
}

.meta-line strong {
  color: #334155;
}

.source-link {
  color: #1d4ed8;
  text-decoration: underline;
  word-break: break-word;
}

.source-details {
  margin-top: 0.48rem;
  border-top: 1px dashed rgba(22, 101, 52, 0.18);
  padding-top: 0.45rem;
}

.source-details details {
  border: 1px solid rgba(22, 101, 52, 0.12);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  padding: 0.42rem 0.58rem;
}

.source-details summary {
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--green-mid);
  list-style: none;
}

.source-details summary::-webkit-details-marker {
  display: none;
}

.source-details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
}

.source-details details[open] summary::before {
  transform: rotate(90deg);
}

.source-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.source-item {
  border-radius: 10px;
  background: rgba(237, 247, 234, 0.85);
  border: 1px solid rgba(22, 101, 52, 0.12);
  padding: 0.6rem 0.7rem;
}

.source-item .title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--green-deep);
  margin-bottom: 0.3rem;
}

.source-item .line {
  font-size: 0.73rem;
  color: #334155;
  word-break: break-word;
  margin-top: 0.18rem;
}

.source-item .excerpt {
  margin-top: 0.38rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #1e293b;
  white-space: normal;
}

.bubble-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.bubble-actions button {
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 0.24rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(22, 101, 52, 0.2);
  background: rgba(255, 255, 255, 0.75);
  color: var(--green-mid);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s ease;
}

.bubble-actions button:hover { background: #fff; transform: translateY(-1px); }

.bubble-actions button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.msg.user .bubble-actions { justify-content: flex-end; }

.msg.user .bubble-actions button {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #ecfdf5;
}

.typing-row {
  display: none;
  align-items: flex-end;
  gap: 0.38rem;
  margin-bottom: 0.55rem;
  padding-left: calc(31px + 0.4rem);
  min-height: 2.2rem;
}

.typing-row.visible { display: flex; animation: msgIn 0.38s var(--ease-out); }

.typing-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--green-bright), var(--green-mid));
  display: grid;
  place-items: center;
  color: #f8fff7;
}

.typing-bubble {
  background: #fff;
  border: 1px solid rgba(202, 138, 4, 0.2);
  border-radius: 14px;
  padding: 0.65rem 1rem;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-mid);
  animation: bounce 1.2s ease-in-out infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.composer-panel,
.composer-wrap {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(236, 253, 245, 0) 0%, rgba(236, 253, 245, 0.88) 24%, rgba(248, 250, 230, 0.96) 100%);
  padding-top: 0.45rem;
}

.composer-row,
.composer {
  display: flex;
  gap: 0.45rem;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(22, 101, 52, 0.12);
  border-radius: 18px;
  padding: 0.45rem;
  box-shadow: 0 6px 18px rgba(15, 61, 46, 0.08);
}

.composer:focus-within {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 3px rgba(254, 249, 195, 0.9), var(--shadow);
}

textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.35;
  min-height: 22px;
  max-height: 180px;
  color: var(--ink);
  padding: 0.18rem 0.24rem;
}

.send-btn,
.composer .send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green-mid), var(--green-deep));
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 6px 16px rgba(22, 101, 52, 0.22);
}

.composer .send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.composer .send:not(:disabled):hover { transform: scale(1.04); }
.composer .send:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.chip-row,
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.38rem;
  margin-top: 0.45rem;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

.chip {
  border: 1px solid rgba(22, 101, 52, 0.14);
  background: rgba(255, 255, 255, 0.76);
  color: var(--green-mid);
  border-radius: 999px;
  padding: 0.38rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 600;
}

.chip:hover { background: var(--green-soft); border-color: var(--green-bright); }
.chip:active { transform: scale(0.97); }
.chip:focus-visible {
  outline: 2px solid var(--green-bright);
  outline-offset: 2px;
}

.chip.pulse {
  animation: chipPulse 0.45s var(--ease-out);
}

@keyframes chipPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
  100% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
}

.composer-foot,
.composer-hint {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.35rem;
  padding: 0 0.3rem;
  font-size: 0.62rem;
  color: var(--muted);
}

.composer-hint {
  margin: 0.2rem 0.25rem 0;
  text-align: center;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.2;
}

.composer-hint kbd {
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.06rem 0.28rem;
  border-radius: 6px;
  border: 1px solid rgba(22, 101, 52, 0.2);
  background: rgba(255, 255, 255, 0.85);
  color: var(--green-mid);
}

.welcome-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(22, 101, 52, 0.12);
  padding: 0.82rem 0.86rem 0.8rem;
  box-shadow: var(--shadow);
}

.welcome-card h3 {
  margin: 0 0 0.3rem;
  color: var(--green-deep);
  font-size: 1rem;
}

.welcome-card p,
.welcome-card li {
  color: var(--muted);
  line-height: 1.42;
  font-size: 0.82rem;
}

.welcome-card ul {
  margin: 0.75rem 0 0;
  padding-left: 1rem;
}

.typing-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(22, 101, 52, 0.12);
  box-shadow: var(--shadow);
}

.typing-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
  animation: dots 1.1s infinite ease-in-out;
}

.typing-pill span:nth-child(2) { animation-delay: 0.16s; }
.typing-pill span:nth-child(3) { animation-delay: 0.32s; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(6px);
}

.modal-backdrop.hidden { display: none; }
.modal-backdrop.open {
  display: flex;
  animation: backdropIn 0.25s ease both;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card,
.modal {
  max-width: 540px;
  width: 100%;
  border-radius: 24px;
  background: #fff;
  padding: 1.7rem;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}

.modal-card h3,
.modal h3 {
  margin: 0 0 0.65rem;
  color: var(--green-deep);
  font-size: 1.65rem;
}

.modal-card p,
.modal p {
  margin: 0 0 1.2rem;
  color: var(--muted);
  line-height: 1.5;
  font-size: 1rem;
}

footer {
  margin-top: 0.45rem;
  text-align: center;
  font-size: 0.6rem;
  color: var(--muted);
}

footer a { color: var(--green-mid); }

#toast-root {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  width: min(92vw, 380px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  animation: toastIn 0.42s var(--ease-out) both;
}

.toast.toast-out { animation: toastOut 0.28s ease-in forwards; }

.toast .toast-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.toast.success {
  background: linear-gradient(135deg, #ecfdf5, #f7fee7);
  color: #14532d;
  border-color: rgba(34, 197, 94, 0.35);
}

.toast.success .toast-icon { background: var(--green-soft); }

.toast.warn {
  background: linear-gradient(135deg, #fffbeb, #fef9c3);
  color: #713f12;
  border-color: rgba(202, 138, 4, 0.4);
}

.toast.warn .toast-icon { background: var(--gold-soft); }

.toast.info {
  background: #fff;
  color: var(--ink);
  border-color: rgba(22, 101, 52, 0.2);
}

.toast.info .toast-icon { background: var(--green-soft); color: var(--green-mid); }

.error-banner {
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: #fff7ed;
  border: 1px solid rgba(234, 88, 12, 0.16);
  color: #9a3412;
}

@media (max-width: 640px) {
  #app {
    padding: 0.55rem 0.72rem 0.82rem;
  }

  .top-bar,
  .toolbar,
  .composer-foot,
  .composer-hint {
    flex-wrap: wrap;
  }

  #chat-scroll {
    max-height: calc(100dvh - 255px);
  }

  .bubble-wrap {
    max-width: 92%;
  }

  .composer-row {
    padding: 0.45rem;
  }

  .send-btn {
    width: 42px;
    height: 42px;
  }

  .modal-card {
    padding: 1.2rem;
  }
}
