.chat {
  position: fixed;
  inset-inline-end: 1rem;
  bottom: 1rem;
  z-index: 60;
  font-size: 0.95rem;
}

.chat-toggle {
  display: grid;
  place-items: center;
  width: 3.75rem;
  height: 3.75rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: var(--accent, #f9ab05);
  box-shadow: 0 4px 0 #b97c00, 0 10px 24px rgb(4 8 18 / 0.4);
  cursor: pointer;
  transition: transform 160ms ease-out;
}

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

.chat-toggle:focus-visible {
  outline: 3px solid var(--hp-on-orange);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--hp-ink-light);
}

.chat-close:focus-visible,
.chat-send:focus-visible,
.chat-input:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.chat-toggle-fox {
  width: 3.3rem;
  height: auto;
  margin-top: 0.9rem;
}

.chat.is-open .chat-toggle {
  display: none;
}

.chat-toggle {
  position: relative;
}

.chat-dot {
  position: absolute;
  inset-block-start: 9px;
  inset-inline-end: 9px;
  inline-size: 0.8rem;
  block-size: 0.8rem;
  border: 2px solid #19243b;
  border-radius: 50%;
  background: var(--success, #53f901);
}

.chat-bubble {
  position: absolute;
  inset-inline-end: calc(100% + 0.9rem);
  inset-block-end: 0.85rem;
  inline-size: max-content;
  max-inline-size: min(14rem, calc(100vw - 7rem));
  padding-block: 0.7rem;
  padding-inline: 1rem 1.9rem;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 26px rgb(0 0 0 / 0.35);
  color: #19243b;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px) scale(0.96);
  transition:
    opacity 220ms var(--ease-out, ease-out),
    transform 220ms var(--ease-out, ease-out),
    visibility 0s linear 220ms;
}

.chat-bubble.is-on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition-delay: 0s;
}

.chat.is-open .chat-bubble {
  display: none;
}

.chat-bubble::after {
  content: "";
  position: absolute;
  inset-inline-end: -6px;
  inset-block-end: 1rem;
  inline-size: 14px;
  block-size: 14px;
  border-radius: 2px;
  background: #fff;
  rotate: 45deg;
}

.chat-bubble-text {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
}

.chat-bubble-close {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  inline-size: 2rem;
  block-size: 2rem;
  padding: 0;
  border: 0;
  background: none;
  color: #5b6577;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.chat-bubble-text:focus-visible,
.chat-bubble-close:focus-visible {
  outline: 3px solid #19243b;
  outline-offset: 2px;
  border-radius: 6px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(23rem, calc(100vw - 2rem));
  max-height: min(40rem, calc(100dvh - 6rem));
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 16px;
  background: linear-gradient(180deg, #1d2a47 0%, #131c2e 100%);
  box-shadow: 0 18px 44px rgb(4 8 18 / 0.55);
  color: #fff;
}

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

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--accent, #f9ab05);
  color: #19243b;
}

.chat-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #19243b;
}

.chat-panel .chat-title {
  text-wrap: balance;
  hyphens: auto;
  hyphenate-limit-chars: 14 6 6;
}

.chat-close {
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #19243b;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.chat .chat-log {
  flex: 1;
  margin: 0;
  padding: 1rem 1rem calc(1rem + 3px);
  overflow-y: auto;
  list-style: none;
}

.chat-msg {
  width: fit-content;
  max-width: 88%;
  hyphens: manual;
  overflow-wrap: break-word;
  margin-bottom: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  line-height: 1.4;
}

.chat-msg:last-child {
  margin-bottom: 0;
}

.chat-msg p {
  margin: 0;
  hyphens: manual;
}

.chat-msg p + p {
  margin-top: 0.45rem;
}

.chat-msg--bot {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  column-gap: 0.5rem;
  align-items: end;
  max-width: 94%;
  padding: 0;
  background: none;
}

.chat-msg--bot::before {
  content: "";
  grid-column: 1;
  grid-row: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #2d3854 url("../img/fuperino-320.webp") 50% 6% / 140% auto no-repeat;
  box-shadow: 0 0 0 2px var(--accent, #f9ab05);
}

.chat-say {
  grid-column: 2;
  width: fit-content;
  max-width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  border-end-start-radius: 4px;
  background: #fff;
  box-shadow: 0 3px 0 #b4bfcf;
  color: #19243b;
}

.chat-msg--bot + .chat-msg--user {
  margin-top: calc(1rem + 3px);
}

.chat-msg--user + .chat-msg--bot {
  margin-top: 1rem;
}

.chat-msg--bot + .chat-msg--bot {
  margin-top: calc(0.5rem + 3px);
}

.chat-msg--bot:has(+ .chat-msg--bot)::before {
  visibility: hidden;
}

.chat-say .chat-lead {
  font-weight: 600;
}

.chat-msg--bot .chat-chips-title,
.chat-msg--bot .chat-chips {
  grid-column: 2;
}

.chat-chips-title {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: #c5ccda;
}

.chat-msg--intro {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  width: 100%;
  max-width: 100%;
}

.chat-msg--intro::before {
  content: none;
}

.chat-intro-fox {
  display: block;
  width: 10rem;
  translate: -3.5% 0;
  height: auto;
  filter: drop-shadow(0 12px 18px rgb(0 0 0 / 0.45));
}

.chat-msg--intro .chat-say {
  position: relative;
  grid-column: 1;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  box-shadow: none;
  font-weight: 600;
  text-align: center;
}

.chat-msg--intro .chat-say::before {
  content: "";
  position: absolute;
  top: -0.5rem;
  inset-inline-start: calc(50% - 0.6rem);
  border-inline: 0.6rem solid transparent;
  border-bottom: 0.6rem solid #fff;
}

.chat-msg--intro .chat-chips-title {
  grid-column: 1;
  justify-self: start;
  margin-top: 1rem;
}

.chat-msg--intro .chat-chips {
  grid-column: 1;
  justify-self: stretch;
}

.chat-msg--user {
  margin-inline-start: auto;
  background: var(--accent, #f9ab05);
  color: #19243b;
  border-end-end-radius: 4px;
}

.chat-msg a {
  color: var(--accent, #f9ab05);
}

.chat-say a {
  color: #19243b;
  text-decoration-color: var(--accent, #f9ab05);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
  font-weight: 600;
}

.chat-say .chat-note,
.chat-say .chat-note a {
  color: #4a556b;
}

.chat-say .chat-note {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid #dfe5ee;
}

.chat-msg.is-waiting {
  opacity: 0.75;
}

.chat-note {
  font-size: 0.8rem;
  color: #c5ccda;
}

.chat-form {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1rem 0;
  border-top: 1px solid rgb(255 255 255 / 0.08);
}

.chat-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.chat-input {
  flex: 1;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  resize: none;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 10px;
  background: #0e1626;
  color: #fff;
  font: inherit;
  font-size: 1rem;
}

.chat-send {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding-inline: 0.9rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent, #f9ab05);
  box-shadow: 0 3px 0 #b97c00;
  color: #19243b;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
}

.chat-send:disabled {
  opacity: 0.6;
  cursor: progress;
}

.chat-privacy,
.chat-contact {
  margin: 0;
  padding: calc(0.75rem + 3px) 1rem 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #c5ccda;
}

.chat-contact {
  padding: 0.5rem 1rem 1rem;
}

.chat-contact a {
  color: #c5ccda;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: calc(0.5rem + 3px) 0.5rem;
  margin-top: 0.5rem;
}

.chat-chip {
  min-height: 2.5rem;
  padding: 0.45rem 0.85rem;
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 #b4bfcf;
  color: #19243b;
  font-weight: 600;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.25;
  text-align: start;
  cursor: pointer;
}

.chat-chip:hover {
  background: #e8edf5;
}

.chat-chip:active {
  box-shadow: 0 1px 0 #b4bfcf;
  transform: translateY(2px);
}

.chat-chip:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 30rem) {
  .chat.is-open {
    inset-inline: 0.5rem;
    bottom: 0.5rem;
  }

  .chat-panel {
    width: 100%;
    max-height: calc(100dvh - 5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-toggle,
  .chat-bubble {
    transition: none;
    transform: none;
  }
}

.chat-input:focus-visible {
  outline: 2px solid var(--accent, #f9ab05);
  outline-offset: -1px;
}

.chat-form {
  align-items: stretch;
}

.chat-send {
  margin-block-end: 3px;
}

.chat-privacy {
  padding-block-start: 1rem;
}

.chat-note.chat-contact,
.chat-contact {
  display: grid;
  gap: 0.25rem;
}

.chat-contact-call a {
  white-space: nowrap;
}

.chat-privacy {
  padding-block-end: calc(1rem - 1.4px);
}

.chat-chips-title,
.chat-msg--intro .chat-chips-title {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.chat-chips-title + .chat-chips {
  margin-top: 0.75rem;
}

.chat-contact-person {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 0.25rem;
}

.chat-contact-photo {
  flex: none;
  inline-size: 3rem;
  block-size: 3rem;
  overflow: hidden;
  border: 2px solid var(--accent, #f9ab05);
  border-radius: 50%;
}

.chat-contact-photo img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

.chat-contact-who {
  display: grid;
  line-height: 1.3;
}

.chat-contact-who b {
  color: inherit;
  font-size: 0.875rem;
}

.chat-say .chat-note:has(.chat-contact-person) {
  display: grid;
  gap: 0.35rem;
  justify-items: start;
  text-align: start;
}

.chat-say .chat-note .chat-contact-who b {
  color: #19243b;
}
