.site-footer .ch-support-open {
  display: block;
  margin-top: 10px;
}
.site-footer .ch-support-open[hidden] { display: none; }

.ch-support-launcher:not([hidden]) {
  position: fixed;
  z-index: 950;
  right: max(24px, env(safe-area-inset-right));
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + var(--ch-support-cookie-height, 0px));
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #064e3c;
  color: white;
  box-shadow: 0 5px 18px #003e3033;
  cursor: pointer;
}

.ch-support-launcher:focus-visible { outline: 2px solid #427b62; outline-offset: 3px; }

.ch-support-badge:not([hidden]) {
  position: absolute;
  top: -3px;
  right: -3px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border: 2px solid white;
  border-radius: 999px;
  background: #c22132;
  color: white;
  font: 700 11px/1 system-ui, sans-serif;
}

#ch-support {
  box-sizing: border-box;
  position: fixed;
  inset: auto 24px 24px auto;
  width: min(410px, calc(100% - 48px));
  height: min(510px, calc(100dvh - 48px));
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: #18352a;
  box-shadow: 0 12px 42px #003e3029;
}

#ch-support::backdrop { background: #102c2514; }
#ch-support [hidden] { display: none !important; }

.ch-support-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#ch-support .ch-support-header {
  position: static;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 8px 18px;
  border: 0;
  background: #064e3c;
  color: white;
}

#ch-support h2 { margin: 0; color: inherit; font-size: 17px; }
#ch-support button { cursor: pointer; font: inherit; }
#ch-support button:disabled { cursor: default; opacity: .48; }
#ch-support :focus-visible { outline: 2px solid #427b62; outline-offset: 2px; }
#ch-support .ch-support-header :focus-visible { outline-color: white; }

#ch-support [data-support-history] {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
}

.ch-support-message {
  width: fit-content;
  max-width: 85%;
  box-sizing: border-box;
  margin: 0 auto 10px 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #e7efe8;
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ch-support-message.is-visitor {
  margin: 0 0 10px auto;
  background: #064e3c;
  color: #fff;
}

.ch-support-message img { display: block; max-width: 100%; max-height: 230px; border-radius: 6px; }
.ch-support-message span + img { margin-top: 8px; }
.ch-support-message time { display: block; margin-top: 5px; font-size: 11px; opacity: .85; }
#ch-support [data-support-status] { margin: 0; padding: 0 16px 8px; font-size: 13px; }
#ch-support [data-support-form] { padding: 10px 12px 12px; border-top: 1px solid #e4eae6; }
#ch-support [data-support-preview] { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#ch-support [data-support-thumbnail] { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
#ch-support [data-support-remove] { min-height: 40px; border: 0; background: none; color: #064e3c; text-decoration: underline; }

.ch-support-composer { display: flex; align-items: flex-end; gap: 8px; }
.ch-support-composer textarea {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 112px;
  padding: 11px 12px;
  border: 1px solid #bfcac3;
  border-radius: 16px;
  background: white;
  color: inherit;
  font: inherit;
  font-size: 16px;
  resize: none;
}

#ch-support [data-support-attach],
#ch-support [data-support-send],
#ch-support [data-support-close] {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e7efe8;
  color: #064e3c;
}

#ch-support [data-support-attach] { font-size: 25px; }
#ch-support [data-support-close] { background: transparent; color: white; font-size: 28px; }
#ch-support [data-support-send] { background: #064e3c; color: white; }

@media (max-width: 520px) {
  .ch-support-launcher:not([hidden]) {
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--ch-support-cookie-height, 0px));
  }

  #ch-support {
    inset: auto 8px 8px;
    width: calc(100% - 16px);
    height: min(510px, calc(100dvh - 16px));
  }
}
