.support-chat {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 100;
}

.support-chat__fab {
  align-items: center;
  background: var(--bbc-blue);
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(0, 128, 255, 0.4);
  color: #fff;
  cursor: pointer;
  display: flex;
  height: 56px;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  width: 56px;
  -webkit-tap-highlight-color: transparent;
}

.support-chat__fab:hover {
  background: #0066cc;
  box-shadow: 0 6px 24px rgba(0, 128, 255, 0.5);
}

.support-chat__fab:active {
  transform: scale(0.96);
}

.support-chat__fab svg {
  display: block;
  height: 28px;
  width: 28px;
}

.support-chat--open .support-chat__fab {
  display: none;
}

.support-chat__panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 13, 43, 0.18);
  display: flex;
  flex-direction: column;
  height: min(520px, calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow: hidden;
  width: min(360px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
}

.support-chat__panel[hidden] {
  display: none !important;
}

.support-chat__head {
  background: var(--bbc-blue);
  color: #fff;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 18px 16px 14px;
}

.support-chat__head strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.support-chat__head span {
  display: block;
  font-size: 0.82rem;
  line-height: 1.35;
  margin-top: 4px;
  opacity: 0.95;
}

.support-chat__close {
  align-items: center;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  font-size: 1.6rem;
  height: 32px;
  justify-content: center;
  line-height: 1;
  opacity: 0.9;
  padding: 0;
  width: 32px;
  -webkit-tap-highlight-color: transparent;
}

.support-chat__close:hover {
  opacity: 1;
}

.support-chat__status {
  align-items: center;
  background: #0066cc;
  color: #fff;
  display: flex;
  font-size: 0.78rem;
  gap: 8px;
  padding: 8px 16px;
}

.support-chat__online {
  background: #4caf50;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  height: 8px;
  width: 8px;
}

.support-chat__messages {
  background: #fff;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
}

.support-chat__msg {
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 85%;
  padding: 10px 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.support-chat__msg--agent {
  align-self: flex-start;
  background: #f3f5f6;
  color: var(--bbc-navy);
}

.support-chat__msg--user {
  align-self: flex-end;
  background: var(--bbc-blue);
  color: #fff;
}

.support-chat__msg-text {
  margin: 0;
}

.support-chat__msg-text + .support-chat__msg-image {
  margin-top: 8px;
}

.support-chat__msg-image {
  border-radius: 8px;
  display: block;
  max-height: 180px;
  max-width: 100%;
  object-fit: cover;
}

.support-chat__composer {
  border-top: 1px solid var(--bbc-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.support-chat__preview {
  align-items: center;
  background: #f8fafb;
  border-bottom: 1px solid var(--bbc-border);
  display: flex;
  gap: 10px;
  padding: 10px 12px;
}

.support-chat__preview[hidden] {
  display: none !important;
}

.support-chat__preview-img {
  border-radius: 8px;
  height: 56px;
  object-fit: cover;
  width: 56px;
}

.support-chat__preview-remove {
  align-items: center;
  background: #fff;
  border: 1px solid var(--bbc-border);
  border-radius: 50%;
  color: var(--bbc-muted);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  font-size: 1.1rem;
  height: 28px;
  justify-content: center;
  line-height: 1;
  margin-left: auto;
  padding: 0;
  width: 28px;
}

.support-chat__preview-remove:hover {
  border-color: var(--bbc-blue);
  color: var(--bbc-blue);
}

.support-chat__form {
  align-items: center;
  display: flex;
  gap: 8px;
  padding: 12px;
}

.support-chat__attach {
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--bbc-muted);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 36px;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  width: 36px;
  -webkit-tap-highlight-color: transparent;
}

.support-chat__attach:hover {
  background: #f3f5f6;
  color: var(--bbc-blue);
}

.support-chat__attach svg {
  display: block;
  height: 20px;
  width: 20px;
}

.support-chat__input {
  border: 1px solid var(--bbc-border);
  border-radius: 999px;
  flex: 1;
  font: inherit;
  font-size: 16px;
  min-width: 0;
  outline: none;
  padding: 10px 16px;
}

.support-chat__input:focus {
  border-color: var(--bbc-blue);
  box-shadow: 0 0 0 2px rgba(0, 128, 255, 0.15);
}

.support-chat__send {
  align-items: center;
  background: var(--bbc-blue);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 40px;
  justify-content: center;
  transition: background 0.15s ease;
  width: 40px;
  -webkit-tap-highlight-color: transparent;
}

.support-chat__send:hover {
  background: #0066cc;
}

.support-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.support-chat__send svg {
  display: block;
  height: 18px;
  width: 18px;
}

@media (max-width: 640px) {
  .support-chat {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
  }

  .support-chat--open {
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
  }

  .support-chat--open .support-chat__panel {
    border-radius: 0;
    box-shadow: none;
    height: 100dvh;
    max-height: 100dvh;
    width: 100%;
  }

  .support-chat--open .support-chat__head {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }

  .support-chat__panel {
    height: min(480px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    width: min(340px, calc(100vw - 20px));
  }

  .support-chat__head strong {
    font-size: 0.98rem;
  }

  .support-chat__head span {
    font-size: 0.78rem;
  }

  .support-chat__msg {
    font-size: 0.86rem;
    max-width: 88%;
  }
}
