.sp-chat-fab,
.sp-chat-panel {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sp-chat-fab {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 86px);
  z-index: 80;
  display: none;
  min-width: 64px;
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  background: #128c7e;
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 0 16px;
}

.sp-chat-fab[data-ready="true"] {
  display: inline-flex;
}

.sp-chat-fab:active {
  transform: translateY(1px);
}

.sp-chat-fab__dot {
  position: relative;
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 8px;
}

.sp-chat-fab__dot::after {
  position: absolute;
  right: 1px;
  bottom: -6px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(35deg);
}

.sp-chat-fab__badge {
  position: absolute;
  top: -5px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.sp-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  background: #e6ddd4;
  color: #111827;
}

.sp-chat-panel[data-open="true"] {
  display: flex;
  flex-direction: column;
}

.sp-chat-header {
  display: flex;
  min-height: calc(env(safe-area-inset-top) + 58px);
  align-items: end;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 10px;
  background: #075e54;
  color: #fff;
}

.sp-chat-icon-btn {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 22px;
  font-weight: 800;
}

.sp-chat-icon-btn:active {
  background: rgba(255, 255, 255, 0.16);
}

.sp-chat-header__text {
  min-width: 0;
  flex: 1;
}

.sp-chat-title {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-chat-subtitle {
  margin: 3px 0 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-chat-list {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

.sp-chat-conversation {
  display: flex;
  width: 100%;
  min-height: 74px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  color: #111827;
  padding: 10px 14px;
  text-align: left;
}

.sp-chat-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: #128c7e;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.sp-chat-avatar--team {
  background: #2563eb;
}

.sp-chat-conversation__body {
  min-width: 0;
  flex: 1;
}

.sp-chat-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.sp-chat-row strong,
.sp-chat-last {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-chat-row strong {
  flex: 1;
  font-size: 15px;
}

.sp-chat-time {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.sp-chat-last {
  margin-top: 4px;
  color: #64748b;
  font-size: 13px;
}

.sp-chat-unread {
  display: inline-grid;
  min-width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.sp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 8px;
}

.sp-chat-empty,
.sp-chat-error {
  margin: 18px auto;
  max-width: 260px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  padding: 12px;
  text-align: center;
}

.sp-chat-error {
  background: #fee2e2;
  color: #991b1b;
}

.sp-chat-msg {
  display: flex;
  margin: 5px 0;
}

.sp-chat-msg--mine {
  justify-content: flex-end;
}

.sp-chat-bubble {
  max-width: min(78vw, 520px);
  border-radius: 12px 12px 12px 3px;
  background: #fff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.11);
  padding: 7px 9px 5px;
}

.sp-chat-msg--mine .sp-chat-bubble {
  border-radius: 12px 12px 3px 12px;
  background: #dcf8c6;
}

.sp-chat-sender {
  margin-bottom: 2px;
  color: #0f766e;
  font-size: 11px;
  font-weight: 900;
}

.sp-chat-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.32;
}

.sp-chat-meta {
  margin-top: 3px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  text-align: right;
}

.sp-chat-compose {
  display: flex;
  gap: 8px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px);
  background: #f1f5f9;
}

.sp-chat-compose textarea {
  min-height: 42px;
  max-height: 112px;
  flex: 1;
  resize: none;
  border: 0;
  border-radius: 20px;
  background: #fff;
  color: #111827;
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  outline: none;
  padding: 11px 14px;
}

.sp-chat-send {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: #128c7e;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.sp-chat-send:disabled {
  background: #94a3b8;
}

@media (min-width: 901px) and (pointer: fine) {
  .sp-chat-fab,
  .sp-chat-panel {
    display: none !important;
  }
}
