:root {
  --spms-floating-control-size: 3.5rem;
  --spms-floating-icon-size: 2.5rem;
}

.spms-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(21, 35, 40, 0.28);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms cubic-bezier(0.22, 0.74, 0.08, 1);
}

.spms-chat-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.spms-chat-panel {
  width: min(28rem, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid rgba(16, 43, 45, 0.08);
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 24px 80px rgba(16, 43, 45, 0.18);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 420ms cubic-bezier(0.22, 0.74, 0.08, 1),
    transform 420ms cubic-bezier(0.22, 0.74, 0.08, 1);
}

.spms-chat-overlay.is-open .spms-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.spms-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(16, 43, 45, 0.06);
}

.spms-chat-title {
  margin: 0;
  color: #102b2d;
  font-size: 0.875rem;
  font-weight: 600;
}

.spms-chat-description {
  margin: 0.25rem 0 0;
  color: #617075;
  font-size: 0.75rem;
  line-height: 1.65;
}

.spms-chat-close {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(16, 43, 45, 0.1);
  border-radius: 999px;
  background: #fff;
  color: #102b2d;
  font-size: 1.25rem;
  cursor: pointer;
}

.spms-chat-close:hover,
.spms-chat-close:focus-visible {
  border-color: #087f87;
  color: #087f87;
}

.spms-chat-messages {
  max-height: 20rem;
  overflow-y: auto;
  padding: 1rem;
}

.spms-chat-message-group {
  display: grid;
  gap: 0.75rem;
}

.spms-chat-starter-label {
  margin: 0;
  color: #536668;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.spms-chat-bubble {
  max-width: 85%;
  padding: 0.625rem 0.75rem;
  border-radius: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.spms-chat-bubble--assistant {
  background: #e9f3f0;
  color: #102b2d;
}

.spms-chat-bubble--user {
  margin-left: auto;
  background: #102b2d;
  color: #fff;
}

.spms-chat-typing::after {
  display: inline-block;
  width: 1.2em;
  content: "…";
  animation: spms-chat-typing-pulse 1s steps(3, end) infinite;
  overflow: hidden;
  vertical-align: bottom;
}

@keyframes spms-chat-typing-pulse {
  0% { width: 0; }
  100% { width: 1.2em; }
}

.spms-chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.spms-chat-quick-reply {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(16, 43, 45, 0.1);
  border-radius: 999px;
  background: #fff;
  color: #102b2d;
  font-size: 0.75rem;
  cursor: pointer;
}

.spms-chat-quick-reply:hover,
.spms-chat-quick-reply:focus-visible {
  border-color: #087f87;
  color: #087f87;
}

.spms-chat-quick-reply:disabled {
  cursor: wait;
  opacity: 0.55;
}

.spms-chat-response {
  display: grid;
  gap: 0.625rem;
  margin-top: 0.75rem;
}

.spms-chat-page-list {
  display: grid;
  gap: 0.5rem;
}

.spms-chat-page-link {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid rgba(16, 43, 45, 0.1);
  border-radius: 0.875rem;
  background: #fff;
  color: #102b2d;
  text-decoration: none;
}

.spms-chat-page-link strong {
  color: #087f87;
  font-size: 0.8125rem;
}

.spms-chat-page-link span {
  color: #617075;
  font-size: 0.75rem;
  line-height: 1.5;
}

.spms-chat-page-link:hover,
.spms-chat-page-link:focus-visible {
  border-color: #087f87;
  outline: none;
}

.spms-chat-contact,
.spms-chat-secondary-action {
  justify-self: start;
  min-height: 2.5rem;
  padding: 0.625rem 0.875rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.spms-chat-contact {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: #dc3838;
  color: #fff;
  text-decoration: none;
}

.spms-chat-secondary-action {
  border: 1px solid rgba(16, 43, 45, 0.1);
  background: #fff;
  color: #102b2d;
}

.spms-chat-contact:hover,
.spms-chat-contact:focus-visible {
  background: #e53b3b;
}

.spms-chat-secondary-action:hover,
.spms-chat-secondary-action:focus-visible {
  border-color: #087f87;
  color: #087f87;
}

.spms-chat-secondary-action:disabled {
  cursor: default;
  opacity: 0.5;
}

.spms-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(16, 43, 45, 0.06);
}

.spms-chat-compose {
  display: grid;
  flex: 1;
  gap: 0.3rem;
}

.spms-chat-keyboard-hint {
  padding-left: 0.5rem;
  color: #617075;
  font-size: 0.625rem;
  line-height: 1.35;
}

.spms-chat-review-status {
  margin: 0;
  color: #617075;
  font-size: 0.6875rem;
  line-height: 1.45;
}

.spms-chat-review-status[data-state="recorded"] {
  color: #087f87;
}

.spms-chat-review-status[data-state="failed"] {
  color: #9d2d2d;
}

.spms-chat-input {
  width: 100%;
  min-height: 3rem;
  resize: vertical;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(16, 43, 45, 0.1);
  border-radius: 1.25rem;
  color: #102b2d;
  font: inherit;
  font-size: 0.875rem;
  outline: none;
}

.spms-chat-input:focus {
  border-color: #087f87;
  box-shadow: 0 0 0 3px rgba(19, 166, 173, 0.14);
}

.spms-chat-input:disabled {
  cursor: wait;
  opacity: 0.65;
}

.spms-chat-submit,
.spms-chat-toggle {
  border: 0;
  cursor: pointer;
}

.spms-chat-submit {
  display: inline-flex;
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #dc3838;
  color: #fff;
  font-size: 1.15rem;
}

.spms-chat-submit:hover,
.spms-chat-submit:focus-visible {
  background: #e53b3b;
}

.spms-chat-submit:disabled {
  cursor: wait;
  opacity: 0.55;
}

.spms-chat-floating {
  position: fixed;
  right: 1rem;
  bottom: 5.5rem;
  z-index: 40;
}

.spms-chat-toggle {
  display: inline-flex;
  width: var(--spms-floating-control-size);
  height: var(--spms-floating-control-size);
  flex: 0 0 var(--spms-floating-control-size);
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(16, 43, 45, 0.16);
}

.spms-chat-toggle-icon {
  display: inline-flex;
  width: var(--spms-floating-icon-size);
  height: var(--spms-floating-icon-size);
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #087f87;
  color: #fff;
}

#jump-to-top {
  box-sizing: border-box;
  display: inline-flex;
  width: var(--spms-floating-control-size);
  height: var(--spms-floating-control-size);
  align-items: center;
  justify-content: center;
  padding: 0;
}

#jump-to-top > .shell-core {
  box-sizing: border-box;
  display: inline-flex;
  width: var(--spms-floating-icon-size);
  height: var(--spms-floating-icon-size);
  min-width: var(--spms-floating-icon-size);
  min-height: var(--spms-floating-icon-size);
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
}

#jump-to-top > .shell-core > span {
  width: var(--spms-floating-icon-size);
  height: var(--spms-floating-icon-size);
}

.spms-chat-toggle-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

@media (max-width: 560px) {
  .spms-chat-panel {
    width: min(28rem, calc(100vw - 1rem));
  }

  .spms-chat-overlay {
    padding: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spms-chat-overlay,
  .spms-chat-panel {
    transition: none;
  }

  .spms-chat-typing::after {
    animation: none;
  }
}
