/* The chat widget, on the public site and on the signed-in pages: Home Income Search's concierge panel in SignalDesk's
   look. The two sides name their tokens differently (tokens.css for the signed-in pages, site.css for the public ones),
   so the widget reads its own from whichever the page has, and follows the page's theme. No inline styles: the CSP
   blocks them, so every look lives here. */

.sd-chat,
.sd-chat-launch {
  --chat-bg: var(--sd-surface, var(--sd-panel));
  --chat-ground: var(--sd-bg, var(--sd-alt));
  --chat-line: var(--sd-line, var(--sd-rule));
  --chat-line-strong: var(--sd-line-strong, var(--sd-rule2));
  --chat-text: var(--sd-text);
  --chat-muted: var(--sd-muted);
  --chat-accent: var(--sd-accent, var(--sd-fill));
  --chat-accent-ink: var(--sd-accent-ink, var(--sd-blue));
  --chat-on-accent: var(--sd-on-accent, #FFFFFF);
  --chat-danger: var(--sd-danger, var(--sd-red));
  --chat-font: var(--sd-font, var(--sd-body));
  --chat-display: var(--sd-font-display, var(--sd-display));
  --chat-radius: var(--sd-radius-control, 10px);
  font-family: var(--chat-font);
}

.sd-chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sd-chat__icon {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Room under the last line of the page, so the launcher never sits on the risk disclosure at the foot. */
body:has(.sd-chat-launch) :is(.sd-foot, .sd-auth__foot, .sd-app-foot) {
  padding-bottom: 96px;
}

.sd-chat-launch {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 38;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chat-accent);
  color: var(--chat-on-accent);
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--chat-accent) 55%, transparent);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sd-chat-launch:hover {
  transform: translateY(-2px);
}

.sd-chat-launch:focus-visible {
  outline: 2px solid var(--chat-accent-ink);
  outline-offset: 3px;
}

.sd-chat-launch .sd-chat__icon {
  width: 24px;
  height: 24px;
}

.sd-chat-launch[aria-expanded='true'] {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--chat-accent) 30%, transparent);
}

.sd-chat {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 38;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(600px, calc(100dvh - 120px));
  overflow: hidden;
  border: 1px solid var(--chat-line-strong);
  border-radius: 18px;
  background: var(--chat-bg);
  color: var(--chat-text);
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.65);
  font-size: 15px;
  line-height: 1.5;
}

.sd-chat[hidden] {
  display: none;
}

.sd-chat__head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--chat-line);
  background: var(--chat-ground);
}

.sd-chat__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--chat-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sd-chat__tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chat-accent) 18%, transparent);
  color: var(--chat-accent-ink);
  font-family: var(--chat-font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  vertical-align: 2px;
}

.sd-chat__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--chat-radius);
  background: none;
  color: var(--chat-muted);
  cursor: pointer;
  text-decoration: none;
}

.sd-chat__btn:hover {
  background: color-mix(in srgb, var(--chat-text) 8%, transparent);
  color: var(--chat-text);
}

.sd-chat__btn:focus-visible,
.sd-chat__chip:focus-visible,
.sd-chat__send:focus-visible,
.sd-chat__primary:focus-visible,
.sd-chat__plain:focus-visible {
  outline: 2px solid var(--chat-accent-ink);
  outline-offset: 1px;
}

.sd-chat__btn[hidden],
.sd-chat__send[hidden] {
  display: none;
}

.sd-chat__speaker .sd-chat__on {
  display: none;
}

.sd-chat__speaker.is-on {
  color: var(--chat-accent-ink);
}

.sd-chat__speaker.is-on .sd-chat__on {
  display: block;
}

.sd-chat__speaker.is-on .sd-chat__off {
  display: none;
}

.sd-chat__log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
}

.sd-chat__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  gap: 6px;
  padding: 8px 16px;
  text-align: center;
}

.sd-chat__empty-icon {
  width: 32px;
  height: 32px;
  color: var(--chat-accent-ink);
}

.sd-chat__empty-title {
  margin: 4px 0 0;
  font-family: var(--chat-display);
  font-size: 15px;
  font-weight: 700;
}

.sd-chat__empty-note {
  max-width: 28ch;
  margin: 0;
  color: var(--chat-muted);
  font-size: 13px;
}

.sd-chat__msg {
  max-width: 86%;
  margin: 0;
  padding: 9px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sd-chat__msg--you {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--chat-accent);
  color: var(--chat-on-accent);
}

.sd-chat__msg--bot {
  align-self: flex-start;
  border: 1px solid var(--chat-line);
  border-bottom-left-radius: 4px;
  background: var(--chat-ground);
}

.sd-chat__msg--failed {
  border-color: color-mix(in srgb, var(--chat-danger) 50%, transparent);
}

.sd-chat__msg a {
  color: var(--chat-accent-ink);
  text-decoration: underline;
}

.sd-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
}

.sd-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: sd-chat-typing 1.1s ease-in-out infinite;
}

.sd-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.sd-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes sd-chat-typing {
  0%,
  60%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.sd-chat__offer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
}

.sd-chat__starters {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.sd-chat__starters::-webkit-scrollbar {
  display: none;
}

.sd-chat__starters[hidden] {
  display: none;
}

.sd-chat__chip {
  flex: none;
  padding: 6px 11px;
  border: 1px solid var(--chat-line-strong);
  border-radius: 999px;
  background: none;
  color: var(--chat-muted);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.sd-chat__chip:hover {
  border-color: var(--chat-accent);
  color: var(--chat-accent-ink);
}

.sd-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 10px;
  border-top: 1px solid var(--chat-line);
}

.sd-chat__form[hidden],
.sd-chat__details[hidden] {
  display: none;
}

.sd-chat__input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 140px;
  padding: 9px 12px;
  border: 1px solid var(--chat-line-strong);
  border-radius: 12px;
  background: var(--chat-ground);
  color: var(--chat-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
}

.sd-chat__input::placeholder {
  color: var(--chat-muted);
  opacity: 1;
}

.sd-chat__input:focus {
  outline: none;
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent) 22%, transparent);
}

.sd-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--chat-accent);
  color: var(--chat-on-accent);
  cursor: pointer;
}

.sd-chat__send:disabled {
  opacity: 0.55;
  cursor: default;
}

.sd-chat__mic {
  width: 40px;
  height: 40px;
}

.sd-chat__mic .sd-chat__mic-done {
  display: none;
}

.sd-chat__mic.is-listening {
  background: color-mix(in srgb, var(--chat-danger) 16%, transparent);
  color: var(--chat-danger);
  animation: sd-chat-listening 1.4s ease-in-out infinite;
}

.sd-chat__mic.is-listening .sd-chat__mic-idle {
  display: none;
}

.sd-chat__mic.is-listening .sd-chat__mic-done {
  display: block;
}

.sd-chat__miccancel {
  width: 32px;
  height: 40px;
}

@keyframes sd-chat-listening {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--chat-danger) 40%, transparent);
  }

  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--chat-danger) 0%, transparent);
  }
}

.sd-chat__foot {
  margin: 0;
  padding: 0 14px 10px;
  color: var(--chat-muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.sd-chat__details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 70%;
  overflow-y: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--chat-line);
  background: var(--chat-ground);
}

.sd-chat__details-title {
  margin: 0;
  font-family: var(--chat-display);
  font-size: 14px;
  font-weight: 700;
}

.sd-chat__details-note {
  margin: 0;
  color: var(--chat-muted);
  font-size: 13px;
}

.sd-chat__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sd-chat__field[hidden],
.sd-chat__consent[hidden] {
  display: none;
}

.sd-chat__field label {
  font-size: 13px;
  font-weight: 600;
}

.sd-chat__optional {
  color: var(--chat-muted);
  font-weight: 400;
}

.sd-chat__field input,
.sd-chat__field textarea {
  padding: 9px 11px;
  border: 1px solid var(--chat-line-strong);
  border-radius: var(--chat-radius);
  background: var(--chat-bg);
  color: var(--chat-text);
  font: inherit;
  font-size: 15px;
}

.sd-chat__field input:focus,
.sd-chat__field textarea:focus {
  outline: none;
  border-color: var(--chat-accent);
}

.sd-chat__field [aria-invalid='true'] {
  border-color: var(--chat-danger);
}

.sd-chat__error,
.sd-chat__alert {
  margin: 0;
  color: var(--chat-danger);
  font-size: 12px;
}

.sd-chat__error[hidden],
.sd-chat__alert[hidden] {
  display: none;
}

.sd-chat__consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.sd-chat__consent input {
  margin-top: 3px;
  flex: none;
}

.sd-chat__consent label {
  color: var(--chat-muted);
  font-size: 11px;
  line-height: 1.45;
}

.sd-chat__consent input:disabled + label {
  opacity: 0.6;
}

.sd-chat__consent a {
  color: var(--chat-accent-ink);
}

.sd-chat .sd-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.sd-chat__details-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sd-chat__primary,
.sd-chat__plain {
  min-height: 36px;
  padding: 7px 14px;
  border-radius: var(--chat-radius);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.sd-chat__primary {
  border: 0;
  background: var(--chat-accent);
  color: var(--chat-on-accent);
}

.sd-chat__primary:disabled {
  opacity: 0.55;
}

.sd-chat__plain {
  border: 1px solid var(--chat-line-strong);
  background: none;
  color: var(--chat-text);
}

/* A phone: the panel takes the screen above the button's corner, and the button tucks in. */
@media (max-width: 639px) {
  .sd-chat-launch {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }

  .sd-chat {
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-width: none;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .sd-chat:not([hidden]) ~ .sd-chat-launch,
  .sd-chat-launch[aria-expanded='true'] {
    display: none;
  }

  .sd-chat__head {
    padding-top: env(safe-area-inset-top);
  }

  .sd-chat__foot {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .sd-chat-launch,
  .sd-chat-launch:hover {
    transition: none;
    transform: none;
  }

  .sd-chat__typing span,
  .sd-chat__mic.is-listening {
    animation: none;
  }

  .sd-chat__typing span {
    opacity: 0.7;
  }
}
