.product-chat {
  --chat-bottom: max(20px, env(safe-area-inset-bottom));
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: var(--chat-bottom);
  z-index: 60;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear 0s;
}
.product-chat.footer-hidden { opacity: 0; transform: translateY(20px); visibility: hidden; pointer-events: none; transition-delay: 0s, 0s, .22s; }
.product-chat [hidden], .product-chat[hidden] { display: none !important; }
body.locked .product-chat { visibility: hidden; }
.product-chat-launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.product-chat-launcher:hover, .product-chat-form button:not(:disabled):hover { background: var(--accent-dark); }
.product-chat-panel {
  display: flex;
  flex-direction: column;
  width: min(370px, calc(100vw - 40px));
  height: 540px;
  max-height: calc(100vh - var(--chat-bottom) - 84px);
  max-height: calc(100dvh - var(--chat-bottom) - 84px);
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(48, 37, 31, .08);
}
.product-chat-header { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.product-chat-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 800; flex-shrink: 0; }
.product-chat-header h2 { font-size: 15px; line-height: 1.3; letter-spacing: -.02em; }
.product-chat-header p { margin: 3px 0 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.product-chat-close { align-self: flex-start; flex-shrink: 0; margin: -6px -8px 0 auto; width: 40px; height: 40px; border: 0; border-radius: 4px; background: transparent; color: var(--text); font-size: 26px; cursor: pointer; }
.product-chat-close:hover { background: var(--bg); }
.product-chat-messages { flex: 1; min-height: 64px; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.product-chat-message { max-width: 94%; margin: 0 0 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.product-chat-message:last-child { margin-bottom: 0; }
.product-chat-message--user { margin-left: auto; background: var(--accent-soft); border-color: transparent; }
.product-chat-message p { margin: 0; white-space: pre-line; }
.product-chat-message a { display: inline-block; margin-top: 9px; color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.product-chat-topics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line); flex-shrink: 0; }
.product-chat-topics button { min-height: 36px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--text); font-size: 12px; text-align: left; cursor: pointer; }
.product-chat-topics button:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--bg); }
.product-chat-form { display: flex; align-items: stretch; gap: 8px; padding: 6px 16px 0; flex-shrink: 0; }
.product-chat-form input { flex: 1; min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 10px; font-size: 16px; color: var(--text); background: #fff; }
.product-chat-form button { flex-shrink: 0; display: grid; place-items: center; width: 44px; min-height: 44px; border: 0; border-radius: 4px; background: var(--accent); color: #fff; cursor: pointer; }
.product-chat-form button:disabled { opacity: .45; cursor: default; }
.product-chat-note { margin: 9px 16px 12px; color: var(--muted); font-size: 10px; line-height: 1.4; flex-shrink: 0; }
.product-chat-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 1100px) {
  body:has(.sticky-buy.visible) .product-chat { --chat-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 620px) {
  .product-chat { --chat-bottom: max(12px, env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right)); }
  .product-chat-panel { width: calc(100vw - 24px); }
  .product-chat-launcher { min-height: 44px; padding: 10px 13px; }
  .product-chat-topics { grid-template-columns: repeat(3, 1fr); padding: 8px 12px; }
  .product-chat-topics button { font-size: 11px; }
}
@media (max-height: 540px) {
  .product-chat:has(.product-chat-panel:not([hidden])) { --chat-bottom: 8px !important; }
  .product-chat-panel { height: calc(100dvh - 80px); max-height: calc(100dvh - 80px); }
  .product-chat-topics { display: flex; overflow-x: auto; }
  .product-chat-topics button { flex-shrink: 0; }
  .product-chat-header { padding-top: 10px; padding-bottom: 10px; }
  .product-chat-note { display: none; }
}
