.klima-webchat-root {
  position: fixed;
  z-index: var(--klima-webchat-z, 99999);
  bottom: max(var(--klima-webchat-offset-bottom, 24px), env(safe-area-inset-bottom, 0px));
  width: 0;
  height: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--klima-webchat-heading, #18181b);
  -webkit-font-smoothing: antialiased;
}

.klima-webchat-root *,
.klima-webchat-root *::before,
.klima-webchat-root *::after {
  box-sizing: border-box;
}

.klima-webchat-root[data-position="right"] {
  right: max(var(--klima-webchat-offset-side, 24px), env(safe-area-inset-right, 0px));
  left: auto;
}

.klima-webchat-root[data-position="left"] {
  left: max(var(--klima-webchat-offset-side, 24px), env(safe-area-inset-left, 0px));
  right: auto;
}

.klima-webchat-root button {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  margin: 0;
  float: none;
  line-height: inherit;
  cursor: pointer;
}

.klima-webchat-root button:disabled {
  cursor: not-allowed;
}

.klima-webchat-root .klima-webchat-launcher {
  position: absolute;
  bottom: 0;
  width: 60px;
  height: 60px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--klima-webchat-primary, #0f766e);
  color: var(--klima-webchat-on-primary, #f0fdfa);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.klima-webchat-root[data-position="right"] .klima-webchat-launcher {
  right: 0;
}

.klima-webchat-root[data-position="left"] .klima-webchat-launcher {
  left: 0;
}

.klima-webchat-root .klima-webchat-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}

.klima-webchat-root .klima-webchat-launcher:focus-visible,
.klima-webchat-root .klima-webchat-icon-btn:focus-visible,
.klima-webchat-root .klima-webchat-card:focus-visible,
.klima-webchat-root .klima-webchat-send:focus-visible,
.klima-webchat-root .klima-webchat-input:focus-visible,
.klima-webchat-root .klima-webchat-text-btn:focus-visible {
  outline: 3px solid var(--klima-webchat-primary, #0f766e);
  outline-offset: 2px;
}

.klima-webchat-root .klima-webchat-launcher svg {
  width: 28px;
  height: 28px;
}

.klima-webchat-root .klima-webchat-launcher[hidden] {
  display: none !important;
}

.klima-webchat-root.is-open .klima-webchat-launcher {
  visibility: hidden;
  pointer-events: none;
}

.klima-webchat-root .klima-webchat-panel {
  position: absolute;
  bottom: 0;
  width: min(384px, calc(100vw - var(--klima-webchat-offset-side, 24px) - 12px));
  height: min(580px, calc(100dvh - var(--klima-webchat-offset-bottom, 24px) - 16px));
  max-height: min(580px, calc(100vh - var(--klima-webchat-offset-bottom, 24px) - 16px));
  background: var(--klima-webchat-panel-bg, #f4f6f8);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.klima-webchat-root[data-position="right"] .klima-webchat-panel {
  right: 0;
}

.klima-webchat-root[data-position="left"] .klima-webchat-panel {
  left: 0;
}

.klima-webchat-root .klima-webchat-panel[hidden] {
  display: none !important;
}

.klima-webchat-root .klima-webchat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px 12px;
  background: var(--klima-webchat-card-bg, #ffffff);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

.klima-webchat-root .klima-webchat-header-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--klima-webchat-primary, #0f766e);
  color: var(--klima-webchat-on-primary, #f0fdfa);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.klima-webchat-root .klima-webchat-header-icon svg {
  width: 16px;
  height: 16px;
}

.klima-webchat-root .klima-webchat-title {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--klima-webchat-heading, #18181b);
  line-height: 1.3;
}

.klima-webchat-root .klima-webchat-icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--klima-webchat-secondary, #71717a);
  flex-shrink: 0;
  box-shadow: none;
}

.klima-webchat-root .klima-webchat-icon-btn:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--klima-webchat-heading, #18181b);
}

.klima-webchat-root .klima-webchat-icon-btn svg {
  width: 20px;
  height: 20px;
}

.klima-webchat-root .klima-webchat-home,
.klima-webchat-root .klima-webchat-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.klima-webchat-root .klima-webchat-home[hidden],
.klima-webchat-root .klima-webchat-chat[hidden] {
  display: none !important;
}

.klima-webchat-root .klima-webchat-home-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.klima-webchat-root .klima-webchat-home-body > .klima-webchat-social-label:first-child {
  margin-top: 0;
}

.klima-webchat-root .klima-webchat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, 0.05);
  background: var(--klima-webchat-card-bg, #ffffff);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.klima-webchat-root .klima-webchat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.klima-webchat-root .klima-webchat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--klima-webchat-avatar, var(--klima-webchat-primary, #0f766e));
  color: var(--klima-webchat-on-primary, #f0fdfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.klima-webchat-root .klima-webchat-wa-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ecfdf3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.klima-webchat-root .klima-webchat-wa-icon img {
  width: 26px;
  height: 26px;
  display: block;
}

.klima-webchat-root .klima-webchat-card-body {
  flex: 1;
  min-width: 0;
}

.klima-webchat-root .klima-webchat-card-title {
  display: block;
  font-weight: 600;
  color: var(--klima-webchat-heading, #18181b);
}

.klima-webchat-root .klima-webchat-card-text {
  margin-top: 2px;
  color: var(--klima-webchat-secondary, #71717a);
  font-size: 0.86rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.klima-webchat-root .klima-webchat-chevron {
  color: var(--klima-webchat-secondary, #71717a);
  flex-shrink: 0;
}

.klima-webchat-root .klima-webchat-chevron svg {
  width: 18px;
  height: 18px;
}

.klima-webchat-root .klima-webchat-social-label {
  margin: 8px 2px 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--klima-webchat-secondary, #71717a);
}

.klima-webchat-root .klima-webchat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.klima-webchat-root .klima-webchat-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.95rem;
}

.klima-webchat-root .klima-webchat-bubble--welcome,
.klima-webchat-root .klima-webchat-bubble--assistant {
  align-self: flex-start;
  background: var(--klima-webchat-card-bg, #ffffff);
  color: var(--klima-webchat-heading, #18181b);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.klima-webchat-root .klima-webchat-bubble--user {
  align-self: flex-end;
  background: var(--klima-webchat-primary, #0f766e);
  color: var(--klima-webchat-on-primary, #f0fdfa);
  border-bottom-right-radius: 6px;
}

.klima-webchat-root .klima-webchat-bubble--pending {
  opacity: 0.72;
}

.klima-webchat-root .klima-webchat-bubble--failed {
  opacity: 1;
  box-shadow: 0 0 0 1px #b91c1c inset;
}

.klima-webchat-root .klima-webchat-error {
  align-self: flex-end;
  max-width: 85%;
  color: #b91c1c;
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.klima-webchat-root .klima-webchat-actions {
  align-self: flex-end;
  display: flex;
  gap: 8px;
}

.klima-webchat-root .klima-webchat-text-btn {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--klima-webchat-card-bg, #ffffff);
  color: var(--klima-webchat-primary, #0f766e);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: none;
}

.klima-webchat-root .klima-webchat-text-btn:hover {
  background: #fff;
}

.klima-webchat-root .klima-webchat-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  background: var(--klima-webchat-card-bg, #ffffff);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
}

.klima-webchat-root .klima-webchat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--klima-webchat-secondary, #71717a);
  opacity: 0.45;
  animation: klima-webchat-blink 1.2s infinite ease-in-out;
}

.klima-webchat-root .klima-webchat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.klima-webchat-root .klima-webchat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes klima-webchat-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 0.9;
    transform: translateY(-2px);
  }
}

.klima-webchat-root .klima-webchat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--klima-webchat-card-bg, #ffffff);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

.klima-webchat-root .klima-webchat-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--klima-webchat-panel-bg, #f4f6f8);
  color: var(--klima-webchat-heading, #18181b);
  font: inherit;
  line-height: 1.4;
  width: 100%;
  box-shadow: none;
}

.klima-webchat-root .klima-webchat-input:disabled {
  opacity: 0.65;
}

.klima-webchat-root .klima-webchat-send {
  flex-shrink: 0;
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--klima-webchat-primary, #0f766e);
  color: var(--klima-webchat-on-primary, #f0fdfa);
  font-weight: 600;
  box-shadow: none;
}

.klima-webchat-root .klima-webchat-send:hover:not(:disabled) {
  filter: brightness(1.05);
}

.klima-webchat-root .klima-webchat-send:disabled {
  opacity: 0.55;
}

.klima-webchat-root .klima-webchat-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .klima-webchat-root *,
  .klima-webchat-root *::before,
  .klima-webchat-root *::after {
    animation: none !important;
    transition: none !important;
  }
}
