.sp-chat {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  font-family: "Instrument Sans", system-ui, "Segoe UI", sans-serif;
  font-size: 0.9375rem;
}

.sp-chat-toggle {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  background: #0d4a2c;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(20, 20, 20, 0.12);
}

.sp-chat-toggle:hover {
  filter: brightness(1.08);
}

.sp-chat-toggle:focus-visible {
  outline: 2px solid #0d4a2c;
  outline-offset: 3px;
}

.sp-chat-panel {
  position: absolute;
  bottom: 3.5rem;
  right: 0;
  width: min(100vw - 2rem, 360px);
  height: min(70vh, 420px);
  background: #ffffff;
  border: 1px solid rgba(20, 20, 20, 0.1);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(20, 20, 20, 0.12);
}

/* Author `display:flex` wins over the `hidden` attribute otherwise — panel never disappears */
.sp-chat-panel[hidden] {
  display: none !important;
}

.sp-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem 0.75rem 1rem;
  border-bottom: 1px solid rgba(20, 20, 20, 0.08);
  font-weight: 600;
  color: #141414;
}

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

.sp-chat-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: #5c5c5c;
  margin-top: 0.15rem;
}

.sp-chat-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  margin: -0.15rem 0 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #5c5c5c;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: system-ui, sans-serif;
}

.sp-chat-close:hover {
  background: rgba(20, 20, 20, 0.07);
  color: #141414;
}

.sp-chat-close:focus-visible {
  outline: 2px solid #0d4a2c;
  outline-offset: 2px;
}

.sp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #fafafa;
}

.sp-chat-msg {
  max-width: 92%;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sp-chat-msg--user {
  align-self: flex-end;
  background: #0d4a2c;
  color: #fff;
}

.sp-chat-msg--bot {
  align-self: flex-start;
  background: #ffffff;
  color: #141414;
  border: 1px solid rgba(20, 20, 20, 0.08);
}

.sp-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem;
  border-top: 1px solid rgba(20, 20, 20, 0.08);
  background: #fff;
}

.sp-chat-form input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(20, 20, 20, 0.12);
  background: #fafafa;
  color: #141414;
  padding: 0.5rem 0.65rem;
}

.sp-chat-send {
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
}

@media (max-width: 480px) {
  .sp-chat {
    right: 0.75rem;
    bottom: 0.75rem;
  }
}
