/* Message us button (app/chat_widget.py, store/_extras.html). Works on the
   core theme and every code theme, so it brings its own small reset and
   inherits only the page's font. static/chat.js sets --sfx-chat-lift (px)
   to clear bottom bars and adds .is-covered under drawers and dialogs. */
.sfx-chat {
  --sfx-chat-gap: 18px;
  position: fixed; z-index: 90;
  bottom: calc(var(--sfx-chat-gap) + var(--sfx-chat-lift, 0px) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column-reverse; gap: 12px;
  font-family: inherit; line-height: 1.4; color: #1b1b1b;
  transition: bottom .3s ease, opacity .2s ease;
}
.sfx-chat--right { right: var(--sfx-chat-gap); align-items: flex-end; }
.sfx-chat--left { left: var(--sfx-chat-gap); align-items: flex-start; }
.sfx-chat.is-covered { opacity: 0; pointer-events: none; visibility: hidden; }
.sfx-chat *, .sfx-chat *::before, .sfx-chat *::after { box-sizing: border-box; }
.sfx-chat svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }

.sfx-chat__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; min-width: 52px; margin: 0; padding: 0 20px 0 16px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--sfx-chat-bg, #1f2937); color: var(--sfx-chat-fg, #fff);
  font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1; letter-spacing: 0; text-transform: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 12px 30px -12px rgba(0, 0, 0, .55);
  transition: transform .2s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.sfx-chat__btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.sfx-chat__btn:focus-visible { outline: 3px solid var(--sfx-chat-bg, #1f2937); outline-offset: 3px; }
.sfx-chat__icx { display: none; }
.sfx-chat.is-open .sfx-chat__btn { padding: 0; width: 52px; }
.sfx-chat.is-open .sfx-chat__label, .sfx-chat.is-open .sfx-chat__ic { display: none; }
.sfx-chat.is-open .sfx-chat__icx { display: block; }

.sfx-chat__panel {
  width: min(360px, calc(100vw - 28px));
  max-height: calc(100vh - 110px - var(--sfx-chat-lift, 0px));
  max-height: calc(100dvh - 110px - var(--sfx-chat-lift, 0px));
  overflow: auto; overscroll-behavior: contain;
  padding: 20px; border-radius: 16px; background: #fff; color: #1b1b1b;
  border: 1px solid rgba(0, 0, 0, .1); box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .5);
  text-align: left;
}
.sfx-chat__panel[hidden] { display: none; }
.sfx-chat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sfx-chat__h { margin: 0 0 4px; font-family: inherit; font-size: 19px; font-weight: 700; line-height: 1.2; color: #111; letter-spacing: 0; text-transform: none; }
.sfx-chat__intro { margin: 0; color: #555; font-size: 15px; }
.sfx-chat__x {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background: #f1f1f1; color: #111; cursor: pointer;
}
.sfx-chat__x svg { width: 18px; height: 18px; }
.sfx-chat__field { display: block; margin: 0 0 12px; }
.sfx-chat__field > span { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 600; color: #222; }
.sfx-chat__field em { font-style: normal; font-weight: 400; color: #666; }
.sfx-chat__field input, .sfx-chat__field textarea {
  display: block; width: 100%; margin: 0; padding: 10px 12px;
  border: 1px solid #c9c9c9; border-radius: 10px; background: #fff; color: #111;
  font-family: inherit; font-size: 16px; line-height: 1.4;   /* 16px: no iOS zoom on focus */
}
.sfx-chat__field textarea { min-height: 96px; resize: vertical; }
.sfx-chat__field input:focus, .sfx-chat__field textarea:focus {
  outline: 2px solid var(--sfx-chat-bg, #1f2937); outline-offset: 1px; border-color: transparent;
}
.sfx-chat__hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.sfx-chat__err { margin: 0 0 12px; color: #b42318; font-size: 14px; font-weight: 600; }
.sfx-chat__err[hidden], .sfx-chat__done[hidden], .sfx-chat__form[hidden] { display: none; }
.sfx-chat__send {
  display: block; width: 100%; min-height: 48px; margin: 0; padding: 0 16px;
  border: 0; border-radius: 10px; cursor: pointer;
  background: var(--sfx-chat-bg, #1f2937); color: var(--sfx-chat-fg, #fff);
  font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1; text-transform: none; letter-spacing: 0;
}
.sfx-chat__send:disabled { opacity: .7; cursor: default; }
.sfx-chat__wa { display: block; margin-top: 12px; text-align: center; color: #117a43; font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.sfx-chat__done { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0 4px; color: #117a43; }
.sfx-chat__done svg { width: 28px; height: 28px; }
.sfx-chat__done p { margin: 0; color: #1b1b1b; font-size: 15px; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .sfx-chat { --sfx-chat-gap: 14px; }
  /* phones: a round icon only, so it never sits over half a line of text */
  .sfx-chat__btn { padding: 0; width: 52px; }
  .sfx-chat__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .sfx-chat, .sfx-chat__btn { transition: none; } }
