.comments {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.comments-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.comments-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.comments-head h2 svg {
  width: 20px;
  height: 20px;
  color: var(--text-subtle);
}
.comments-composer {
  margin-bottom: 28px;
}
.comments-empty {
  padding: 28px 0;
  text-align: center;
  color: var(--text-muted);
}

.login-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
}
.login-card p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}
.login-card-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, #5865f2 14%, transparent);
  color: #5865f2;
}
:root[data-theme='dark'] .login-card-icon {
  color: #8b93ff;
}

/* Composer */
.composer-guest {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border);
}
.composer-guest .input {
  width: 200px;
  max-width: 100%;
}
.composer-guest a {
  color: var(--brand-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
/* Honeypot: invisible and out of the layout, but still in the form for bots. */
.hp-field {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.composer {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.composer-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.composer-box:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.composer-input {
  display: block;
  width: 100%;
  min-height: 84px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  resize: vertical;
  font-size: 14.5px;
  line-height: 1.6;
  outline: none;
}
.composer-preview {
  min-height: 84px;
  padding: 12px 14px;
}
.composer-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 10px 14px;
}
.mention-menu {
  position: absolute;
  left: 12px;
  top: 100%;
  z-index: 30;
  min-width: 260px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.mention-menu .dropdown-item[aria-selected='true'] {
  background: var(--brand-soft);
}

/* Comment */
.comment {
  display: flex;
  gap: 12px;
  padding: 10px 0 2px;
  border-radius: var(--radius-lg);
  /* Added to the page-level scroll-padding (header height + 24px). */
  scroll-margin-top: 40px;
}
.comment.highlighted > .comment-main {
  animation: comment-flash 2.4s var(--ease);
}
@keyframes comment-flash {
  0%,
  40% {
    background: var(--brand-soft);
    box-shadow: 0 0 0 6px var(--brand-soft);
  }
  100% {
    background: transparent;
    box-shadow: 0 0 0 6px transparent;
  }
}
.comment-gutter {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
}
.thread-line {
  flex: 1;
  width: 14px;
  margin-top: 6px;
  border: 0;
  background: linear-gradient(var(--border), var(--border)) center / 2px 100% no-repeat;
  cursor: pointer;
}
.thread-line:hover {
  background-image: linear-gradient(var(--brand), var(--brand));
}
.comment-main {
  flex: 1;
  min-width: 0;
  border-radius: var(--radius);
}
.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
}
.comment-head strong {
  font-weight: 650;
}
.comment-time:hover {
  text-decoration: underline;
}
.comment-body {
  margin-top: 4px;
  font-size: 14.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.comment-body p {
  margin: 0 0 0.6em;
}
.comment-body > :last-child {
  margin-bottom: 0;
}
.comment-body a {
  color: var(--brand-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.comment-body blockquote {
  margin: 0 0 0.6em;
  padding-left: 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}
.comment-body ul,
.comment-body ol {
  margin: 0 0 0.6em;
  padding-left: 1.4em;
}
.comment-body :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--inline-code-bg);
}
.comment-body pre {
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
}
.comment-body .mention {
  padding: 0 3px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
}
.comment-removed {
  margin: 4px 0;
  font-size: 14px;
  font-style: italic;
  color: var(--text-subtle);
}
.comment-removed-avatar {
  background: var(--bg-muted);
}
.comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 6px 0 4px -6px;
}
.comment-actions .btn-sm {
  height: 28px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  transition: border-color var(--dur), background var(--dur);
}
.reaction:hover:not(:disabled) {
  border-color: var(--border-strong);
}
.reaction.mine {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand-text);
}
.reaction-picker {
  display: flex;
  gap: 2px;
}
.reaction-picker button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 18px;
  transition: background var(--dur), transform var(--dur);
}
.reaction-picker button:hover {
  background: var(--bg-hover);
  transform: scale(1.15);
}
.comment-replies {
  margin-top: 4px;
}
.reply-composer {
  margin: 10px 0 6px;
}
.replies-toggle {
  margin: 2px 0 4px -6px;
  color: var(--brand-text) !important;
}
.report-option {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
}
.report-option.selected {
  border-color: var(--brand);
  background: var(--brand-softer);
}
.report-option input {
  margin-top: 3px;
}

/* Notifications */
.notif-menu {
  width: min(380px, calc(100vw - 32px));
}
.notif-item {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  font-size: 13.5px;
}
.notif-item:hover {
  background: var(--bg-hover);
}
.notif-item > svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--text-subtle);
}
.notif-item.unread {
  background: var(--brand-softer);
}
.notif-item.unread > svg {
  color: var(--brand-text);
}
.notif-title {
  display: block;
  font-weight: 550;
  line-height: 1.4;
}
.notif-body {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  color: var(--text-muted);
}
.notif-time {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-subtle);
}

/* Tree editor (sidebar reorder + admin structure) */
.tree-editor {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tree-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-right: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  cursor: grab;
  transition: background var(--dur);
}
.tree-editor.compact .tree-row {
  min-height: 32px;
  font-size: 13px;
}
.tree-row:hover {
  background: var(--bg-hover);
}
.tree-row.tree-category {
  font-weight: 600;
}
.tree-row[data-dragging='true'] {
  opacity: 0.4;
}
.tree-row[data-drop='before']::before,
.tree-row[data-drop='after']::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.tree-row[data-drop='before']::before {
  top: -1px;
}
.tree-row[data-drop='after']::after {
  bottom: -1px;
}
.tree-row[data-drop='inside'] {
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1.5px var(--brand);
}
.tree-grip,
.tree-icon {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--text-subtle);
}
.tree-move {
  display: flex;
  opacity: 0;
  transition: opacity var(--dur);
}
.tree-row:hover .tree-move,
.tree-row:focus-within .tree-move {
  opacity: 1;
}
.tree-editor.compact .tree-move .btn {
  width: 24px;
  height: 24px;
}
.tree-empty {
  padding: 6px 0;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-subtle);
}

.expand-sidebar {
  display: none !important;
  position: fixed;
  left: 14px;
  top: calc(var(--header-h) + 16px);
  z-index: 30;
}
:root[data-sidebar='collapsed'] .expand-sidebar {
  display: inline-flex !important;
}
@media (max-width: 960px) {
  :root[data-sidebar='collapsed'] .expand-sidebar {
    display: none !important;
  }
}

/* Compact tree editor (sidebar "Reorder" mode): match the regular sidebar —
   no filled rows, no page icons, quiet grips, controls only on the active row. */
.tree-editor.compact {
  gap: 1px;
}
.tree-editor.compact .tree-row {
  min-height: 32px;
  padding-right: 6px;
  gap: 6px;
  background: transparent;
  font-size: 13.5px;
}
.tree-editor.compact .tree-row:hover,
.tree-editor.compact .tree-row:focus-within {
  background: var(--bg-hover);
}
.tree-editor.compact .tree-row.tree-page {
  color: var(--text-muted);
  font-weight: 450;
}
.tree-editor.compact .tree-row.tree-category {
  margin-top: 10px;
  color: var(--text);
}
.tree-editor.compact > .tree-category:first-child,
.tree-editor.compact > :first-child > .tree-category {
  margin-top: 0;
}
.tree-editor.compact .tree-page .tree-icon {
  display: none;
}
.tree-editor.compact .tree-grip {
  width: 14px;
  height: 14px;
  opacity: 0.35;
  transition: opacity var(--dur);
}
.tree-editor.compact .tree-row:hover .tree-grip,
.tree-editor.compact .tree-row:focus-within .tree-grip {
  opacity: 1;
}
/* Move buttons float over the row's right edge instead of taking width. */
.tree-editor.compact .tree-move {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  padding: 1px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  box-shadow: -10px 0 10px var(--bg-hover);
  pointer-events: none;
}
.tree-editor.compact .tree-row:hover .tree-move,
.tree-editor.compact .tree-row:focus-within .tree-move {
  pointer-events: auto;
}
.tree-editor.compact .tree-empty {
  padding: 4px 0 6px;
  font-size: 12px;
}
