<div class="list"
     data-default="任意のキーワードを入力し、Enterで追加します。追加できるのは4つまでです。"
     data-great-choice="素晴らしい!次はどんなキーワードですか?"
     data-empty-focus="最初のキーワードを入力中"
     data-half="良いですね!残りは2つです。"
     data-one-more="では、最後のキーワードです!"
     data-done="完璧です!言う事はありません。これ以上はダメですよ。"
     data-almost-too-much="ダメって言いましたよね?"
     data-too-much="追加するの?マジあり得ない。"
>
  
  <ul contenteditable>
    <li></li>
  </ul>
  
  <button type="button">
    無視して追加する
  </button>
</div>
.list {
  --color: black;
  
  color: var(--color);
}

ul {
  border: 3px solid var(--color);
  padding: 0;
  color: #000;
  list-style: none;
  counter-reset: count;
}

li {
  counter-increment: count;
  margin: 0;
  padding: 0.5rem 0.5rem 0.2rem 4.5ch;
  height: 1.8rem;
  position: relative;
}

li::before {
  content: counter(count);
  display: inline-block;
  background: #000;
  color: #fff;
  padding: 0.5rem;
  margin-right: 1rem;
  width: 4ch;
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  box-sizing: border-box;
  }

.list:focus-within {
  --color: rgb(11, 103, 162);
}

.list::before {
  content: attr(data-default);
}

.list:focus-within::before {
  content: attr(data-empty-focus);
}

.list:has(li:nth-child(2)) {
  --color: rebeccapurple;
}

.list:has(li:nth-child(3)) {
  --color: rgb(255, 111, 0);
}

.list:has(li:nth-child(4) > :first-child) {
  --color: rgb(203, 157, 0);
}

.list:has(li:nth-child(4)) {
  --color: rgb(76, 113, 32);
}

.list:has(li:nth-child(5)) {
  --color: red;
}


.list:has(li:nth-child(2))::before {
  content: attr(data-great-choice)
}

.list:has(li:nth-child(3) > :first-child)::before,
.list:has(li:nth-child(3))::before{
    content: attr(data-half);
}

.list:has(li:nth-child(4):last-child)::before {
    content: attr(data-done);
}

.list:has(li:nth-child(4) > :first-child)::before {
    content: attr(data-one-more);
}

.list:has(li:nth-child(5))::before {
    content: attr(data-too-much);
}

.list:has(li:nth-child(5))::before {
    content: attr(data-too-much);
}

.list:has(li:nth-child(5) > :first-child)::before {
    content: attr(data-almost-too-much);
}

.list.list:has(li:nth-child(4)) button {
  opacity: 1;
}

.list:has(li:nth-child(4) > :first-child) button{
  opacity: 0;
}

.list.list:has(li:nth-child(5)) button {
  opacity: 0;
}

.list:has(li:nth-child(5) > :first-child) button {
  opacity: 1;
}

button {
  opacity: 0;
  transition: opacity .3s;
  background: #0080dd;
  font-family: inherit;
  padding-inline: 1.2rem;
  border: 0;
  color: #fff;
  font-weight: bold;
  font-size: 1.2rem;
  padding-block: 0.8rem 0.5rem;
  letter-spacing: 1px;
}

:focus-visible {
  outline: 2px solid transparent;
}

body {
  font: 1rem/1.5 sans-serif;
  padding: 1rem;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.