.hh-chat {
  --chat-ink: #251c17;
  --chat-paper: #fffaf2;
  --chat-brown: #603e2a;
  --chat-border: #ddcdbb;
  --chat-gap: clamp(12px, 3vw, 24px);
  position: fixed;
  right: calc(var(--chat-gap) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--chat-gap) + max(env(safe-area-inset-bottom, 0px), var(--chat-viewport-bottom, 0px)));
  z-index: 999;
  color: var(--chat-ink);
  font: 16px/1.45 Arial, Helvetica, sans-serif;
  text-align: left;
}

.hh-chat *, .hh-chat *::before, .hh-chat *::after {
  box-sizing: border-box;
}

.hh-chat button {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--chat-brown);
  color: #fff;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

.hh-chat button:hover {
  background: var(--chat-ink);
}

.hh-chat button[aria-disabled="true"] {
  opacity: .7;
  cursor: wait;
}

.hh-chat :focus-visible {
  outline: 3px solid #a26528;
  outline-offset: 2px;
}

.hh-chat .hh-chat-launch {
  padding: 10px 18px;
  border: 1px solid #b98a53;
  border-radius: 999px;
  box-shadow: 0 4px 16px #251c1740;
}

.hh-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 2 * var(--chat-gap) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  height: min(440px, calc(100vh - 2 * var(--chat-gap) - 60px));
  height: min(440px, calc(100dvh - 2 * var(--chat-gap) - 60px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px)));
  max-height: calc(var(--chat-viewport-height, 100vh) - 2 * var(--chat-gap) - 60px);
  overflow: auto;
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  background: var(--chat-paper);
  box-shadow: 0 12px 32px #251c1740;
}

.hh-chat-panel[hidden] {
  display: none;
}

.hh-chat-heading {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 14px;
  background: var(--chat-ink);
  color: var(--chat-paper);
}

.hh-chat-heading h2 {
  margin: 0;
  color: inherit;
  font: bold 1.2rem Georgia, serif;
}

.hh-chat .hh-chat-close {
  min-width: 44px;
  padding: 0;
  background: transparent;
  font-size: 1.65rem;
}

.hh-chat-close:focus-visible {
  outline-color: #edbe7a;
  outline-offset: -4px;
}

.hh-chat-log {
  flex: 1 0 72px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
}

.hh-chat-log:focus-visible {
  outline-offset: -3px;
}

.hh-chat-log p {
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #f1e8db;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.hh-chat-log p:last-child {
  margin-bottom: 0;
}

.hh-chat-log strong {
  display: block;
  margin-bottom: 3px;
  font-size: .85rem;
}

.hh-chat-log .hh-chat-customer {
  margin-left: 20px;
  background: #e8d6c2;
}

.hh-chat-privacy {
  flex: none;
  margin: 0;
  padding: 6px 12px 8px;
  font-size: .8125rem;
}

.hh-chat-status {
  padding: 0 12px;
  font-size: .875rem;
  font-weight: bold;
}

.hh-chat-status:not(:empty) {
  padding-bottom: 8px;
}

.hh-chat-form {
  flex: none;
  margin: 0;
  padding: 9px 12px 12px;
  border-top: 1px solid var(--chat-border);
}

.hh-chat-form label {
  display: block;
  margin: 0 0 4px;
  font-size: .875rem;
  font-weight: bold;
}

.hh-chat-compose {
  display: flex;
  gap: 8px;
}

.hh-chat-compose input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  border: 1px solid #8d7765;
  border-radius: 8px;
  background: #fff;
  color: var(--chat-ink);
  font: inherit;
}
