.app-comments {
  grid-area: comments;
  display: block;
  margin-top: 15px;
  padding: 24px;
  background: var(--surface-bg);
  border: 1px solid var(--line-color);
  border-radius: 12px;
  box-shadow: var(--box-shadow);
}

.app-comments-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  margin-inline: 0;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-color);
}

.app-comments h2 { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--heading-color); font-size: 20px; font-weight: 700; }
.app-comments h2 > span { font-size: 20px; font-weight: 700; }
.app-comments h2 em { color: var(--primary-color); font-size: inherit; font-style: normal; }
.app-comments-title-icon { width: 23px; height: 23px; color: var(--primary-color); }

.app-comment-form { display: block; margin-bottom: 20px; direction: rtl; }
.app-comment-form-avatar,
.app-comment-avatar { display: block; box-sizing: border-box; border: 0; border-radius: 50%; background: var(--surface-soft-bg); box-shadow: none; }
.app-comment-form-avatar { width: 64px; height: 64px; flex: 0 0 64px; }
.app-comment-input { position: relative; flex: 1; min-width: 0; }
.app-comment-input-label { position: absolute; z-index: 1; top: 13px; right: 14px; color: var(--heading-color); font-size: 12px; font-weight: 800; pointer-events: none; }
.app-comment-form textarea { display: block; width: 100%; height: 112px; min-height: 112px; max-height: 260px; box-sizing: border-box; padding: 36px 14px 14px 118px; color: var(--text-color); background: var(--surface-soft-bg); border: 1px solid var(--line-color); border-radius: 14px; font: inherit; line-height: 1.6; resize: vertical; }
.app-comment-form textarea:focus { border-color: var(--primary-color); outline: 2px solid color-mix(in srgb, var(--primary-color) 28%, transparent); }
.app-comment-input [type="submit"] { position: absolute; bottom: 12px; left: 12px; min-height: 42px; padding: 0 20px; color: #fff; background: var(--primary-color); border: 0; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 700; transition: transform 160ms ease, filter 160ms ease; }
.app-comment-input [type="submit"]:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.app-comment-input [type="submit"]:disabled { cursor: wait; opacity: .65; }
.app-comment-guest { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 242px; padding: 12px 16px 22px; box-sizing: border-box; text-align: center; }
.app-comment-member-prompt { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 158px; margin-bottom: 20px; padding: 8px 16px 12px; box-sizing: border-box; text-align: center; }
.app-comment-guest[hidden], .app-comment-form[hidden] { display: none !important; }
.app-comment-reply-state { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 8px 10px 8px 8px; color: var(--muted-color); background: color-mix(in srgb, var(--primary-color) 7%, var(--surface-soft-bg)); border: 1px solid color-mix(in srgb, var(--primary-color) 22%, var(--line-color)); border-radius: 10px; font-size: 11px; line-height: 1.5; }
.app-comment-reply-state[hidden] { display: none !important; }
.app-comment-reply-state > span { min-width: 0; overflow: hidden; color: var(--heading-color); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.app-comment-reply-state button { position: static; flex: 0 0 auto; min-height: 30px; margin: 0; padding: 0 11px; color: var(--primary-color); background: transparent; border: 1px solid color-mix(in srgb, var(--primary-color) 40%, transparent); border-radius: 7px; cursor: pointer; font: inherit; font-size: 11px; font-weight: 800; transform: none; }
.app-comment-reply-state button:hover { color: #fff; background: var(--primary-color); filter: none; transform: none; }
html[data-theme="dark"] .app-comment-reply-state { background: color-mix(in srgb, var(--primary-color) 15%, var(--surface-soft-bg)); border-color: color-mix(in srgb, var(--primary-color) 42%, var(--line-color)); }
.app-comment-guest-icon { display: block; width: 108px; height: 108px; margin-bottom: 4px; object-fit: contain; }
.app-comment-guest p { margin: 0; color: var(--heading-color); font-size: 15px; font-weight: 800; line-height: 1.8; }
.app-comment-member-prompt p { margin: 0; color: var(--heading-color); font-size: 15px; font-weight: 800; line-height: 1.8; }
.app-comment-guest > span { margin-top: 1px; color: var(--muted-color); font-size: 12px; line-height: 1.8; }
.app-comment-member-prompt > span { margin-top: 1px; color: var(--muted-color); font-size: 12px; line-height: 1.8; }
.app-comment-guest a { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; margin-top: 12px; padding: 0 22px; color: #fff; background: var(--primary-color); border-radius: 999px; font-size: 13px; font-weight: 800; text-decoration: none; transition: transform 160ms ease, filter 160ms ease; }
.app-comment-guest a:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); }

.app-comment-list { margin: 0; padding: 0; list-style: none; }
.app-comment-loader { display: flex; align-items: center; justify-content: center; min-height: 68px; margin: 8px 0; }
.app-comment-loader[hidden] { display: none !important; }
.app-comment-loader-spinner { width: 19px; height: 19px; box-sizing: border-box; border: 2px solid color-mix(in srgb, var(--primary-color) 24%, transparent); border-top-color: var(--primary-color); border-radius: 50%; animation: app-comment-loader-spin .7s linear infinite; }
.app-comments.is-comments-loading .app-comment-list { opacity: .55; pointer-events: none; }
@keyframes app-comment-loader-spin { to { transform: rotate(360deg); } }
.app-comment-list .children { margin: 14px 58px 0 0; padding: 0; list-style: none; }
.app-comment-card { display: flex; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--line-color); }
.app-comment-list > li:last-child > .app-comment-card { border-bottom: 0; }
.app-comment-avatar { width: 52px; height: 52px; flex: 0 0 52px; }
.app-comment-content { min-width: 0; flex: 1; }
.app-comment-header { display: flex; align-items: baseline; gap: 10px; }
.app-comment-header strong { color: var(--heading-color); font-size: 15px; font-weight: 800; }
.app-comment-header time { color: var(--muted-color); font-size: 12px; }
.app-comment-author-type { padding: 2px 7px; color: var(--primary-color); background: color-mix(in srgb, var(--primary-color) 10%, transparent); border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1.4; }
.app-comment-author-type.is-guest { color: var(--muted-color); background: var(--surface-soft-bg); }
.app-comment-text { margin-top: 7px; overflow-wrap: anywhere; word-break: break-word; color: var(--text-color); line-height: 1.9; }
.app-comment-text p { margin: 0; }
.app-comment-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.app-comment-actions button, .app-comment-actions a { display: inline-flex; align-items: center; gap: 5px; padding: 0; color: var(--muted-color); background: transparent; border: 0; cursor: pointer; font: inherit; font-size: 13px; text-decoration: none; }
.app-comment-reply { font-weight: 700 !important; }
.app-comment-children { margin-right: 58px; }
.app-comment-children .app-comment-card { padding-right: 14px; border-right: 2px solid var(--line-color); }
.app-comment-vote-icon { width: 17px; height: 17px; }
.app-comment-actions button:hover, .app-comment-actions button.is-active, .app-comment-actions a:hover { color: var(--primary-color); }
.app-comment-actions button:disabled { opacity: .55; cursor: wait; }
.app-comment-login, .app-comment-closed { margin: 0 0 20px; color: var(--muted-color); }
.app-comment-login { display: flex; justify-content: center; }
.app-comment-login a { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; box-sizing: border-box; padding: 0 14px; color: var(--primary-color); background: var(--surface-soft-bg); border: 1px solid var(--line-color); border-radius: 10px; font-weight: 700; text-decoration: none; transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms ease; }
.app-comment-login a:hover { color: #fff; background: var(--primary-color); border-color: var(--primary-color); transform: translateY(-1px); }
.app-comment-login-icon { width: 21px; height: 21px; }
.app-comments-load-more { display: block; min-height: 42px; margin: 20px auto 0; padding: 0 20px; color: var(--primary-color); background: var(--surface-soft-bg); border: 1px solid var(--primary-color); border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700; }
.app-comments-load-more:hover { color: #fff; background: var(--primary-color); }
.app-comments-load-more:disabled { opacity: .65; cursor: wait; }
.app-comments-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 188px; box-sizing: border-box; margin-top: 8px; padding: 18px 16px 24px; color: #b4bfd3; text-align: center; }
.app-comments-empty-icon { display: block; width: 104px; height: 104px; margin-bottom: 4px; object-fit: contain; }
.app-comments-empty-icon svg { display: block; width: 100%; height: 100%; }
.app-comments-empty-title { margin: 0; color: var(--heading-color); font-size: 16px; font-weight: 700; line-height: 1.6; }
.app-comments-empty-text { margin: 0; color: var(--heading-color); font-size: 14px; font-weight: 800; line-height: 1.8; }
.app-comments-empty-hint { margin-top: 2px; color: var(--muted-color); font-size: 12px; line-height: 1.7; }

html[data-theme="dark"] .app-comments-empty-icon { color: #8794ad; }

@media (max-width: 600px) {
  .app-comments { padding: 16px; }
  .app-comment-form { align-items: flex-start; gap: 10px; }
  .app-comment-form-avatar { width: 44px; height: 44px; flex-basis: 44px; }
  .app-comment-form textarea { height: 118px; min-height: 118px; padding: 35px 12px 58px; }
  .app-comment-input [type="submit"] { bottom: 10px; left: 10px; min-height: 36px; padding: 0 15px; transform: none; }
  .app-comment-list .children { margin-right: 20px; }
}
