.sp-chat-btn {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px 12px 12px;
  background: var(--accent, #c6ff4a);
  color: var(--ink, #111);
  font: 700 14px/1 inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.sp-chat-btn .sp-chat-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .12);
  display: grid;
  place-items: center;
  font-size: 16px;
}
.sp-chat-btn .sp-chat-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c0392b;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}
.sp-chat-btn.has-unread .sp-chat-badge { display: inline-block; }
.sp-chat-panel {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 41;
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100dvh - 100px));
  display: none;
  flex-direction: column;
  background: var(--card, #161616);
  color: var(--text, #f2f2f2);
  border: 1px solid var(--line, #333);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
}
.sp-chat-panel.open { display: flex; }
.sp-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #333);
  background: #111;
}
.sp-chat-head strong { font-size: 15px; }
.sp-chat-head button {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.sp-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg, #0b0b0b);
}
.sp-chat-empty { color: var(--muted, #aaa); font-size: 13px; margin: auto; text-align: center; }
.sp-chat-msg {
  max-width: 86%;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.sp-chat-msg.client {
  margin-left: auto;
  background: #2a3300;
  color: #eaffb0;
}
.sp-chat-msg.staff {
  margin-right: auto;
  background: var(--card-2, #222);
}
.sp-chat-msg time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: .65;
}
.sp-chat-form {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line, #333);
}
.sp-chat-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sp-chat-form input, .sp-chat-form textarea {
  width: 100%;
  border: 1px solid var(--line, #333);
  border-radius: 10px;
  background: var(--bg, #0b0b0b);
  color: inherit;
  font: inherit;
  padding: 8px 10px;
}
.sp-chat-form textarea { min-height: 64px; resize: vertical; }
.sp-chat-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted, #aaa);
}
.sp-chat-consent a { color: var(--accent, #c6ff4a); }
.sp-chat-form button[type="submit"] {
  border: 0;
  border-radius: 10px;
  padding: 10px;
  background: var(--accent, #c6ff4a);
  color: var(--ink, #111);
  font-weight: 700;
  cursor: pointer;
}
.sp-chat-error { color: #ff8a8a; font-size: 12px; min-height: 1em; }
.to-top { right: 72px; }
@media (max-width: 860px) {
  .sp-chat-panel { display: none !important; }
  .sp-chat-form .row { grid-template-columns: 1fr; }
  .sp-chat-btn span.sp-chat-label { display: none; }
  .sp-chat-btn { padding: 12px; }
}
@media (max-width: 520px) {
  .sp-chat-form .row { grid-template-columns: 1fr; }
}
