.updaly-inbox {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  --updaly-inbox-accent: #155eef;
  --updaly-inbox-accent-dark: #004eeb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #101828;
}

.updaly-inbox--right {
  right: max(18px, env(safe-area-inset-right));
}

.updaly-inbox--left {
  left: max(18px, env(safe-area-inset-left));
}

.updaly-inbox button,
.updaly-inbox input,
.updaly-inbox textarea {
  font: inherit;
}

.updaly-inbox svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.updaly-inbox__toggle {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--updaly-inbox-accent);
  box-shadow: 0 18px 34px rgba(21, 94, 239, 0.32);
  cursor: pointer;
  outline: none;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.updaly-inbox__toggle:hover {
  transform: translateY(-1px);
  background: var(--updaly-inbox-accent-dark);
  box-shadow: 0 22px 42px rgba(21, 94, 239, 0.38);
}

.updaly-inbox__toggle-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.updaly-inbox__toggle:focus-visible,
.updaly-inbox__close:focus-visible,
.updaly-inbox__form button:focus-visible {
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.16), 0 18px 34px rgba(21, 94, 239, 0.28);
}

.updaly-inbox__toggle-close,
.updaly-inbox--open .updaly-inbox__toggle-open {
  display: none;
}

.updaly-inbox--open .updaly-inbox__toggle-close {
  display: block;
}

.updaly-inbox__panel {
  display: none;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 104px));
  min-height: 460px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22);
  transform-origin: right bottom;
  animation: updaly-inbox-enter 180ms ease-out;
}

.updaly-inbox--left .updaly-inbox__panel {
  transform-origin: left bottom;
}

.updaly-inbox--open .updaly-inbox__panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.updaly-inbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  color: #fff;
  background: linear-gradient(135deg, #101828 0%, #1d2939 58%, var(--updaly-inbox-accent) 160%);
}

.updaly-inbox__brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.updaly-inbox__avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: #fff;
  color: var(--updaly-inbox-accent);
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
}

.updaly-inbox__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.updaly-inbox__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  line-height: 1.2;
}

.updaly-inbox__status span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #32d583;
  box-shadow: 0 0 0 3px rgba(50, 213, 131, 0.2);
}

.updaly-inbox__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  outline: none;
}

.updaly-inbox__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.updaly-inbox__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 24px 24px, rgba(21, 94, 239, 0.08) 0 2px, transparent 3px) 0 0 / 28px 28px,
    #f8fafc;
}

.updaly-inbox__intro {
  display: grid;
  gap: 8px;
  margin: auto 0;
  padding: 18px;
  border: 1px solid #e4e7ec;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
  text-align: center;
}

.updaly-inbox__intro strong {
  font-size: 15px;
  line-height: 1.3;
}

.updaly-inbox__intro span {
  color: #667085;
  font-size: 13px;
  line-height: 1.45;
}

.updaly-inbox__profile {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.updaly-inbox__profile input {
  width: 100%;
  height: 40px;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  padding: 0 11px;
  color: #101828;
  background: #fff;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.updaly-inbox__profile input:focus {
  border-color: #84adff;
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.12);
}

.updaly-inbox__message-row {
  display: grid;
  gap: 5px;
  max-width: 84%;
}

.updaly-inbox__message-row--visitor {
  align-self: flex-end;
  justify-items: end;
}

.updaly-inbox__message-row--agent {
  align-self: flex-start;
  justify-items: start;
}

.updaly-inbox__message {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  color: #111827;
  box-shadow: 0 3px 12px rgba(16, 24, 40, 0.07);
  font-size: 14px;
  line-height: 1.42;
  word-break: break-word;
}

.updaly-inbox__message-row .updaly-inbox__message {
  max-width: 100%;
}

.updaly-inbox__message-text {
  white-space: pre-wrap;
}

.updaly-inbox__message-image {
  display: block;
  width: min(240px, 100%);
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
}

.updaly-inbox__image-button {
  display: block;
  border: 0;
  padding: 0;
  margin: 0 0 8px;
  border-radius: 12px;
  background: transparent;
  cursor: zoom-in;
}

.updaly-inbox__message-text:empty {
  display: none;
}

.updaly-inbox__receipt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #667085;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.2;
  padding-right: 4px;
}

.updaly-inbox__receipt svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  stroke: none;
}

.updaly-inbox__receipt--read {
  color: #667085;
}

.updaly-inbox__typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  border-radius: 16px 16px 16px 5px;
  padding: 0 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(16, 24, 40, 0.07);
}

.updaly-inbox__typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #98a2b3;
  animation: updaly-inbox-typing-dot 1s ease-in-out infinite;
}

.updaly-inbox__typing-bubble span:nth-child(2) {
  animation-delay: 130ms;
}

.updaly-inbox__typing-bubble span:nth-child(3) {
  animation-delay: 260ms;
}

.updaly-inbox__message--visitor {
  color: #fff;
  border-radius: 16px 16px 5px 16px;
  background: var(--updaly-inbox-accent);
  box-shadow: 0 8px 20px rgba(21, 94, 239, 0.2);
}

.updaly-inbox__form {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.updaly-inbox__form textarea {
  height: 42px;
  min-height: 42px;
  max-height: 116px;
  resize: none;
  border: 1px solid #d0d5dd;
  border-radius: 14px;
  padding: 10px 12px;
  color: #101828;
  background: #f9fafb;
  outline: none;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.updaly-inbox__form textarea:focus {
  border-color: #84adff;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.12);
}

.updaly-inbox__form button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  padding: 0;
  color: #fff;
  background: var(--updaly-inbox-accent);
  cursor: pointer;
  outline: none;
  transition: background 150ms ease, transform 150ms ease;
}

.updaly-inbox__attach {
  color: var(--updaly-inbox-accent) !important;
  background: #eef4ff !important;
}

.updaly-inbox__attach--active {
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.12);
}

.updaly-inbox__attach svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.updaly-inbox__image-preview {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
}

.updaly-inbox__image-preview img {
  display: block;
  max-width: min(92vw, 1100px);
  max-height: 88vh;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.38);
}

.updaly-inbox__image-preview-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  color: #101828;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.updaly-inbox__form button:hover {
  transform: translateY(-1px);
  background: var(--updaly-inbox-accent-dark);
}

.updaly-inbox__form button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

@keyframes updaly-inbox-typing-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

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

@keyframes updaly-inbox-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 480px) {
  .updaly-inbox {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .updaly-inbox__panel {
    width: 100%;
    height: min(620px, calc(100vh - 92px));
    min-height: 420px;
  }

  .updaly-inbox__toggle {
    margin-left: auto;
  }
}
