.chat-panel:has(> .desktop-chat) {
  padding-block-start: 8px;
}

.chat-panel > .desktop-chat {
  margin-block-start: 0;
}

#chat-history {
  position: relative;
  display: flex;
  flex-direction: column;
  min-block-size: 0;
}

#chat-history #chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgb(39 79 63 / 34%) transparent;
}

#chat-history #chat-messages:focus-visible {
  outline: 2px solid #527e6d;
  outline-offset: -2px;
}

#chat-to-latest {
  position: absolute;
  z-index: 1;
  inset-inline-end: 15px;
  inset-block-end: 10px;
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 1px solid #9fbcaf;
  border-radius: 50%;
  background: #f7fbf8;
  color: #26594a;
  box-shadow: 0 2px 7px rgb(21 60 56 / 14%);
}

#chat-to-latest:hover {
  background: #e9f5ee;
}

#chat-to-latest[hidden] {
  display: none;
}

@media (min-width: 800px) {
  html:has(#sections:not([hidden])) {
    scrollbar-gutter: stable;
  }

  .desktop-chat #chat-history {
    flex: 1 1 0;
  }
}

@media (max-width: 650px) {
  html:is(.chat-menu-hidden, .chat-keyboard-open) #chat-conversation #chat-history {
    flex: 1 1 0;
  }
}

@supports not (scrollbar-color: auto) {
  #chat-messages::-webkit-scrollbar {
    width: 7px;
  }

  #chat-messages::-webkit-scrollbar-track {
    background: transparent;
  }

  #chat-messages::-webkit-scrollbar-thumb {
    border-radius: 7px;
    background: rgb(39 79 63 / 34%);
  }
}
