.catalog-chat {
  --chat-accent: #245acb;
  --chat-ink: #192e55;
  --chat-edge: max(18px, env(safe-area-inset-right));
  --chat-bottom: max(18px, env(safe-area-inset-bottom));
  position: fixed;
  right: var(--chat-edge);
  bottom: var(--chat-bottom);
  z-index: 1040;
  color: var(--chat-ink);
  font: 400 15px/1.55 system-ui, sans-serif;
}
.catalog-chat [hidden] { display: none !important; }
.catalog-chat button { font: inherit; cursor: pointer; }
.catalog-chat button:focus-visible,
.catalog-chat a:focus-visible,
.catalog-chat input:focus-visible { outline: 2px solid #3874ff; outline-offset: 3px; }

.catalog-chat .catalog-chat-launcher {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--chat-accent);
  box-shadow: 0 6px 22px #183e8a40;
}
.catalog-chat-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 29px;
  height: 22px;
  border: 2px solid currentColor;
  border-radius: 9px;
  font: 700 11px/1 system-ui, sans-serif;
  letter-spacing: 1px;
}
.catalog-chat-icon::after {
  position: absolute;
  bottom: -4px;
  left: 5px;
  width: 5px;
  height: 5px;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  background: var(--chat-accent);
  transform: skewY(-32deg);
  content: '';
}

.catalog-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(380px, calc(100vw - var(--chat-edge) - max(12px, env(safe-area-inset-left))));
  height: min(510px, calc(100vh - var(--chat-bottom) - 12px));
  height: min(510px, calc(100dvh - var(--chat-bottom) - 12px));
  overflow: hidden;
  border: 1px solid #cddbf3;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 14px 55px #18356438;
}
.catalog-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--chat-accent);
  color: white;
}
.catalog-chat-header h2 { flex: 1; margin: 0; color: inherit; font: 700 16px/1.4 system-ui, sans-serif; }
.catalog-chat-avatar { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #ffffff55; border-radius: 12px; }
.catalog-chat-avatar .catalog-chat-icon { transform: scale(.72); }
.catalog-chat .catalog-chat-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #ffffff20;
  color: white;
  font-size: 24px;
}
.catalog-chat-close:focus-visible { outline-color: white !important; }

.catalog-chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background: #f1f5ff;
}
.catalog-chat-bubble {
  align-self: flex-start;
  max-width: 89%;
  margin: 0;
  padding: 10px 13px;
  border-radius: 4px 14px 14px 14px;
  background: white;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.catalog-chat-bubble--customer {
  align-self: flex-end;
  border-radius: 14px 4px 14px 14px;
  background: var(--chat-accent);
  color: white;
}
.catalog-chat-results { display: grid; gap: 6px; padding: 0; margin: 0; list-style: none; }
.catalog-chat-results a {
  display: block;
  padding: 8px 12px;
  border: 1px solid #d4e1fa;
  border-radius: 10px;
  background: white;
  color: #214fa9;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.catalog-chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #dae4f7; }
.catalog-chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #a1b5dc;
  border-radius: 10px;
  background: white;
  color: var(--chat-ink);
  font: inherit;
  font-size: 16px;
}
.catalog-chat-form button {
  min-width: 54px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--chat-accent);
  color: white;
}
.catalog-chat-form button:disabled { opacity: .6; cursor: wait; }
