#chat { position: relative; }
#chat-unread:empty { display: none; }
body:has(#panel[open] .support-chat) #chat { color: #53e0ce; }

.support-chat {
  display: grid;
  grid-template-columns: minmax(270px, 31fr) minmax(0, 69fr);
  gap: 16px;
  width: min(calc(100% - 48px), 1250px);
  height: clamp(480px, calc(100dvh - 216px), 920px);
  margin: 20px auto 24px;
}
.chat-sidebar, .chat-pane {
  min-width: 0;
  min-height: 0;
  border: 1px solid #dce8e1;
  border-radius: 14px;
  background: #fff;
}
.chat-sidebar { display: flex; flex-direction: column; overflow: hidden; }
.chat-sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid #e7eee9;
}
.chat-sidebar-heading h3, .chat-thread-heading h3 { margin: 0; font-size: 16px; }
.chat-sidebar-heading .textbtn {
  padding: 7px 9px;
  border-radius: 7px;
  background: #eaf5ee;
}
.chat-sidebar-heading .textbtn:hover { background: #d9eee1; }
.chat-sidebar-scroll { min-height: 0; overflow-y: auto; }
.chat-list-status { margin: 16px; }
.support-chat [role="status"]:empty { display: none; }
.chat-more { margin: 12px 16px 16px; }
.chat-group-title {
  margin: 0;
  padding: 11px 16px;
  background: #f0f5f2;
  color: #476358;
  font-size: 12px;
  letter-spacing: .025em;
  text-transform: uppercase;
}
.chat-threads { list-style: none; margin: 0; padding: 0; }
.chat-thread {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 70px;
  padding: 12px 14px;
  border: 0;
  border-inline-start: 3px solid transparent;
  border-bottom: 1px solid #e7eee9;
  background: #fff;
  color: var(--ink);
  text-align: start;
}
.chat-thread:hover, .chat-thread[aria-current] { background: #eef8f2; }
.chat-thread[aria-current] { border-inline-start-color: var(--green); }
.chat-thread:focus-visible { outline-offset: -3px; }
.chat-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #d9eee5;
  color: #245c40;
  font-size: 17px;
  font-weight: 800;
}
.chat-thread-copy { display: grid; gap: 3px; min-width: 0; }
.chat-thread-copy strong, .chat-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-snippet, .chat-thread-meta { color: #496159; font-size: 12px; }
.chat-thread-meta { display: grid; justify-items: end; align-self: start; gap: 5px; }
.chat-thread-meta > :empty { display: none; }
.chat-count {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 12px;
  background: #256f47;
  color: white;
  text-align: center;
  font-weight: 700;
}

.chat-pane { overflow: hidden; }
.chat-idle {
  display: grid;
  align-content: center;
  justify-items: center;
  height: 100%;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse at center, #f1f9f4, #fbfdfb 70%);
}
.chat-idle h3 { margin: 22px 0 5px; font-size: clamp(18px, 2vw, 24px); }
.chat-idle p { margin: 0; color: #496159; }
.chat-idle-mark {
  position: relative;
  width: 112px;
  height: 86px;
}
.chat-idle-mark::before, .chat-idle-mark span {
  position: absolute;
  width: 75px;
  height: 54px;
  border-radius: 21px 21px 21px 6px;
}
.chat-idle-mark::before {
  content: "";
  inset: auto 0 5px auto;
  background: #b4ddc9;
  transform: rotate(10deg);
}
.chat-idle-mark span {
  inset: 4px auto auto 4px;
  background: #24704a;
  transform: rotate(-8deg);
}
.chat-idle-mark span::after {
  content: "";
  position: absolute;
  top: 23px;
  left: 21px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 13px 0 #fff, 26px 0 #fff;
}

.chat-conversation { display: flex; flex-direction: column; height: 100%; }
.chat-thread-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid #e7eee9;
  overflow-wrap: anywhere;
}
.chat-back { display: none; }
.chat-history {
  flex: 1;
  min-height: 0;
  padding: 16px 18px;
  overflow-y: auto;
  overflow-anchor: none;
  background: #f7faf8;
}
.chat-log { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.chat-log:empty { min-height: 1px; }
.chat-history > button { display: block; margin: 0 auto 12px; }
.chat-message {
  width: fit-content;
  max-width: min(90%, 620px);
  padding: 9px 13px;
  border: 1px solid #dce8e1;
  border-radius: 12px 12px 12px 4px;
  background: #fff;
}
.chat-outgoing {
  align-self: flex-end;
  border-radius: 12px 12px 4px 12px;
  background: #e0f1e7;
}
.chat-message-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: #496159; }
.chat-message-meta span { font-weight: 700; }
.chat-message p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-status { margin: 8px 18px 0; }
.chat-compose { display: flex; align-items: end; gap: 10px; padding: 12px 18px; }
.chat-compose label { flex: 1; min-width: 0; }
.chat-compose textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 160px;
  padding: 10px 12px;
  resize: vertical;
  background: #fff;
  color: var(--ink);
  border: 1px solid #9db3a6;
  border-radius: 8px;
}
.chat-compose button:disabled { opacity: .65; }

@media (max-width: 700px) {
  .support-chat {
    display: block;
    width: calc(100% - 24px);
    height: clamp(360px, calc(100dvh - 294px), 800px);
    margin: 12px auto 20px;
  }
  .chat-sidebar, .chat-pane { height: 100%; }
  .support-chat:not(.chat-thread-visible) .chat-pane,
  .chat-thread-visible .chat-sidebar { display: none; }
  .chat-back { display: inline-flex; flex-shrink: 0; padding: 7px 0; }
  .chat-thread-heading, .chat-history, .chat-compose { padding-inline: 12px; }
  .chat-compose .primary { padding-inline: 13px; }
}
