.webchat-launcher-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-direction: row;
}

/* Подсказка слева от кнопки: зелёный «овал», белый текст (без нативного чёрного title) */
.webchat-launcher-hint {
  pointer-events: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  background: linear-gradient(145deg, #22c55e 0%, #15803d 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(22, 101, 52, 0.35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.webchat-launcher-wrap:hover .webchat-launcher-hint,
.webchat-launcher-wrap:focus-within .webchat-launcher-hint {
  opacity: 1;
  transform: translateX(0);
}

.webchat-launcher {
  border: 0;
  border-radius: 999px;
  width: 54px;
  height: 54px;
  background: var(--primary-color);
  color: var(--text-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  flex-shrink: 0;
}

.webchat-launcher-icon {
  font-size: 24px;
  line-height: 1;
}

.webchat-panel {
  position: fixed;
  right: 20px;
  bottom: 78px;
  width: min(380px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 120px));
  z-index: 1200;
  display: none;
  flex-direction: column;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.webchat-panel.open {
  display: flex;
}

.webchat-head {
  background: var(--primary-color);
  color: var(--text-light);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.webchat-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.webchat-head-sub {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.92;
  line-height: 1.2;
}

.webchat-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
}

.webchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #f8fbf7;
}

.webchat-row {
  margin-bottom: 8px;
  display: flex;
}

.webchat-row.user {
  justify-content: flex-end;
}

.webchat-bubble {
  max-width: 88%;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.webchat-user-cap {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.95;
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.webchat-row.user .webchat-user-cap {
  color: inherit;
}

.webchat-bubble-body {
  white-space: pre-wrap;
}

.webchat-row.user .webchat-bubble {
  background: var(--primary-color);
  color: var(--text-light);
}

.webchat-row.assistant .webchat-bubble {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--foreground);
}

.webchat-row.manager .webchat-bubble {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-left: 4px solid var(--primary-color, #16a34a);
  color: var(--foreground);
}

.webchat-msg-meta {
  align-self: flex-end;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

.webchat-dticks {
  letter-spacing: -3px;
}

.webchat-dtick {
  color: #94a3b8;
}

.webchat-dtick.t1 {
  opacity: 0.95;
}

.webchat-msg-meta[data-delivered="1"] .webchat-dtick.t2 {
  color: #16a34a;
  opacity: 1;
}

.webchat-msg-meta[data-delivered="0"] .webchat-dtick.t2 {
  opacity: 0.32;
}

.webchat-row.system .webchat-bubble {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
  font-size: 12px;
}

.webchat-form {
  border-top: 1px solid var(--card-border);
  padding: 10px;
  background: var(--card);
}

.webchat-input-wrap {
  display: flex;
  gap: 8px;
}

.webchat-input {
  flex: 1;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
}

.webchat-send {
  border: 0;
  border-radius: 10px;
  background: var(--primary-color);
  color: var(--text-light);
  padding: 0 12px;
  font-weight: 600;
  cursor: pointer;
}

.webchat-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.webchat-tool-btn {
  border: 1px solid var(--card-border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
}

.webchat-lead {
  border: 1px dashed var(--card-border);
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 10px;
  background: #fafafa;
}

.webchat-lead-hint {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
}

.webchat-lead input {
  width: 100%;
  margin-bottom: 6px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
}

.webchat-consent {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  column-gap: 8px;
  align-items: start;
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-align: left;
}

.webchat-consent input[type="checkbox"] {
  margin: 2px 0 0;
  width: 14px;
  height: 14px;
  justify-self: start;
  align-self: start;
}

.webchat-consent span {
  min-width: 0;
  display: block;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: left;
}

.webchat-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.webchat-row.typing {
  justify-content: flex-start;
}

.webchat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e8f5e9;
  font-size: 13px;
  color: #2e7d32;
  padding: 8px 10px;
  border-radius: 10px;
}

.webchat-typing-dots span {
  display: inline-block;
  animation: webchat-dot-pulse 1.2s infinite ease-in-out;
  opacity: 0.35;
}

.webchat-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.webchat-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes webchat-dot-pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.webchat-typing-caption {
  font-size: 12px;
  color: #1b5e20;
}

@media (max-width: 640px) {
  .webchat-launcher-wrap {
    right: 10px;
    bottom: 10px;
    gap: 8px;
  }
  .webchat-launcher-hint {
    font-size: 12px;
    padding: 7px 14px;
  }
  .webchat-panel {
    right: 8px;
    bottom: 64px;
    width: calc(100vw - 16px);
    height: min(74vh, 700px);
  }
}
