.comments {
  --comment-tint: color-mix(in srgb, var(--accent) 5%, var(--panel));
  margin-block: 18px 12px;
  padding-block-start: 8px;
  border-top: 2px solid var(--accent);
}
.comments [hidden] { display: none; }
.comments-heading { margin-block-end: 4px; }
.comments-heading h2 { margin: 0; font-size: 1.16rem; }
.comments-heading p, .comments-status, .comments-actions p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .88rem;
}
.comments-status:not(:empty) { margin-block: 4px; }
.comments-form, .comments-dialog form { display: grid; gap: 8px; }
.comments-form {
  gap: 5px;
  padding: 7px 13px;
  margin-block-start: 5px;
  background: var(--comment-tint);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.comments-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.comments label { display: grid; gap: 5px; min-width: 0; font-size: .88rem; font-weight: 700; }
.comments-form label { gap: 3px; }
.comments :is(input, textarea) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
}
.comments textarea { resize: vertical; }
.comments-form :is(input, textarea) { padding-block: 4px; line-height: 1.35; }
.comments :is(textarea, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.comments-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.comments-actions p { margin: 0; }
.comments button { font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; }
.comments button:disabled { opacity: .65; cursor: wait; }
.comments :is(.comments-primary, .comments-secondary) {
  min-height: 34px;
  padding: 4px 11px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  white-space: nowrap;
}
.comments-primary { background: var(--accent); color: #fff; }
.comments-secondary { background: var(--panel); color: var(--accent); }
.comments-list { margin: 0; padding: 0; list-style: none; }
.comments-list li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.comments-list li:last-child { border-bottom: 1px solid var(--line); }
.comments-list header { display: flex; flex-wrap: wrap; gap: 5px 9px; align-items: center; }
.comments-list time { color: var(--muted); font-size: .8rem; }
.comment-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  background: var(--comment-tint);
  color: var(--accent);
  border-radius: 50%;
  font-weight: 750;
}
.comment-body { margin: 5px 0 0; white-space: pre-wrap; }
.comments .comment-delete {
  margin-inline-start: auto;
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}
.comments .comment-delete:hover { background: var(--comment-tint); color: var(--accent); }
.comments [data-more] { margin-top: 12px; }
.comments-dialog {
  width: min(100% - 32px, 380px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
}
.comments-dialog::backdrop { background: rgb(15 23 42 / .52); }
.comments-dialog h3, .comments-dialog .comments-status { margin: 0; }
.comments-dialog .comments-status:empty { display: none; }
.comments-dialog .comments-actions { justify-content: flex-end; }
@media (max-width: 540px) {
  .comments-fields { grid-template-columns: 1fr; }
  .comments-form .comments-actions { align-items: stretch; flex-direction: column; }
}
