.htaiw-root {
  --htaiw-bg: #ffffff;
  --htaiw-ink: #162033;
  --htaiw-muted: #667085;
  --htaiw-line: rgba(22, 32, 51, 0.12);
  --htaiw-brand: #0f8f78;
  --htaiw-brand-dark: #0b6f5e;
  --htaiw-action: #24c63f;
  --htaiw-action-dark: #18a834;
  --htaiw-action-soft: #eaf8ee;
  --htaiw-gold: #d6a84f;
  --htaiw-soft: #f3f7f6;
  --htaiw-shadow: 0 20px 60px rgba(15, 28, 44, 0.22);
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--htaiw-ink);
  letter-spacing: 0;
}

.htaiw-root--left {
  left: max(18px, env(safe-area-inset-left));
  right: auto;
}

.htaiw-root * {
  box-sizing: border-box;
}

.htaiw-root button,
.htaiw-root textarea {
  font-family: inherit;
  letter-spacing: 0;
}

.htaiw-root button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  min-width: 0;
  min-height: 0;
  text-transform: none;
  text-decoration: none;
  background-image: none;
  outline-offset: 2px;
}

.htaiw-root .htaiw-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 16px 10px 10px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f8f78, #136f97);
  color: #fff;
  box-shadow: 0 16px 38px rgba(15, 143, 120, 0.34);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.htaiw-root .htaiw-launcher:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 46px rgba(15, 143, 120, 0.42);
}

.htaiw-launcher__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 22px;
}

.htaiw-launcher__copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.htaiw-launcher__title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
}

.htaiw-launcher__hint {
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.88;
  white-space: nowrap;
}

.htaiw-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 28px));
  height: min(610px, calc(100vh - 110px));
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--htaiw-line);
  border-radius: 18px;
  background: var(--htaiw-bg);
  box-shadow: var(--htaiw-shadow);
  isolation: isolate;
}

.htaiw-root--left .htaiw-panel {
  left: 0;
  right: auto;
}

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

.htaiw-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  min-height: 70px;
  padding: 14px;
  background: #111827;
  color: #fff;
}

.htaiw-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 22px;
}

.htaiw-head__copy {
  min-width: 0;
}

.htaiw-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.htaiw-subtitle {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.25;
}

.htaiw-root .htaiw-close {
  display: grid;
  place-items: center;
  width: 34px !important;
  min-width: 34px !important;
  max-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  box-shadow: none !important;
  cursor: pointer;
  font-size: 22px;
  font-weight: 800;
  line-height: 1 !important;
}

.htaiw-root .htaiw-close:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

.htaiw-messages {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(15, 143, 120, 0.07), transparent 160px),
    #f8faf9;
}

.htaiw-msg {
  display: flex;
  width: 100%;
}

.htaiw-msg--user {
  justify-content: flex-end;
}

.htaiw-msg--bot {
  justify-content: flex-start;
}

.htaiw-bubble {
  max-width: 86%;
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.htaiw-msg--bot .htaiw-bubble {
  border: 1px solid rgba(22, 32, 51, 0.08);
  background: #fff;
  color: var(--htaiw-ink);
  border-bottom-left-radius: 5px;
}

.htaiw-msg--user .htaiw-bubble {
  background: var(--htaiw-brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.htaiw-bubble b {
  font-weight: 800;
}

.htaiw-msg--typing .htaiw-bubble {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 56px;
}

.htaiw-msg--typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--htaiw-brand);
  animation: htaiwPulse 1.1s infinite ease-in-out;
}

.htaiw-msg--typing span:nth-child(2) {
  animation-delay: 0.16s;
}

.htaiw-msg--typing span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes htaiwPulse {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.htaiw-chips {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  padding: 10px 14px 8px;
  overflow: visible;
  border-top: 1px solid var(--htaiw-line);
  background: #fff;
}

.htaiw-root .htaiw-chips button {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  min-width: 0 !important;
  height: 34px !important;
  min-height: 34px !important;
  max-height: 34px !important;
  padding: 0 10px !important;
  border: 1px solid rgba(24, 168, 52, 0.22) !important;
  border-radius: 999px !important;
  background: var(--htaiw-action) !important;
  color: #102018 !important;
  box-shadow: 0 7px 16px rgba(18, 130, 45, 0.18) !important;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.htaiw-root .htaiw-chips button:hover {
  background: var(--htaiw-action-dark) !important;
}

.htaiw-form {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: stretch;
  padding: 10px 14px 8px;
  background: #fff;
}

.htaiw-root .htaiw-input {
  width: 100%;
  min-height: 44px;
  max-height: 104px;
  resize: none;
  border: 1px solid var(--htaiw-line) !important;
  border-radius: 13px !important;
  padding: 11px 12px !important;
  color: var(--htaiw-ink) !important;
  background: #fff !important;
  box-shadow: none !important;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
}

.htaiw-root .htaiw-input:focus {
  border-color: rgba(15, 143, 120, 0.62);
  box-shadow: 0 0 0 3px rgba(15, 143, 120, 0.12);
}

.htaiw-root .htaiw-send {
  display: grid !important;
  place-items: center;
  width: 46px !important;
  min-width: 46px !important;
  max-width: 46px !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 13px !important;
  background: var(--htaiw-action) !important;
  color: #102018 !important;
  box-shadow: 0 8px 18px rgba(18, 130, 45, 0.2) !important;
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
  line-height: 1 !important;
}

.htaiw-root .htaiw-send:hover {
  background: var(--htaiw-action-dark) !important;
}

.htaiw-foot {
  flex: 0 0 auto;
  padding: 0 14px 12px;
  background: #fff;
  color: var(--htaiw-muted);
  font-size: 11px;
  line-height: 1.35;
}

@media (max-width: 520px) {
  .htaiw-root {
    right: 12px;
    bottom: 12px;
  }

  .htaiw-root--left {
    left: 12px;
    right: auto;
  }

  .htaiw-root .htaiw-launcher {
    min-height: 54px;
    padding-right: 12px;
  }

  .htaiw-launcher__hint {
    display: none;
  }

  .htaiw-panel {
    position: fixed;
    inset: auto 10px 76px 10px;
    width: auto;
    height: min(620px, calc(100vh - 92px));
    min-height: 390px;
    border-radius: 16px;
  }

  .htaiw-chips {
    gap: 7px;
    padding: 9px 12px 7px;
  }

  .htaiw-root .htaiw-chips button {
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding: 0 7px !important;
    font-size: 11px;
  }

  .htaiw-form {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 9px 12px 7px;
  }

  .htaiw-root .htaiw-send {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
  }
}
