.hm-sophie,
.hm-sophie * {
  box-sizing: border-box;
}

.hm-sophie {
  --hm-navy: #102c49;
  --hm-navy-dark: #091c30;
  --hm-yellow: #ffc612;
  --hm-green: #25c96f;
  --hm-bg: #f4f7f9;
  --hm-line: #dbe3e9;
  --hm-muted: #627487;
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 2147482000;
  font-family: Inter, Arial, sans-serif;
  color: var(--hm-navy);
}

.hm-sophie [hidden] {
  display: none !important;
}

.hm-sophie__launcher {
  width: 78px;
  height: 78px;
  position: relative;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 3px solid var(--hm-green);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 15px 38px rgba(9, 28, 48, .28);
  cursor: pointer;
  animation: hm-sophie-arrive .6s cubic-bezier(.2,.85,.25,1) both,
             hm-sophie-talk 3.6s ease-in-out .85s infinite;
}

.hm-sophie__launcher img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.hm-sophie__hello {
  position: absolute;
  right: 4px;
  bottom: calc(100% + 10px);
  min-width: 54px;
  padding: 8px 12px;
  border: 1px solid rgba(16, 44, 73, .1);
  border-radius: 15px 15px 4px 15px;
  background: #fff;
  color: var(--hm-navy-dark);
  box-shadow: 0 8px 24px rgba(9, 28, 48, .16);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transform-origin: 88% 100%;
  animation: hm-sophie-hello 3.6s ease-in-out 1s infinite;
}

.hm-sophie__online-dot {
  width: 14px;
  height: 14px;
  position: absolute;
  right: 2px;
  bottom: 6px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--hm-green);
  box-shadow: 0 0 0 0 rgba(37, 201, 111, .35);
  animation: hm-sophie-online 2s ease-out infinite;
}

.hm-sophie__panel {
  width: min(390px, calc(100vw - 28px));
  max-height: min(680px, calc(100dvh - 32px));
  position: absolute;
  right: 0;
  bottom: 0;
  overflow: hidden;
  border: 1px solid rgba(16, 44, 73, .14);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(9, 28, 48, .34);
  animation: hm-sophie-panel .34s cubic-bezier(.2,.85,.25,1) both;
}

.hm-sophie__panel[hidden] {
  display: none !important;
}

.hm-sophie__header {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  background: var(--hm-navy-dark);
  color: #fff;
}

.hm-sophie__header > img {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 2px solid var(--hm-green);
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

.hm-sophie__header > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.hm-sophie__header strong {
  color: #fff;
  font-size: 13px;
  line-height: 1.25;
}

.hm-sophie__header small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cbd7e0;
  font-size: 10px;
}

.hm-sophie__header small i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hm-green);
  box-shadow: 0 0 0 4px rgba(37, 201, 111, .13);
}

.hm-sophie__header > button {
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: #fff;
  font: inherit;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.hm-sophie__progress {
  height: 4px;
  overflow: hidden;
  background: #dfe6eb;
}

.hm-sophie__progress i {
  width: 8%;
  height: 100%;
  display: block;
  border-radius: 999px;
  background: var(--hm-yellow);
  transition: width .35s ease;
}

.hm-sophie__messages {
  min-height: 330px;
  max-height: min(470px, calc(100dvh - 230px));
  display: flex;
  overflow-y: auto;
  flex-direction: column;
  gap: 9px;
  padding: 17px 15px;
  background:
    radial-gradient(circle at 95% 0, rgba(255,198,18,.09), transparent 36%),
    var(--hm-bg);
  scroll-behavior: smooth;
}

.hm-sophie__bubble {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.5;
  animation: hm-sophie-message .24s ease both;
}

.hm-sophie__bubble--agent {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: #fff;
  color: var(--hm-navy);
  box-shadow: 0 5px 17px rgba(9,28,48,.07);
}

.hm-sophie__bubble--user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--hm-navy);
  color: #fff;
  white-space: pre-line;
}

.hm-sophie__choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.hm-sophie__choices button {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--hm-line);
  border-radius: 11px;
  background: #fff;
  color: var(--hm-navy);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.hm-sophie__choices button:hover,
.hm-sophie__choices button:focus-visible {
  border-color: var(--hm-yellow);
  background: #fff9df;
}

.hm-sophie__ready {
  padding: 16px;
  border: 1px solid var(--hm-yellow);
  border-radius: 15px;
  background: #fffbea;
  color: var(--hm-navy-dark);
  font-size: 22px;
  font-weight: 900;
  animation: hm-sophie-message .26s ease both;
}

.hm-sophie__seen {
  align-self: flex-end;
  padding-right: 3px;
  color: #7b8994;
  font-size: 9px;
}

.hm-sophie__typing {
  width: 54px;
  min-height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  align-self: flex-start;
  border-radius: 13px 13px 13px 4px;
  background: #fff;
  box-shadow: 0 5px 17px rgba(9,28,48,.07);
}

.hm-sophie__typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #82919d;
  animation: hm-sophie-dot .9s ease-in-out infinite;
}

.hm-sophie__typing i:nth-child(2) { animation-delay: .14s; }
.hm-sophie__typing i:nth-child(3) { animation-delay: .28s; }

.hm-sophie__composer {
  display: grid;
  gap: 7px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--hm-line);
  background: #fff;
}

.hm-sophie__composer label {
  color: var(--hm-navy);
  font-size: 10px;
  font-weight: 800;
}

.hm-sophie__composer > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 7px;
}

.hm-sophie__composer input {
  min-width: 0;
  height: 45px;
  padding: 0 12px;
  border: 1px solid #cfd8df;
  border-radius: 10px;
  outline: 0;
  color: var(--hm-navy);
  background: #fff;
  font: inherit;
  font-size: 12px;
}

.hm-sophie__composer input:focus {
  border-color: var(--hm-yellow);
  box-shadow: 0 0 0 3px rgba(255,198,18,.18);
}

.hm-sophie__composer button {
  min-width: 70px;
  border: 0;
  border-radius: 10px;
  background: var(--hm-yellow);
  color: var(--hm-navy-dark);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.hm-sophie__composer button span {
  display: inline-block;
  margin-left: 3px;
  font-size: 14px;
  transition: transform .18s ease;
}

.hm-sophie__composer button:hover span,
.hm-sophie__composer button:focus-visible span {
  transform: translateX(3px);
}

.hm-sophie__contact-fields {
  grid-template-columns: 1fr 1fr !important;
}

.hm-sophie__contact-fields button {
  min-height: 44px;
  min-width: 0;
  grid-column: 1 / -1;
  font-size: 12px;
}

.hm-sophie__trap {
  width: 1px !important;
  height: 1px !important;
  position: absolute !important;
  left: -10000px !important;
  opacity: 0 !important;
}

@keyframes hm-sophie-arrive {
  from { opacity: 0; transform: translateY(22px) scale(.72); }
  to { opacity: 1; transform: none; }
}

@keyframes hm-sophie-talk {
  0%, 24%, 100% { transform: translateY(0) rotate(0); }
  6% { transform: translateY(-5px) rotate(-2deg); }
  12% { transform: translateY(-2px) rotate(2deg); }
  18% { transform: translateY(-4px) rotate(-1deg); }
}

@keyframes hm-sophie-hello {
  0%, 24%, 100% { transform: scale(1); }
  8% { transform: scale(1.08) rotate(-2deg); }
  16% { transform: scale(1.03) rotate(1deg); }
}

@keyframes hm-sophie-online {
  0% { box-shadow: 0 0 0 0 rgba(37,201,111,.38); }
  70%, 100% { box-shadow: 0 0 0 10px rgba(37,201,111,0); }
}

@keyframes hm-sophie-panel {
  from { opacity: 0; transform: translateY(18px) scale(.96); transform-origin: 100% 100%; }
  to { opacity: 1; transform: none; }
}

@keyframes hm-sophie-message {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

@keyframes hm-sophie-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 760px) {
  .hm-sophie {
    right: 13px;
    bottom: 78px;
  }

  .hm-sophie__launcher {
    width: 66px;
    height: 66px;
  }

  .hm-sophie__panel {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 92px);
    right: -1px;
    bottom: -4px;
    border-radius: 18px;
  }

  .hm-sophie__messages {
    min-height: 280px;
    max-height: calc(100dvh - 255px);
  }
}

@media (max-width: 430px) {
  .hm-sophie__contact-fields {
    grid-template-columns: 1fr !important;
  }

  .hm-sophie__contact-fields button {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hm-sophie *,
  .hm-sophie *::before,
  .hm-sophie *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
