/* Avello Labs chat assistant. Uses the color tokens from site.css. */
.chat-launcher { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: inline-flex; align-items: center; gap: .5rem;
                 min-height: 52px; padding: 0 1.15rem 0 1rem; border: 0; border-radius: 999px; cursor: pointer;
                 background: var(--grad-btn); color: var(--btn-ink); font: 600 .95rem/1 var(--font);
                 box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 12px 30px -10px color-mix(in srgb, var(--blue) 70%, transparent),
                             0 0 0 1px color-mix(in srgb, var(--cyan) 35%, transparent); }
.chat-launcher svg { width: 22px; height: 22px; }
.chat-launcher:hover { box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 14px 34px -10px color-mix(in srgb, var(--blue) 85%, transparent),
                                   0 0 0 2px color-mix(in srgb, var(--cyan) 55%, transparent); }
.chat-launcher:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.chat-panel { position: fixed; right: 1rem; bottom: 5rem; z-index: 61; width: min(24rem, calc(100vw - 2rem));
              height: min(36rem, calc(100dvh - 7rem)); display: flex; flex-direction: column; overflow: hidden;
              border: 1px solid var(--line-bright); border-radius: 16px; background: var(--bg-2); color: var(--text);
              box-shadow: 0 30px 60px -20px rgb(0 0 0 / .7), 0 0 0 1px color-mix(in srgb, var(--cyan) 12%, transparent); }
.chat-panel[hidden] { display: none; }
.chat-panel::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--grad); }

.chat-head { display: flex; align-items: center; gap: .25rem; padding: .85rem .6rem .75rem 1rem; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -.01em; max-width: none; }
.chat-title p { margin: .1rem 0 0; color: var(--muted); font-size: .78rem; }
.chat-icon-btn { width: 40px; height: 40px; display: grid; place-items: center; flex: none; border: 1px solid transparent; border-radius: 10px;
                 background: none; color: var(--muted); cursor: pointer; }
.chat-icon-btn:hover { color: var(--text); border-color: var(--line-bright); }
.chat-icon-btn svg { width: 18px; height: 18px; }

.chat-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.chat-msg { max-width: 88%; padding: .65rem .85rem; border-radius: 14px; font-size: .94rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg.user { align-self: flex-end; background: color-mix(in srgb, var(--blue-2) 26%, var(--panel)); border: 1px solid color-mix(in srgb, var(--blue-2) 45%, transparent);
                 border-bottom-right-radius: 4px; }
.chat-msg.notice { align-self: center; max-width: 95%; background: none; color: var(--muted); font-size: .84rem; text-align: center; padding: .25rem .5rem; }
.chat-msg.failed { opacity: .7; }
.chat-failed { color: var(--error); font-size: .8rem; }
.chat-msg a { color: var(--text); text-decoration: underline; text-decoration-color: var(--cyan); text-underline-offset: 3px; }

.chat-typing { display: inline-flex; gap: .3rem; align-items: center; padding: .8rem .9rem; }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .chat-typing i { animation: chat-dot 1.2s ease-in-out infinite; }
  .chat-typing i:nth-child(3) { animation-delay: .15s; }
  .chat-typing i:nth-child(4) { animation-delay: .3s; }
  @keyframes chat-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
  .chat-panel:not([hidden]) { animation: chat-in .18s ease-out; }
  @keyframes chat-in { from { opacity: 0; transform: translateY(8px); } }
}

.chat-lead { align-self: stretch; padding: .9rem 1rem; border: 1px solid color-mix(in srgb, var(--cyan) 40%, var(--line)); border-radius: 12px;
             background: linear-gradient(135deg, color-mix(in srgb, var(--blue-2) 14%, var(--panel)), var(--panel)); }
.chat-lead-title { margin: 0 0 .5rem; font-weight: 600; font-size: .92rem; }
.chat-lead dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem; margin: 0; font-size: .88rem; }
.chat-lead dt { color: var(--muted); }
.chat-lead dd { margin: 0; overflow-wrap: anywhere; }
.chat-lead dd.chat-empty { color: var(--muted); font-style: italic; }
.chat-lead-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.chat-lead-send { min-height: 40px; padding: 0 1rem; border: 0; border-radius: 9px; background: var(--grad-btn); color: var(--btn-ink);
                  font: 600 .9rem/1 var(--font); cursor: pointer; }
.chat-lead-send[disabled] { opacity: .65; cursor: progress; }
.chat-lead-edit { min-height: 40px; padding: 0 .9rem; border: 1px solid var(--line-bright); border-radius: 9px; background: none;
                  color: var(--text); font: 500 .9rem/1 var(--font); cursor: pointer; }
.chat-lead-edit:hover { border-color: var(--blue); }

.chat-form { display: flex; align-items: flex-end; gap: .5rem; padding: .75rem .75rem 0; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; padding: .65rem .8rem; border: 1px solid var(--line-bright);
                      border-radius: 12px; background: var(--bg); color: var(--text); font: 1rem/1.4 var(--font); }
.chat-form textarea::placeholder { color: #66729a; }
.chat-form textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 22%, transparent); }
.chat-form textarea:disabled { opacity: .6; }
.chat-send { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 12px; cursor: pointer;
             background: var(--grad-btn); color: var(--btn-ink); }
.chat-send svg { width: 18px; height: 18px; }
.chat-send:disabled { opacity: .45; cursor: default; }
.chat-count { margin: .35rem .9rem 0; min-height: 0; color: var(--muted); font-size: .76rem; text-align: right; }
.chat-count:empty { display: none; }
.chat-note { margin: 0; padding: .5rem .9rem .75rem; color: var(--muted); font-size: .76rem; }
.chat-note a { color: var(--text); text-decoration: underline; text-decoration-color: var(--cyan); text-underline-offset: 2px; }
.chat .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phones (under 640px): the chat is a fixed, full-screen sheet. chat.js locks the page behind it and sizes
   it to the visual viewport, so it shrinks above the iOS keyboard instead of sliding under it. Only the
   message list scrolls. Safe-area insets keep it clear of the notch and home bar. */
@media (max-width: 39.99rem) {
  .chat-launcher-label { display: none; }
  .chat-launcher { width: 56px; height: 56px; padding: 0; justify-content: center;
                   right: calc(1rem + env(safe-area-inset-right)); bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .chat.is-open .chat-launcher { display: none; }
  .chat-panel { top: var(--chat-vv-top, 0px); right: 0; bottom: auto; left: 0; width: 100%; height: var(--chat-vv-height, 100dvh);
                border: 0; border-radius: 0; padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); overscroll-behavior: none; }
  .chat-panel:not([hidden]) { animation: none; }
  .chat-head { flex: none; padding-top: calc(.75rem + env(safe-area-inset-top)); }
  .chat-log { flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
  .chat-form, .chat-count { flex: none; }
  .chat-note { flex: none; padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  /* With the keyboard up, it covers the home bar, so that space isn't needed. */
  .chat.kb-open .chat-note { padding-bottom: .5rem; }
  html.chat-locked { overflow: hidden; overscroll-behavior: none; }
}
@media print { .chat { display: none; } }
