.modx-comments {
  --mc-bg: #fff;
  --mc-surface: #f7f8fa;
  --mc-border: #dfe3e8;
  --mc-text: #20242a;
  --mc-muted: #6b7280;
  --mc-accent: #2f6fed;
  --mc-accent-hover: #245fcd;
  --mc-danger: #c0392b;
  --mc-radius: 12px;
  --mc-shadow: 0 8px 28px rgba(20, 28, 40, .06);
  max-width: 820px;
  color: var(--mc-text);
  font: inherit;
}

.mc-loading {
  display: none;
  align-items: center;
  gap: 5px;
  min-height: 42px;
}
.modx-comments.is-loading .mc-loading { display: flex; }
.modx-comments.is-loading .mc-list,
.modx-comments.is-loading .mc-composer { opacity: .45; pointer-events: none; }

.mc-loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  animation: mc-pulse 1s infinite ease-in-out;
}
.mc-loading span:nth-child(2) { animation-delay: .12s; }
.mc-loading span:nth-child(3) { animation-delay: .24s; }

@keyframes mc-pulse {
  0%, 100% { transform: translateY(0); opacity: .25; }
  50% { transform: translateY(-3px); opacity: .7; }
}

.mc-list { display: grid; gap: 12px; }

.mc-comment {
  margin-left: calc(min(var(--mc-depth), 5) * 22px);
  padding: 16px 18px;
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  background: var(--mc-bg);
  box-shadow: var(--mc-shadow);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mc-comment:hover { border-color: #c9d0d8; }

.mc-comment-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  min-width: 0;
}

.mc-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  font-size: 12px;
  font-weight: 700;
}

.mc-author {
  min-width: 0;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc-comment time,
.mc-edited {
  font-size: .82em;
  color: var(--mc-muted);
}
.mc-edited::before { content: "·"; margin-right: 5px; }

.mc-content {
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.mc-content a { color: var(--mc-accent); }

.mc-comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.mc-action,
.mc-link-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--mc-muted);
  font: inherit;
  font-size: .9em;
  cursor: pointer;
}
.mc-action:hover,
.mc-link-button:hover { color: var(--mc-accent); }
.mc-action.is-danger:hover { color: var(--mc-danger); }

.mc-comment.is-deleted {
  background: var(--mc-surface);
  border-style: dashed;
  box-shadow: none;
  opacity: .8;
}
.mc-deleted {
  color: var(--mc-muted);
  font-style: italic;
}

.mc-composer { margin-top: 22px; }

.mc-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  background: var(--mc-bg);
  box-shadow: var(--mc-shadow);
}

.mc-form-title {
  font-size: 1.05em;
  font-weight: 700;
}

.mc-guest-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mc-form label { display: grid; gap: 6px; }
.mc-form label > span { font-size: .88em; color: var(--mc-muted); }
.mc-form small { font-size: .9em; }

.mc-form input,
.mc-form textarea,
.mc-inline-panel textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--mc-border);
  border-radius: 9px;
  padding: 10px 12px;
  background: #fff;
  color: var(--mc-text);
  font: inherit;
  line-height: 1.45;
  outline: none;
  resize: vertical;
}
.mc-form input:focus,
.mc-form textarea:focus,
.mc-inline-panel textarea:focus {
  border-color: var(--mc-accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}

.mc-replying {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--mc-surface);
  color: var(--mc-muted);
  font-size: .9em;
}
.mc-replying[hidden] { display: none; }

.mc-form-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: -8px;
}
.mc-counter { font-size: .8em; color: var(--mc-muted); }

.mc-actions,
.mc-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mc-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.mc-btn:disabled { opacity: .6; cursor: wait; }

.mc-btn-primary {
  background: var(--mc-accent);
  color: #fff;
}
.mc-btn-primary:hover:not(:disabled) { background: var(--mc-accent-hover); }

.mc-btn-secondary {
  background: #fff;
  border-color: var(--mc-border);
  color: var(--mc-text);
}

.mc-btn-danger {
  background: var(--mc-danger);
  color: #fff;
}

.mc-btn-small {
  padding: 6px 10px;
  border-radius: 7px;
  font-size: .9em;
}

.mc-inline-panel,
.mc-delete-confirm {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border-radius: 9px;
  background: var(--mc-surface);
}

.mc-delete-confirm {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.mc-delete-confirm div:first-child {
  display: grid;
  gap: 3px;
}
.mc-delete-confirm span {
  color: var(--mc-muted);
  font-size: .88em;
}

.mc-empty,
.mc-notice {
  padding: 24px;
  border: 1px dashed var(--mc-border);
  border-radius: var(--mc-radius);
  text-align: center;
  color: var(--mc-muted);
  background: var(--mc-surface);
}
.mc-empty-title {
  margin-bottom: 4px;
  color: var(--mc-text);
  font-weight: 700;
}

.mc-status {
  min-height: 1.35em;
  margin-top: 10px;
  font-size: .9em;
}
.mc-status.is-error { color: var(--mc-danger); }
.mc-status.is-success { color: #237a46; }

.mc-captcha:empty { display: none; }

.mc-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 640px) {
  .mc-comment { margin-left: calc(min(var(--mc-depth), 5) * 10px); padding: 14px; }
  .mc-guest-fields { grid-template-columns: 1fr; }
  .mc-comment-header { align-items: flex-start; flex-wrap: wrap; }
  .mc-comment time { flex-basis: calc(100% - 39px); margin-left: 39px; margin-top: -7px; }
  .mc-delete-confirm { grid-template-columns: 1fr; }
}


/* beta5: editor toolbar, honeypot, reply quotes and voting */
.mc-honeypot {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.mc-editor {
  border: 1px solid var(--mc-border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.mc-editor:focus-within {
  border-color: var(--mc-accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}
.mc-editor .mc-comment-field textarea {
  border: 0;
  border-radius: 0;
  box-shadow: none !important;
}

.mc-toolbar {
  position: relative;
  border-bottom: 1px solid var(--mc-border);
  background: var(--mc-surface);
}
.mc-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
}
.mc-tool,
.mc-emoji-choice {
  appearance: none;
  border: 0;
  border-radius: 7px;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  background: transparent;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.mc-tool:hover,
.mc-emoji-choice:hover {
  background: #e9edf2;
}
.mc-emoji {
  font-size: 18px;
}

.mc-link-panel {
  display: flex;
  gap: 7px;
  padding: 8px;
  border-top: 1px solid var(--mc-border);
}
.mc-link-panel[hidden],
.mc-emoji-panel[hidden] {
  display: none;
}
.mc-link-panel input {
  min-width: 0;
  flex: 1 1 auto;
}

.mc-emoji-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px;
  border-top: 1px solid var(--mc-border);
}
.mc-emoji-choice {
  font-size: 19px;
}

.mc-reply-preview {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.mc-reply-preview strong {
  color: var(--mc-text);
  font-size: .9em;
}
.mc-reply-preview span {
  display: block;
  max-width: 620px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mc-quote {
  display: grid;
  gap: 3px;
  margin: 0 0 10px 39px;
  padding: 8px 10px;
  border-left: 3px solid var(--mc-border);
  border-radius: 0 7px 7px 0;
  background: var(--mc-surface);
  color: var(--mc-muted);
  font-size: .88em;
}
.mc-quote strong {
  color: var(--mc-text);
}
.mc-quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-quote.is-deleted {
  font-style: italic;
}

.mc-comment-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
}
.mc-comment-footer .mc-comment-actions {
  margin-top: 0;
}

.mc-votes {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.mc-vote {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--mc-border);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  color: var(--mc-muted);
  font: inherit;
  font-size: .86em;
  cursor: pointer;
}
.mc-vote:hover {
  border-color: #bfc8d2;
  color: var(--mc-text);
}
.mc-vote.is-active {
  border-color: var(--mc-accent);
  background: rgba(47, 111, 237, .08);
  color: var(--mc-accent);
}
.mc-vote:disabled {
  opacity: .55;
  cursor: wait;
}

@media (max-width: 640px) {
  .mc-comment-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .mc-votes {
    margin-left: 0;
  }
  .mc-quote {
    margin-left: 0;
  }
  .mc-link-panel {
    align-items: stretch;
    flex-direction: column;
  }
}


/* beta6: permalinks and labeled-link editor */
.mc-permalink {
  color: var(--mc-muted);
  font-size: .82em;
  text-decoration: none;
}
.mc-permalink:hover {
  color: var(--mc-accent);
  text-decoration: underline;
}

.mc-comment:target {
  border-color: var(--mc-accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12), var(--mc-shadow);
}

.mc-link-panel label {
  display: grid;
  gap: 4px;
  flex: 1 1 180px;
}
.mc-link-panel label > span {
  color: var(--mc-muted);
  font-size: .78em;
}
.mc-link-panel .mc-btn {
  align-self: end;
}

@media (max-width: 640px) {
  .mc-link-panel .mc-btn {
    align-self: stretch;
  }
}


/* beta7: pending comment preview */
.mc-comment.is-pending-preview {
  opacity: .62;
  border-style: dashed;
  background: var(--mc-surface);
  box-shadow: none;
}

.mc-pending-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff6dc;
  color: #8a6413;
  font-size: .76em;
  font-weight: 600;
}

.mc-pending-note {
  margin-top: 12px;
  color: #8a6413;
  font-size: .84em;
  font-style: italic;
}


/* beta13: count heading and root-thread pagination */
.mc-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 1.08em;
}

.mc-heading strong {
  font-weight: 700;
}

.mc-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 36px;
  margin: 16px 0 2px;
  color: var(--mc-muted);
  font-size: .9em;
}

.mc-pagination:empty {
  display: none;
}

.mc-pagination .mc-btn:disabled {
  cursor: default;
  opacity: .45;
}


/* beta14: highlight a freshly submitted comment after autoscroll */
.mc-comment.is-new-comment {
  animation: mc-new-comment-pulse 2.2s ease;
}

@keyframes mc-new-comment-pulse {
  0%, 100% {
    box-shadow: var(--mc-shadow);
  }
  25%, 65% {
    box-shadow: 0 0 0 4px rgba(47, 111, 237, .16), var(--mc-shadow);
  }
}


/* Admin-authored frontend comments */
.mc-admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .72em;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.mc-admin-badge + .mc-author {
  font-weight: 700;
}
