/* Valure Assistant chat (adapted from the Ducki chat kit).
   Colours are set here; the font comes from the page (Rethink Sans). */
.chat-launcher, .chat-panel {
  --chat-accent: #0207ff;
  --chat-accent-hover: #0005d1;
  --chat-on-accent: #ffffff;
  --chat-bg: #ffffff;
  --chat-ink: #0a0b12;
  --chat-bubble: #f4f4f5;
  --chat-muted: #5f6068;
  --chat-line: rgba(0, 0, 0, 0.06);
  --chat-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --chat-ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: inherit; /* uses the page's font */
  box-sizing: border-box;
}
.chat-panel *, .chat-panel *::before, .chat-panel *::after { box-sizing: border-box; }

/* The round button left behind when the chat is minimised */
.chat-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483000;
  display: block; width: 60px; height: 60px; margin: 0; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  opacity: 0; visibility: hidden; transform: scale(0.8);
  transition: transform 0.4s var(--chat-ease-soft), opacity 0.3s var(--chat-ease-soft), visibility 0s 0.4s;
}
.chat-launcher img { display: block; width: 100%; height: 100%; border-radius: 50%; }
.chat-launcher.is-visible { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.chat-launcher.is-visible:hover { transform: scale(1.06); }
.chat-launcher:focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 3px; }
@media (max-width: 720px) { .chat-launcher { right: 16px; bottom: 16px; } }

/* ---- The chat panel ---- */
.chat-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483001;
  display: flex; flex-direction: column;
  width: min(400px, calc(100vw - 48px)); height: min(640px, calc(100dvh - 48px));
  background: var(--chat-bg); color: var(--chat-ink); border: 1px solid var(--chat-line); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  overflow: hidden; transform-origin: 100% 100%;
  opacity: 0; visibility: hidden; transform: translateY(40px) scale(0.96);
  transition: transform 0.6s var(--chat-ease-soft), opacity 0.4s var(--chat-ease-soft), visibility 0s 0.6s;
}
.chat-panel.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.chat-panel.is-expanded { width: min(640px, calc(100vw - 48px)); height: calc(100dvh - 48px); }
.chat-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 20px; background: var(--chat-accent); color: var(--chat-on-accent); }
.chat-logo {
  flex: none; width: 24px; height: 20px; background: currentColor;
  -webkit-mask: url(../assets/mark.svg) center / contain no-repeat; mask: url(../assets/mark.svg) center / contain no-repeat;
}
.chat-title { font-size: 18px; font-weight: 600; line-height: 1.2; }
.chat-body, .chat-compose { transition: opacity 0.5s var(--chat-ease-soft) 0.15s; }
.chat-panel.is-loading :is(.chat-body, .chat-compose) { opacity: 0; visibility: hidden; transition: none; }
.chat-head-button {
  display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
  transition: background-color 0.2s var(--chat-ease);
}
.chat-head-button:hover { background: rgba(255, 255, 255, 0.16); }
.chat-expand { margin-left: auto; }
.chat-head-button + .chat-head-button { margin-left: -8px; }
.chat-head-button { flex: none; }
.chat-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 20px 16px; overflow-y: auto; overscroll-behavior: contain; }
.chat-loader { position: absolute; inset: 0; display: grid; place-items: center; color: var(--chat-accent); pointer-events: none; transition: opacity 0.4s var(--chat-ease-soft), transform 0.4s var(--chat-ease-soft); }
.chat-loader.is-done { opacity: 0; transform: scale(0.8); }
.chat-loader svg { animation: chat-spin 1.3s cubic-bezier(0.4, 0.12, 0.6, 0.88) infinite; }
.chat-loader circle { animation: chat-arc 1.3s cubic-bezier(0.4, 0.12, 0.6, 0.88) infinite; }
@keyframes chat-spin { to { transform: rotate(360deg); } }
@keyframes chat-arc {
  0% { stroke-dasharray: 4 159; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 100 63; stroke-dashoffset: -30; }
  100% { stroke-dasharray: 4 159; stroke-dashoffset: -163; }
}
.chat-group { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px 8px; padding-right: 20px; }
.chat-avatar { grid-column: 1; grid-row: 1; display: block; border-radius: 50%; animation: chat-msg-in 0.45s var(--chat-ease-soft) both; }
.chat-panel :focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 2px; }
.chat-head :focus-visible { outline-color: var(--chat-on-accent); }
.chat-msg {
  padding: 12px 16px; border-radius: 22px; font-size: 15px; line-height: 1.45;
  animation: chat-msg-in 0.45s var(--chat-ease-soft) both;
}
.chat-msg.from-assistant { grid-column: 2; justify-self: start; white-space: pre-line; background: var(--chat-bubble); }
.chat-msg.from-me { align-self: flex-end; max-width: 85%; background: var(--chat-accent); color: var(--chat-on-accent); }
.chat-meta { align-self: flex-end; margin-top: -6px; font-size: 12px; color: var(--chat-muted); }
.chat-msg.from-me a { text-decoration-color: currentColor; }
.chat-msg a { color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--chat-accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.chat-msg .chat-linkbox {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 6px; vertical-align: -5px;
  border-radius: 7px; background: var(--chat-bg); border: 1px solid rgba(0, 0, 0, 0.1); text-decoration: none;
  transition: background-color 0.2s var(--chat-ease), border-color 0.2s var(--chat-ease);
}
.chat-msg .chat-linkbox:hover { background: var(--chat-accent); border-color: var(--chat-accent); }

/* The assistant is thinking: the big star hops between three spots */
.chat-thinking { display: flex; align-items: center; gap: 12px; min-height: 28px; padding-left: 4px; }
.chat-sparkle { position: relative; flex: none; width: 20px; height: 20px; }
.chat-sparkle svg {
  position: absolute; width: 12px; height: 12px; fill: var(--chat-accent);
  animation: chat-sparkle 1.25s ease-in-out infinite;
}
.chat-sparkle svg:nth-child(1) { top: 0; left: 8px; }
.chat-sparkle svg:nth-child(2) { top: 9px; left: 8px; animation-delay: -0.833s; }
.chat-sparkle svg:nth-child(3) { top: 4px; left: 0; animation-delay: -0.417s; }
@keyframes chat-sparkle { 0%, 24% { transform: scale(1); } 34%, 90% { transform: scale(0.42); } 100% { transform: scale(1); } }
.chat-thinking-text { font-size: 13px; color: var(--chat-muted); }
.chat-thinking-text span { animation: chat-letter 0.4s ease-out both; }
@keyframes chat-letter { from { color: var(--chat-ink); } }

/* The agent is typing: three dots that rise one after another */
.chat-typing { display: flex; align-items: center; gap: 5px; height: 45px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--chat-muted); animation: chat-typing 1.2s ease-in-out infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing { 0%, 60%, 100% { opacity: 0.4; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; } }
.chat-edited { display: block; margin-top: 2px; font-size: 12px; color: var(--chat-muted); }

/* Leave a message: shown in the conversation when no agent is available */
.chat-form { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid #e6e6e6; border-radius: 16px; }
.chat-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.chat-field input, .chat-field textarea {
  display: block; width: 100%; margin: 0; padding: 10px 12px; border: 1px solid #a9a9ae; border-radius: 6px; resize: vertical;
  font: inherit; font-size: 16px; font-weight: 400; line-height: 1.4; color: var(--chat-ink); background: var(--chat-bg); outline: none;
}
.chat-field input:focus, .chat-field textarea:focus { border-color: var(--chat-accent); box-shadow: 0 0 0 3px rgba(2, 7, 255, 0.16); }
.chat-form .chat-button:disabled { opacity: 0.6; cursor: default; }
.chat-form-error { margin: 0; font-size: 14px; color: #b3261e; }
.chat-form-note { margin: 0; font-size: 13px; line-height: 1.4; color: var(--chat-muted); }
.chat-form-note a { color: inherit; text-decoration: underline; }

/* Ending the chat: sheets rise over the dimmed conversation */
.chat-ended { align-self: center; margin: 8px 0; padding: 6px 14px; border-radius: 999px; font-size: 14px; background: var(--chat-bubble); }
.chat-scrim { position: absolute; inset: 0; z-index: 3; background: rgba(0, 0, 0, 0.32); animation: chat-fade 0.25s ease-out both; }
.chat-scrim[hidden] { display: none; }
.chat-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; flex-direction: column; gap: 16px; max-height: 100%; padding: 24px 20px 20px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--chat-bg); border-radius: 24px 24px 0 0;
  animation: chat-sheet-in 0.3s var(--chat-ease-soft) both;
}
.chat-sheet[hidden] { display: none; }
.chat-sheet.is-full { top: 0; border-radius: 16px; animation: none; }
.chat-sheet-title { margin: 0; font-size: 19px; font-weight: 500; line-height: 1.35; outline: none; }
.chat-sheet-text { margin: 0; font-size: 16px; line-height: 1.45; }
.chat-sheet-thanks { padding: 16px 0; text-align: center; }
.chat-transcript { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.chat-download {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; padding: 0; border: 0; background: none;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--chat-accent); cursor: pointer;
}
.chat-download:hover { text-decoration: underline; text-underline-offset: 3px; }
.chat-sheet-actions { display: flex; flex-direction: column; gap: 4px; }
.chat-sheet.is-full .chat-sheet-actions { margin-top: auto; }
.chat-button {
  min-height: 48px; margin: 0; padding: 0 16px; border: 0; border-radius: 8px;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--chat-on-accent); background: var(--chat-accent); cursor: pointer;
  transition: background-color 0.2s var(--chat-ease);
}
.chat-button:hover { background: var(--chat-accent-hover); }
.chat-button--pill { border-radius: 999px; }
.chat-text-button { min-height: 44px; margin: 0; padding: 0; border: 0; background: none; font: inherit; font-size: 16px; font-weight: 700; color: var(--chat-accent); cursor: pointer; }
.chat-text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.chat-faces { display: flex; justify-content: space-between; gap: 8px; }
.chat-face {
  display: grid; place-items: center; width: 52px; height: 52px; margin: 0; padding: 0; border: 1px solid transparent; border-radius: 12px;
  color: #6b6b70; background: #f7f7f8; cursor: pointer; transition: color 0.2s var(--chat-ease), background-color 0.2s var(--chat-ease), border-color 0.2s var(--chat-ease);
}
.chat-face svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chat-face-eye { fill: currentColor; stroke: none; }
.chat-face:hover { background: #eeeef0; }
.chat-face[aria-pressed="true"] { background: var(--chat-bg); border-color: rgba(0, 0, 0, 0.2); }
.chat-face--good[aria-pressed="true"] { color: #2e7d1e; }
.chat-face--mid[aria-pressed="true"] { color: #9a6200; }
.chat-face--bad[aria-pressed="true"] { color: #c62828; }
.chat-sheet.is-full .chat-faces:has([aria-pressed="true"]) .chat-face:not([aria-pressed="true"]) { background: none; }
.chat-followup { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.chat-followup:empty { display: none; }
.chat-followup-title { margin: 0; font-size: 16px; font-weight: 700; }
.chat-reasons { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.chat-reason {
  min-height: 44px; margin: 0; padding: 0 14px; border: 1px solid #a9a9ae; border-radius: 6px;
  font: inherit; font-size: 15px; color: var(--chat-ink); background: var(--chat-bg); cursor: pointer;
  transition: color 0.2s var(--chat-ease), background-color 0.2s var(--chat-ease), border-color 0.2s var(--chat-ease);
}
.chat-reason:hover { border-color: var(--chat-accent); }
.chat-reason[aria-pressed="true"] { color: var(--chat-accent); background: #eef0ff; border-color: var(--chat-accent); }
.chat-more { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; padding: 0; border: 0; background: none; font: inherit; font-size: 16px; font-weight: 700; color: var(--chat-ink); cursor: pointer; }
.chat-more svg { color: var(--chat-accent); transition: transform 0.2s var(--chat-ease); }
.chat-more[aria-expanded="true"] svg { transform: rotate(45deg); }
.chat-comment {
  display: block; width: 100%; margin: 0; padding: 12px 14px; border: 1px solid #a9a9ae; border-radius: 6px; resize: vertical;
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--chat-ink); background: var(--chat-bg); outline: none;
}
.chat-comment[hidden] { display: none; }
.chat-comment:focus { border-color: var(--chat-accent); box-shadow: 0 0 0 3px rgba(2, 7, 255, 0.16); }
@keyframes chat-fade { from { opacity: 0; } }
@keyframes chat-sheet-in { from { transform: translateY(100%); } }
@keyframes chat-msg-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.chat-compose { flex: none; display: flex; margin: 0; padding: 8px 16px 20px; }
.chat-compose input {
  flex: 1; min-width: 0; height: 48px; margin: 0; padding: 0 20px; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 999px;
  font: inherit; font-size: 16px; color: var(--chat-ink); background: var(--chat-bubble); outline: none;
  transition: border-color 0.2s var(--chat-ease);
}
.chat-compose input:focus { border-color: var(--chat-accent); box-shadow: 0 0 0 3px rgba(2, 7, 255, 0.16); }
.chat-compose input:focus-visible { outline: none; }
.chat-compose :disabled { opacity: 0.6; cursor: default; }
@media (max-width: 720px) {
  .chat-panel { right: 16px; bottom: 16px; width: calc(100vw - 32px); height: min(640px, calc(100dvh - 32px)); }
  .chat-expand { display: none; }
  .chat-minimise { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel { transform: none; }
  .chat-sparkle svg { animation: none; }
  .chat-sparkle svg:nth-child(n + 2) { transform: scale(0.42); }
  .chat-sheet, .chat-scrim { animation: none; }
}
