.boss-chat {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 80;
  font-family: var(--font-sans, "Manrope", sans-serif);
  pointer-events: none;
}

.boss-chat-toggle,
.boss-chat-panel,
.boss-chat-close {
  pointer-events: auto;
}

.boss-chat-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 52px;
  min-width: 52px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 80px;
  background: #352a44;
  color: #fafaf7;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 18px 50px rgba(53, 42, 68, 0.18);
}

.boss-chat-toggle svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.boss-chat.is-open .boss-chat-toggle {
  display: none;
}

.boss-chat-panel {
  display: none;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(84px, calc(20px + env(safe-area-inset-bottom) + 64px));
  left: auto;
  width: min(380px, calc(100vw - 40px));
  height: min(560px, calc(100dvh - 140px));
  flex-direction: column;
  background: #ffffff;
  color: rgba(7, 8, 7, 0.9);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(53, 42, 68, 0.22);
}

.boss-chat.is-open .boss-chat-panel {
  display: flex;
}

.boss-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 0.85rem 0.85rem 1.1rem;
  background: #352a44;
  color: #e9fff4;
  flex-shrink: 0;
}

.boss-chat-head strong {
  display: block;
  font-family: var(--font-serif, "Baskervville", serif);
  font-size: 1.2rem;
  font-weight: 400;
}

.boss-chat-head span {
  display: block;
  margin-top: 0.15rem;
  color: #fafaf7;
  font-size: 0.78rem;
  font-weight: 500;
}

.boss-chat-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #e9fff4;
  color: #352a44;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.boss-chat-close svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.boss-chat-log {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #fafaf7;
  -webkit-overflow-scrolling: touch;
}

.boss-chat-bubble {
  max-width: 85%;
  padding: 0.7rem 0.85rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.boss-chat-bubble.is-visitor {
  align-self: flex-end;
  background: #352a44;
  color: #fafaf7;
}

.boss-chat-bubble.is-agent {
  align-self: flex-start;
  background: #e9fff4;
  color: #352a44;
}

.boss-chat-form {
  display: grid;
  gap: 0.5rem;
  padding: 0.85rem;
  border-top: 1px solid rgba(53, 42, 68, 0.12);
  background: #ffffff;
  flex-shrink: 0;
}

.boss-chat-form input,
.boss-chat-form textarea {
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: #faf2ea;
  color: inherit;
  font: inherit;
  font-size: 1rem;
  padding: 0.7rem 0.8rem;
}

.boss-chat-form textarea {
  min-height: 72px;
  resize: vertical;
}

.boss-chat-form button[type="submit"] {
  justify-self: end;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 80px;
  background: #352a44;
  color: #fafaf7;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.boss-chat-error {
  margin: 0;
  color: #8c3a3a;
  font-size: 0.8rem;
}

.boss-chat-error:empty {
  display: none;
}

@media (max-width: 1099px) and (min-width: 768px) {
  .boss-chat {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .boss-chat-panel {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(80px, calc(16px + env(safe-area-inset-bottom) + 64px));
    width: min(380px, calc(100vw - 32px));
    height: min(520px, calc(100dvh - 130px));
  }
}

@media (max-width: 767px) {
  .boss-chat {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .boss-chat-toggle {
    width: 52px;
    min-width: 52px;
    min-height: 52px;
    padding: 0;
    border-radius: 50%;
  }

  .boss-chat-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .boss-chat-panel {
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
    bottom: max(72px, calc(12px + env(safe-area-inset-bottom) + 58px));
    width: auto;
    height: min(70dvh, 560px);
    border-radius: 20px;
  }

  .boss-chat-form button[type="submit"] {
    justify-self: stretch;
    width: 100%;
  }
}
