.comments-component {
  --comments-background-tint: color-mix(
    in srgb,
    var(--rw-color-primary-subtle, var(--fs-color-primary-subtle)) 18%,
    rgba(255, 255, 255, 0.68)
  );
  --comments-border-color: color-mix(
    in srgb,
    var(--rw-color-primary, var(--fs-color-primary)) 24%,
    var(--rw-color-border-subtle, var(--border))
  );
}

.comments-component .comments-component__section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--comments-border-color);
  border-radius: 2px;
  background-color: var(--rw-color-surface, #fff);
  background-image:
    linear-gradient(var(--comments-background-tint), var(--comments-background-tint)),
    url("/stoneware/backgrounds/info-block.png");
  background-position: 0 0, 0 0;
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, 526px 526px;
  box-shadow: var(--rw-shadow-sm, 0 1px 2px rgba(31, 31, 31, 0.08));
}

.comments-component--compact .comments-component__section {
  gap: 7px;
  padding: 8px 10px;
  box-shadow: none;
}

.comments-component--compact.comments-component--empty .comments-component__section {
  padding-block: 5px;
}

.comments-component__body {
  display: grid;
  gap: 10px;
}

.comments-component--compact .comments-component__body {
  gap: 7px;
}

.comments-component--compact.comments-component--empty .comments-component__body {
  gap: 0;
}

.comments-component__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.comments-component__title {
  color: var(--rw-color-text, var(--brand-blue-dark));
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.comments-component__add-button {
  flex: 0 0 auto;
  justify-content: center;
}

.comments-component__status,
.comments-component__empty {
  color: var(--brand-muted);
  font-size: 12px;
  line-height: 1.35;
}

.comments-component__status:empty {
  display: none;
}

.comments-component__status--error {
  color: var(--danger, var(--fs-color-danger));
}

.comments-component__list,
.comments-component__previous-list {
  display: grid;
  gap: 8px;
}

.comments-component--compact .comments-component__list,
.comments-component--compact .comments-component__previous-list {
  gap: 5px;
}

.comments-component__row {
  padding: 9px 10px;
  border: 1px solid var(--rw-color-border-subtle, var(--border));
  border-radius: 2px;
  background: color-mix(in srgb, var(--rw-color-primary-subtle, var(--fs-color-primary-subtle)) 12%, rgba(255, 255, 255, 0.9));
}

.comments-component--compact .comments-component__row {
  padding: 7px 8px;
}

.comments-component__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--brand-muted);
  font-size: 11px;
  line-height: 1.25;
  font-weight: 700;
}

.comments-component--compact .comments-component__meta {
  margin-bottom: 4px;
}

.comments-component__text {
  color: var(--brand-dark);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.comments-component__previous {
  display: grid;
  gap: 7px;
}

.comments-component--compact .comments-component__previous {
  gap: 5px;
}

.comments-component__previous-summary {
  cursor: pointer;
  color: var(--brand-blue);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
}

.comments-component__previous-summary::marker {
  color: var(--brand-blue);
}

.comments-component__previous-list {
  padding-top: 8px;
  border-top: 1px dashed color-mix(in srgb, var(--brand-blue) 18%, var(--border));
}

.comments-component--compact .comments-component__previous-list {
  padding-top: 5px;
}

.nomenclature-history-toggle {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin-top: 8px;
}

.nomenclature-history-toggle__summary {
  cursor: pointer;
  color: var(--brand-blue);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
}

.nomenclature-history-toggle__summary::marker {
  color: var(--brand-blue);
}

.nomenclature-history__list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.nomenclature-history__entry {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 9px 10px;
  background: var(--fs-color-surface);
  border: 1px solid color-mix(in srgb, var(--brand-blue) 16%, var(--border));
  border-radius: 10px;
}

.nomenclature-history__message {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--brand-dark);
  font-size: 13px;
  line-height: 1.35;
}

.nomenclature-history__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--brand-muted);
  font-size: 11px;
  line-height: 1.25;
  font-weight: 700;
}

.nomenclature-history__empty {
  color: var(--brand-muted);
  font-size: 12px;
  line-height: 1.35;
}

.nomenclature-history__field {
  color: var(--brand-blue-dark);
  font-weight: 700;
}

.nomenclature-history__from,
.nomenclature-history__to {
  display: inline-block;
  max-width: 100%;
  padding: 2px 7px;
  overflow-wrap: anywhere;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  vertical-align: baseline;
}

.nomenclature-history__from {
  color: var(--fs-color-danger);
  background: color-mix(in srgb, var(--fs-color-danger) 10%, #fff);
}

.nomenclature-history__to {
  color: var(--fs-color-success-text);
  background: color-mix(in srgb, var(--fs-color-success) 12%, #fff);
}

.comments-component__modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.comments-component__modal[hidden] {
  display: none;
}

.comments-component__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.comments-component__dialog {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--comments-border-color);
  border-radius: var(--rw-radius-md, 6px);
  background-color: var(--rw-color-surface, #fff);
  background-image:
    linear-gradient(var(--comments-background-tint), var(--comments-background-tint)),
    url("/stoneware/backgrounds/info-block.png");
  background-position: 0 0, 0 0;
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, 526px 526px;
  box-shadow: 0 18px 48px rgba(38, 35, 31, 0.22);
}

.comments-component__form {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--comments-border-color);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.64);
}

.comments-component__modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.comments-component__modal-title {
  color: var(--brand-blue-dark);
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
}

.comments-component__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--fs-color-surface);
  color: var(--brand-blue);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.comments-component__field {
  display: grid;
  gap: 6px;
}

.comments-component__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.comments-component__actions .action-button {
  flex: 0 0 auto;
}

.comments-component__error {
  padding: 10px 12px;
  border: 1px solid var(--fs-color-danger-line);
  border-radius: 8px;
  background: var(--fs-color-danger-subtle);
  color: var(--fs-color-danger-hover);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .comments-component__modal {
    align-items: flex-end;
    padding: 8px;
  }

  .comments-component__dialog {
    width: 100%;
    max-height: calc(100vh - 16px);
    padding: 12px 10px;
    border-radius: 4px;
  }

  .comments-component__form {
    gap: 10px;
    padding: 10px;
  }

  .comments-component__field textarea {
    min-height: 120px;
  }

  .comments-component__actions .action-button {
    flex: 1 1 100%;
    width: 100%;
    min-height: 40px;
  }

  .comments-component--compact .comments-component__section {
    padding-inline: 8px;
  }

  .comments-component__meta {
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: 2px;
  }
}
