/* Keep field names available to assistive technology in the light template. */
html:not([data-theme="dark"]) .cs-comment-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

html[data-theme="dark"] .article-page .article-comments {
  --comment-input: #161f24;
  --comment-stroke: #53666e;
  padding: clamp(18px, 2.4vw, 34px);
}
html[data-theme="dark"] .article-comments > .article-section-heading {
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--ui-line);
}
html[data-theme="dark"] .article-page .article-comments .article-section-heading h2 {
  padding-inline-start: 12px;
  border-inline-start: 3px solid var(--ui-action);
  font-size: clamp(24px, 2.1vw, 30px) !important;
  line-height: 1 !important;
}
html[data-theme="dark"] .article-comments .article-comments-count {
  min-width: 25px;
  padding: 3px 8px;
  border: 1px solid var(--ui-line);
  border-radius: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .cs-comment-composer {
  display: grid;
  container: comment-form / inline-size;
  gap: 18px;
  min-width: 0;
}
html[data-theme="dark"] .cs-comment-composer .cs-comment-identity {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0;
}
html[data-theme="dark"] .cs-comment-identity > div { width: auto; padding: 0; min-width: 0; }
html[data-theme="dark"] .cs-comment-composer .form-group { margin: 0 !important; min-width: 0; }
html[data-theme="dark"] .article-comments .cs-comment-composer label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ui-ink);
}
html[data-theme="dark"] .modern-site #dle-content .article-comments .cs-comment-composer input.form-control {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--comment-stroke);
  border-radius: 9px;
  background: var(--comment-input);
  color: var(--ui-ink);
  font-size: 15px;
  line-height: 1.4;
  box-shadow: none;
}
html[data-theme="dark"] .article-comments .cs-comment-identity input::placeholder { color: #a0b1b7; opacity: 1; }
html[data-theme="dark"] .modern-site #dle-content .article-comments .cs-comment-composer input.form-control:focus {
  border-color: var(--ui-action);
  outline: 2px solid var(--ui-action);
  outline-offset: -1px;
}
html[data-theme="dark"] .cs-comment-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-top: 16px;
  border-top: 1px solid var(--ui-line);
}
html[data-theme="dark"] .modern-site .cs-comment-footer .cs16-captcha {
  display: grid;
  grid-template: "image label" auto "image input" auto "hint hint" auto / auto minmax(0, 13rem);
  align-items: center;
  gap: 5px 14px;
  padding: 0;
  border: 0;
  background: transparent;
}
html[data-theme="dark"] .article-comments .cs16-captcha label { grid-area: label; margin: 0; }
html[data-theme="dark"] .article-comments .cs16-captcha .cs16-captcha__image { grid-area: image; }
html[data-theme="dark"] .article-comments .cs16-captcha__image a {
  display: block;
  border-radius: 8px;
}
html[data-theme="dark"] .article-comments .cs16-captcha__image img {
  display: block;
  border: 1px solid var(--ui-line);
}
html[data-theme="dark"] .article-comments .cs16-captcha input { grid-area: input; }
html[data-theme="dark"] .article-comments .cs16-captcha .cs16-captcha__hint {
  grid-area: hint;
  max-width: none;
  margin-top: 3px;
  color: var(--ui-muted);
  font-size: 12px;
  line-height: 1.45;
}
html[data-theme="dark"] .modern-site #dle-content .cs-comment-footer .btn-primary {
  min-height: 44px;
  padding: 9px 22px;
  margin-inline-start: auto;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 650;
}
html[data-theme="dark"] .modern-site #dle-content .cs-comment-footer .btn-primary:hover {
  background: #ffb480;
  color: var(--ui-on-action);
}
@container comment-form (max-width: 480px) {
  html[data-theme="dark"] .cs-comment-composer .cs-comment-identity { grid-template-columns: minmax(0, 1fr); }
  html[data-theme="dark"] .modern-site .cs-comment-footer .cs16-captcha {
    width: 100%;
    grid-template-columns: minmax(0, 40%) minmax(0, 1fr);
    gap: 5px 10px;
  }
  html[data-theme="dark"] .article-comments .cs16-captcha__image #dle-captcha img { width: 100%; height: auto; }
  html[data-theme="dark"] .modern-site #dle-content .cs-comment-composer input.form-control { font-size: 16px; }
  html[data-theme="dark"] .cs-comment-footer .btn-primary { width: 100%; }
}
@container comment-form (max-width: 275px) {
  html[data-theme="dark"] .modern-site .cs-comment-footer .cs16-captcha {
    grid-template: "label" auto "image" auto "input" auto "hint" auto / minmax(0, 1fr);
  }
  html[data-theme="dark"] .article-comments .cs16-captcha__image a { width: min(160px, 100%); }
}

/* Posted messages. DLE inserts the same template for replies loaded through AJAX. */
html[data-theme="dark"] .cs-comment {
  display: grid !important;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-areas: "avatar meta" ". message" ". actions";
  align-items: start;
  gap: 8px 14px;
  margin: 12px 0 !important;
  padding: clamp(14px, 1.6vw, 22px);
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  background: var(--ui-raised);
  color: var(--ui-ink);
}
html[data-theme="dark"] .cs-comment__avatar {
  grid-area: avatar;
  width: 40px;
  height: 40px;
  margin: 0 !important;
  border: 1px solid var(--ui-line);
  border-radius: 50%;
  object-fit: cover;
  background: var(--ui-soft);
}
html[data-theme="dark"] .cs-comment__main { display: contents; }
html[data-theme="dark"] .cs-comment__meta {
  grid-area: meta;
  align-self: center;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0 !important;
  min-width: 0;
}
html[data-theme="dark"] .cs-comment__author,
html[data-theme="dark"] .cs-comment__author a {
  margin: 0;
  padding: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ui-ink);
  text-decoration: none;
}
html[data-theme="dark"] .cs-comment__author a:hover { color: var(--ui-accent); }
html[data-theme="dark"] .cs-comment__date {
  margin: 0 !important;
  color: var(--ui-muted);
  font-size: 12px;
  line-height: 1.5;
}
/* Reply stays available in the action row below the message. */
html[data-theme="dark"] .cs-comment__meta > a:has(> .text-body) { display: none; }
html[data-theme="dark"] .cs-comment__message {
  grid-area: message;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ui-ink);
  font-size: 15px;
  line-height: 1.65;
}
html[data-theme="dark"] .cs-comment__message p { margin: 0 0 .7em; color: inherit; }
html[data-theme="dark"] .cs-comment__message p:last-child { margin-bottom: 0; }
html[data-theme="dark"] .cs-comment__message a {
  color: var(--ui-accent);
  text-decoration: underline;
  text-underline-offset: .16em;
}
html[data-theme="dark"] .cs-comment__message img { max-width: 100%; height: auto; }
html[data-theme="dark"] .cs-comment__message :is(blockquote, .quote, .title_quote, .scriptcode, .text_spoiler, .title_spoiler) {
  margin: 8px 0;
  padding: 10px 14px;
  border: 1px solid var(--ui-line);
  border-inline-start: 2px solid var(--ui-accent);
  border-radius: 0 8px 8px 0;
  background: var(--ui-soft) !important;
  color: var(--ui-ink);
}
html[data-theme="dark"] .cs-comment__message :is(blockquote, .quote)::before { content: none; }
html[data-theme="dark"] .cs-comment__message pre { max-width: 100%; overflow-x: auto; }
html[data-theme="dark"] .cs-comment__actions,
html[data-theme="dark"] .cs-comment__rating {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
html[data-theme="dark"] .cs-comment__actions {
  grid-area: actions;
  margin: 2px 0 0 !important;
  padding: 0;
  border: 0;
  background: none;
}
html[data-theme="dark"] .cs-comment__actions:not(:has(a, button)),
html[data-theme="dark"] .cs-comment__rating:not(:has(a, span)) { display: none; }
html[data-theme="dark"] .cs-comment__rating { margin-inline-start: auto; }
html[data-theme="dark"] .cs-comment__actions :is(a, button),
html[data-theme="dark"] .cs-comment__rating a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  box-sizing: border-box;
  padding: 4px 10px;
  margin: 0;
  border: 1px solid var(--ui-line);
  border-radius: 7px;
  background: var(--ui-soft);
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}
html[data-theme="dark"] .cs-comment :is(.cs-comment__actions, .cs-comment__rating) a:is(:hover, :focus-visible) {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}
html[data-theme="dark"] .cs-comment__rating .text-success { color: #98d6b1 !important; margin: 0 !important; }
html[data-theme="dark"] .cs-comment__rating .text-danger { color: #f3aaa7 !important; }
html[data-theme="dark"] #dle-comments-list :is(ol, ul):has(> li .cs-comment) {
  list-style: none;
  margin: 0;
  padding: 0;
}
html[data-theme="dark"] #dle-comments-list li > :is(ol, ul):has(> li .cs-comment) {
  border-inline-start: 1px solid var(--ui-line);
  margin-inline-start: 16px;
  padding-inline-start: 14px;
}
html[data-theme="dark"] #dle-comments-list li li li > :is(ol, ul):has(> li .cs-comment) {
  margin-inline-start: 0;
  padding-inline-start: 0;
  border: none;
}
@media (max-width: 620px) {
  html[data-theme="dark"] .cs-comment {
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-areas: "avatar meta" "message message" "actions actions";
    gap: 10px;
  }
  html[data-theme="dark"] .cs-comment__avatar { width: 36px; height: 36px; }
  html[data-theme="dark"] .cs-comment__meta { gap: 0 10px; }
  html[data-theme="dark"] .cs-comment__message { font-size: 14px; }
  html[data-theme="dark"] .cs-comment__rating { margin-inline-start: 0; }
  html[data-theme="dark"] .cs-comment__actions :is(a, button),
  html[data-theme="dark"] .cs-comment__rating a { min-height: 42px; }
  html[data-theme="dark"] #dle-comments-list li > :is(ol, ul):has(> li .cs-comment) {
    margin-inline-start: 4px;
    padding-inline-start: 8px;
  }
  html[data-theme="dark"] #dle-comments-list li li > :is(ol, ul):has(> li .cs-comment) {
    margin-inline-start: 0;
    padding-inline-start: 0;
    border: none;
  }
}

/* DLE loads its TinyMCE skin after the page styles. The skin marks SVG fills
   and toolbar dividers important, so match them within the dark editor only. */
html[data-theme="dark"] .article-comments .tox.tox-tinymce {
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  box-shadow: none;
}
html[data-theme="dark"] .article-comments .tox.tox-tinymce:focus-within {
  border-color: var(--ui-accent);
}
html[data-theme="dark"] .article-comments .tox .tox-editor-header,
html[data-theme="dark"] .article-comments .tox :is(.tox-toolbar,.tox-toolbar__primary,.tox-toolbar__overflow),
html[data-theme="dark"] .tox-tinymce-aux .tox-toolbar__overflow {
  background: var(--ui-raised);
  border-color: var(--ui-line) !important;
  box-shadow: none;
}
html[data-theme="dark"] .article-comments .tox .tox-toolbar__primary { padding: 3px; }
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) .tox-toolbar__group {
  border-color: var(--ui-line) !important;
  box-shadow: none !important;
}
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) .tox-tbtn {
  min-width: 32px;
  min-height: 32px;
  color: var(--ui-ink);
  background: transparent;
  border-radius: 6px;
}
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) :is(.tox-tbtn,.tox-mbtn):is(:hover,:focus-visible,.tox-tbtn--enabled,[aria-expanded="true"],[aria-pressed="true"]) {
  color: var(--ui-accent);
  background: var(--ui-tint);
}
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) :is(.tox-tbtn,.tox-mbtn):is(:disabled,.tox-tbtn--disabled,[aria-disabled="true"]) {
  color: var(--ui-muted);
  background: transparent;
  opacity: .6;
}
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) :is(.tox-tbtn,.tox-mbtn,.tox-button--icon,.tox-collection__item-icon,.tox-collection__item-checkmark,.tox-listbox__select-chevron,.tox-statusbar__resize-handle) svg {
  fill: currentColor !important;
}
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) :is(.tox-tbtn__icon-wrap,.tox-icon i,.tox-icon [class*="icon-"]) {
  color: inherit;
}
html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) :is(.tox-tbtn,.tox-mbtn,.tox-button,.tox-listbox,.tox-collection__item):focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: -2px;
}
html[data-theme="dark"] .article-comments .tox .tox-statusbar {
  background: var(--ui-soft);
  border-color: var(--ui-line);
  box-shadow: none;
}
html[data-theme="dark"] .tox-tinymce-aux :is(.tox-dialog,.tox-menu,.tox-pop__dialog) {
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  background: var(--ui-raised);
  color: var(--ui-ink);
  box-shadow: 0 14px 44px rgb(0 0 0 / 36%);
}
html[data-theme="dark"] .tox-tinymce-aux .tox-dialog :is(.tox-dialog__header,.tox-dialog__footer),
html[data-theme="dark"] .tox-tinymce-aux .tox-menu .tox-collection__group {
  border-color: var(--ui-line);
  background: var(--ui-raised);
  box-shadow: none;
}
html[data-theme="dark"] .tox-tinymce-aux .tox-dialog__body-nav-item--active {
  color: var(--ui-ink);
  border-color: var(--ui-action);
}
html[data-theme="dark"] .tox-tinymce-aux .tox-collection .tox-collection__item:is(.tox-collection__item--active,.tox-collection__item--enabled) {
  color: var(--ui-accent);
  background: var(--ui-tint);
}
html[data-theme="dark"] .tox-tinymce-aux .tox-dialog__footer .tox-button {
  color: var(--ui-on-action);
  background: var(--ui-action);
  border: 1px solid var(--ui-action);
  border-radius: 7px;
  box-shadow: none;
}
html[data-theme="dark"] .tox-tinymce-aux .tox-dialog__footer .tox-button--secondary {
  color: var(--ui-ink);
  background: var(--ui-soft);
  border-color: var(--ui-line);
}
html[data-theme="dark"] .tox-tinymce-aux .tox-dialog__footer .tox-button:hover:not(:disabled) {
  border-color: var(--ui-accent);
  filter: brightness(1.09);
}
@media (pointer: coarse) {
  html[data-theme="dark"] :is(.article-comments .tox,.tox-tinymce-aux) .tox-tbtn {
    min-height: 36px;
    min-width: 36px;
  }
}
