.songde-chat {
  --chat-ink: #432d24;
  --chat-muted: #6c5648;
  --chat-border: #eadbce;
  --chat-surface: #fffaf5;
  --chat-header: #684437;
  --chat-accent: #98492f;
  --chat-bottom: 19px;
  position: fixed;
  right: max(19px, env(safe-area-inset-right));
  bottom: calc(var(--chat-bottom) + env(safe-area-inset-bottom));
  z-index: 24;
  color: var(--chat-ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.songde-chat--with-line {
  --chat-bottom: 94px;
}

@media (min-width: 768px) {
  html[lang="zh-CN"] .page-index .songde-chat {
    right: auto;
    left: max(19px, env(safe-area-inset-left));
  }

  html[lang="zh-CN"] .page-index .songde-chat__panel {
    right: auto;
    left: 0;
  }
}

@media (max-width: 767px) {
  html[lang="zh-CN"] .page-index .songde-chat {
    --chat-bottom: 72px;
  }
}

.songde-chat,
.songde-chat * {
  box-sizing: border-box;
}

.songde-chat [hidden],
.songde-chat[hidden] {
  display: none !important;
}

.songde-chat button,
.songde-chat input {
  margin: 0;
  font-family: inherit;
  line-height: inherit;
}

.songde-chat :where(button, a, input, [tabindex]):focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: 3px;
}

.songde-chat__launcher {
  display: flex;
  min-height: 49px;
  align-items: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid #805035;
  border-radius: 30px;
  background: #5e3a2b;
  color: #fffaf4;
  box-shadow: 0 6px 20px #3d241c35;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.songde-chat__launcher:hover {
  background: #73482f;
}

.songde-chat__bubble-icon {
  position: relative;
  display: inline-block;
  width: 17px;
  height: 13px;
  flex: none;
  border: 1.5px solid currentColor;
  border-radius: 5px;
}

.songde-chat__bubble-icon::after {
  position: absolute;
  bottom: -4px;
  left: 3px;
  width: 5px;
  height: 5px;
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  background: inherit;
  content: '';
  transform: skewY(-36deg);
}

.songde-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 11px);
  display: flex;
  width: min(386px, calc(100vw - max(19px, env(safe-area-inset-right)) - max(12px, env(safe-area-inset-left))));
  height: 532px;
  max-height: calc(100vh - var(--chat-bottom) - 74px - env(safe-area-inset-bottom));
  max-height: calc(100dvh - var(--chat-bottom) - 74px - env(safe-area-inset-bottom));
  flex-direction: column;
  overflow: auto;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  background: var(--chat-surface);
  box-shadow: 0 16px 44px #3d271d30;
  overscroll-behavior: contain;
}

.songde-chat__header {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 42px;
  min-height: 62px;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 8px 11px 8px 15px;
  background: var(--chat-header);
}

.songde-chat__emblem {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: #815948;
  color: #fff9ed;
}

.songde-chat__emblem .songde-chat__bubble-icon {
  background: #815948;
}

.songde-chat__launcher .songde-chat__bubble-icon {
  background: #5e3a2b;
}

.songde-chat__launcher:hover .songde-chat__bubble-icon {
  background: #73482f;
}

.songde-chat .songde-chat__title {
  min-width: 0;
  margin: 0;
  color: #fffaf4;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
  writing-mode: horizontal-tb;
}

.songde-chat .songde-chat__close {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #fffaf4;
  font-size: 25px;
  font-weight: 400;
  cursor: pointer;
}

.songde-chat .songde-chat__close:hover {
  background: #ffffff24;
}

.songde-chat__header :where(button, [tabindex]):focus-visible {
  outline-color: #fff5e9;
}

.songde-chat__messages {
  display: flex;
  min-height: 76px;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 13px;
  overflow: auto;
  padding: 16px;
  background: #faf6f0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.songde-chat__messages:focus-visible {
  outline-offset: -3px;
}

.songde-chat__message {
  max-width: 92%;
  flex: none;
  align-self: flex-start;
  padding: 10px 13px;
  border: 1px solid #e9dbcf;
  border-radius: 16px 16px 16px 5px;
  background: #f2e9df;
  overflow-wrap: anywhere;
}

.songde-chat__message--visitor {
  max-width: 86%;
  align-self: flex-end;
  border-color: var(--chat-accent);
  border-radius: 16px 16px 5px;
  background: var(--chat-accent);
  color: #fffaf4;
}

.songde-chat__message p {
  margin: 0;
  color: inherit;
  line-height: 1.6;
  white-space: pre-line;
}

.songde-chat__message--pending {
  color: var(--chat-muted);
}

.songde-chat__typing {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
}

.songde-chat__typing > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: songde-chat-dot 1.2s ease-in-out infinite;
}

.songde-chat__typing > span:nth-child(2) {
  animation-delay: .15s;
}

.songde-chat__typing > span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes songde-chat-dot {
  0%, 60%, 100% { opacity: .45; }
  30% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .songde-chat__typing > span {
    animation: none;
  }
}

.songde-chat__message-source {
  display: block;
  margin-top: 6px;
  color: var(--chat-muted);
  font-size: 11px;
}

.songde-chat__message-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  margin-top: 8px;
}

.songde-chat__retry,
.songde-chat__contacts a {
  color: #8d3f24;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.songde-chat__message-links a {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid #ecdac9;
  border-radius: 7px;
  background: #fff8ee;
  color: #803d28;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.songde-chat__message-links a:hover {
  border-color: #c58e6d;
  background: #f9ebdc;
}

.songde-chat__retry {
  padding: 2px 0;
  border: 0;
  background: transparent;
  font-size: inherit;
  cursor: pointer;
}

.songde-chat__actions {
  flex: none;
  padding: 12px 14px 8px;
  border-top: 1px solid var(--chat-border);
}

.songde-chat__questions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-self: flex-start;
  gap: 6px 7px;
}

.songde-chat__question {
  min-height: 36px;
  max-width: 100%;
  padding: 5px 11px;
  border: 1px solid #e2cdbc;
  border-radius: 18px;
  background: #fffdfa;
  color: #77422c;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.songde-chat__question:not(:disabled):hover {
  border-color: #c78c67;
  background: #f8eadc;
}

.songde-chat__form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.songde-chat__form input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #dfcabc;
  border-radius: 24px;
  background: #fffefa;
  color: var(--chat-ink);
  font-size: 16px;
}

.songde-chat__form input::placeholder {
  color: var(--chat-muted);
  font-size: 13px;
}

.songde-chat__send {
  min-width: 60px;
  min-height: 44px;
  flex: none;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 24px;
  background: var(--chat-accent);
  color: #fffaf5;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.songde-chat__send:not(:disabled):hover {
  background: #8d3f24;
}

.songde-chat__send:disabled {
  background: #eadcd0;
  color: #685144;
  cursor: default;
}

.songde-chat__form[aria-busy="true"] .songde-chat__send,
.songde-chat__question:disabled {
  cursor: wait;
}

.songde-chat__privacy {
  margin: 5px 0 0;
  color: var(--chat-muted);
  font-size: 11px;
}

.songde-chat__contacts {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 5px 10px;
  padding: 6px 13px 8px;
  border-top: 1px solid var(--chat-border);
  background: #fcf2e7;
  font-size: 12px;
}

.songde-chat__contacts a {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
}

.songde-chat__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .songde-chat__question {
    min-height: 40px;
  }

  .songde-chat__header {
    min-height: 57px;
  }

  .songde-chat__contacts {
    padding-block: 4px;
  }
}
