/* Visitor assistant (public/assets/assistant.js). Scoped under .fma so the site's global
   button, form, and label styles do not leak in. */
.fma {
  --fma-ink: #0b1020;
  --fma-navy: #10182e;
  --fma-purple: #3c2468;
  --fma-lilac: #d9ccff;
  --fma-muted: #5c6178;
  --fma-line: #ddd8ea;
  --fma-raised: #fbfbfe;
  --fma-soft: #f3eeff;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  font: 400 1rem/1.5 "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--fma-ink);
}
.fma [hidden] { display: none !important; }
/* :where() keeps this reset at class-level weight, so the .fma-* button classes below win. */
.fma :where(button) {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  font: inherit;
}
.fma button:hover { transform: none; }
.fma button:focus-visible, .fma a:focus-visible { outline: 2px solid var(--fma-purple); outline-offset: 2px; }
.fma button:disabled { opacity: 0.55; cursor: progress; }

.fma-launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 16px;
  border-radius: 999px;
  background: var(--fma-navy);
  color: #fff;
  font-weight: 600 !important;
  box-shadow: 0 12px 30px rgba(7, 11, 20, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: transform 0.2s ease, background 0.2s ease;
}
.fma .fma-launch:hover { transform: translateY(-2px); background: #1b2547; }
.fma-launch-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--fma-lilac);
  box-shadow: 0 0 0 4px rgba(217, 204, 255, 0.22);
}
.fma.is-open .fma-launch { display: none; }

.fma-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(390px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--fma-raised);
  border: 1px solid var(--fma-line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(7, 11, 20, 0.28);
  overflow: hidden;
}
.fma-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px 18px;
  background: linear-gradient(120deg, rgba(26, 63, 134, 0.45), transparent 60%), var(--fma-navy);
  color: #f7f6fb;
}
.fma-title { margin: 0; font: 600 1.12rem/1.3 "Source Serif 4", Georgia, serif; }
.fma-sub { margin: 2px 0 0; font-size: 0.85rem; color: #c9cde0; }
.fma-close {
  display: inline-grid !important;
  place-items: center;
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  font-size: 1.4rem !important; line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.fma-close:hover { background: rgba(255, 255, 255, 0.2); }

.fma-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.fma-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.98rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.fma-msg p { margin: 0 0 6px; }
.fma-msg p:last-child { margin-bottom: 0; }
.fma-msg a { color: var(--fma-purple); font-weight: 600; text-underline-offset: 2px; }
.fma-a { align-self: flex-start; background: #fff; border: 1px solid var(--fma-line); border-bottom-left-radius: 6px; }
.fma-u { align-self: flex-end; background: var(--fma-purple); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.fma-note { align-self: stretch; max-width: none; background: #e3f3ea; border: 1px solid #bfe3cd; color: #1f6b43; font-weight: 600; }
.fma-typing { min-height: 40px; min-width: 64px; }
.fma-typing::after {
  content: "";
  display: inline-block;
  width: 36px; height: 10px;
  background:
    radial-gradient(circle 4px, var(--fma-muted) 98%, transparent) 0 50% / 12px 10px no-repeat,
    radial-gradient(circle 4px, var(--fma-muted) 98%, transparent) 12px 50% / 12px 10px no-repeat,
    radial-gradient(circle 4px, var(--fma-muted) 98%, transparent) 24px 50% / 12px 10px no-repeat;
  animation: fma-pulse 1.1s ease-in-out infinite;
}
@keyframes fma-pulse { 50% { opacity: 0.35; } }

.fma-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.fma-chip {
  padding: 7px 12px;
  border: 1px solid #cdbff2;
  border-radius: 999px;
  background: var(--fma-soft);
  color: var(--fma-purple);
  font-size: 0.92rem !important;
  font-weight: 600 !important;
}
.fma-chip:hover { background: #e9e0ff; }

.fma-composer {
  display: flex !important;
  align-items: flex-end;
  gap: 8px;
  max-width: none !important;
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--fma-line);
  background: #fff;
}
.fma .fma-input {
  flex: 1;
  min-height: 42px !important;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--fma-line);
  border-radius: 14px;
  background: var(--fma-raised);
  font: inherit;
  font-size: 1rem;
  resize: none;
  color: var(--fma-ink);
}
.fma-send {
  display: inline-grid !important;
  place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  background: var(--fma-purple);
  color: #fff;
  font-size: 1.2rem !important;
  font-weight: 700 !important;
}
.fma-send:hover { background: #2e1a52; }

.fma-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px 12px;
  background: #fff;
}
.fma-small { margin: 0; font-size: 0.8rem; line-height: 1.4; color: var(--fma-muted); }
.fma-handoff-btn {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--fma-purple);
  color: var(--fma-purple);
  font-size: 0.86rem !important;
  font-weight: 600 !important;
  white-space: nowrap;
}
.fma-handoff-btn:hover { background: var(--fma-purple); color: #fff; }

.fma-handoff { padding: 14px 16px 16px; border-top: 1px solid var(--fma-line); background: #fff; }
.fma .fma-form { display: grid; gap: 10px; max-width: none; margin: 0; }
.fma-form-title { margin: 0; font-weight: 600; font-size: 0.95rem; }
.fma .fma-form label { display: grid; gap: 4px; font-size: 0.88rem; color: var(--fma-muted); }
.fma .fma-form input, .fma .fma-form textarea {
  width: 100%;
  min-height: 0;
  padding: 9px 11px;
  border: 1px solid var(--fma-line);
  border-radius: 10px;
  background: var(--fma-raised);
  font: inherit;
  font-size: 0.98rem;
  color: var(--fma-ink);
}
.fma .fma-form textarea { resize: vertical; min-height: 56px; }
.fma .fma-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fma-row { display: flex; gap: 8px; align-items: center; }
.fma-primary { padding: 10px 18px; border-radius: 999px; background: var(--fma-purple); color: #fff; font-weight: 600 !important; }
.fma-primary:hover { background: #2e1a52; }
.fma-ghost { padding: 10px 14px; border-radius: 999px; color: var(--fma-muted); font-weight: 600 !important; }
.fma-ghost:hover { background: #f0edf7; }

@media (max-width: 560px) {
  .fma { right: 12px; bottom: 12px; }
  .fma-launch-text { font-size: 0.95rem; }
  .fma.is-open { inset: auto 0 0 0; }
  .fma-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: min(86vh, 640px);
    height: min(86dvh, 640px);
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }
  .fma-foot { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .fma-launch { transition: none; }
  .fma-typing::after { animation: none; }
}
@media print { .fma { display: none; } }
