.learning-paper {
  --learning-ink: #222e29;
  --learning-line: #bdb29a;
  --learning-green: #1f6858;
  --learning-rose: #933a50;
  background: #fbf5e6;
  border: 1px solid var(--learning-line);
  color: var(--learning-ink);
  padding: clamp(1rem, 3vw, 1.65rem);
}

.reward-scene {
  display: grid;
  grid-template-columns: minmax(6rem, .8fr) minmax(0, 3fr) minmax(7rem, 1fr);
  align-items: center;
  column-gap: 1.65rem;
}

.reward-agent, .reward-results {
  display: grid;
  gap: .3rem;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.reward-agent img { width: 6rem; height: 4.6rem; object-fit: contain; }
.reward-agent b, .reward-results > b, .reward-stage { font-size: 1.05rem; }
.reward-stage { display: block; margin-bottom: .55rem; }
.reward-route {
  position: relative;
  display: grid;
  grid-template-columns: max-content 1.65rem minmax(0, 1fr) 1.65rem minmax(0, 1fr);
  align-items: center;
  gap: .45rem;
  text-align: center;
  padding: .6rem .52rem;
  border-block: 2px solid #746e60;
  background: #fffcf5;
}

.reward-route-b { border-color: var(--learning-green); background: #e3efdf; margin-top: .45rem; }
.reward-route div { display: grid; justify-items: center; gap: .2rem; }
.reward-stop { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .21rem .32rem; }
.reward-shelf {
  display: inline-block;
  position: relative;
  width: 1.65rem;
  height: 1.18rem;
  border: 2px solid #545243;
  border-bottom-width: 3px;
  border-radius: 2px;
  background: #faf4e6;
}

.reward-shelf::before {
  content: "";
  position: absolute;
  width: .48rem;
  height: .5rem;
  bottom: 0;
  left: .15rem;
  border: 1px solid #715737;
  border-radius: 1px;
  background: #ffc46d;
}

.shelf-full::before { box-shadow: .5rem 0 #c9945d, .25rem -.34rem #e3b37a; }
.reward-route div b {
  color: #31514b;
  background: #e6eee7;
  border: 1px solid currentColor;
  border-radius: .22rem;
  padding: .03rem .4rem;
}

.reward-route-b div:last-child b, .reward-results div:last-child {
  color: #263e2e;
  background: #ffe385;
}

.reward-route [data-diagram-arrow] { width: 100%; color: var(--learning-green); }
.reward-route [data-diagram-arrow]::before { width: 100%; height: .95rem; }
.reward-results div {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: .35rem;
  border-bottom: 1px solid var(--learning-line);
  padding: .18rem .44rem;
}

.reward-return {
  position: relative;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-start;
  margin: .86rem min(6%, 3rem) 0;
  border-inline: 2px solid var(--learning-green);
  border-bottom: 2px solid var(--learning-green);
  border-radius: 0 0 .5rem .5rem;
  padding: .36rem 1.1rem .52rem;
  line-height: 1.45;
}

.reward-return span { display: grid; gap: .2rem; }
.reward-return [data-diagram-arrow] {
  position: absolute;
  top: -.78rem;
  left: -.6rem;
  width: 1.2rem;
  color: var(--learning-green);
}
.reward-return [data-diagram-arrow]::before { width: 1.07rem; height: 1.6rem; }

@media (min-width: 721px) {
  .reward-agent { position: relative; top: .9rem; }
  .reward-results {
    align-self: stretch;
    grid-template-rows: 1.85rem 1fr 1fr;
    align-items: center;
    gap: .45rem;
  }

  .reward-results div { margin-top: .08rem; }
  .reward-agent::after, .reward-route::before, .reward-route::after {
    content: "";
    position: absolute;
    color: var(--learning-green);
  }

  .reward-agent::after { top: 50%; right: -.8rem; width: 2rem; max-width: 32%; border-top: 2px solid; }
  .reward-route::before {
    left: -.9rem;
    top: 50%;
    width: .9rem;
    height: calc(50% + .35rem);
    border: 2px solid;
    border-right: 0;
    border-bottom: 0;
    border-radius: .36rem 0 0;
  }

  .reward-route-b::before {
    top: auto;
    bottom: 50%;
    border-top: 0;
    border-bottom: 2px solid;
    border-radius: 0 0 0 .36rem;
  }

  .reward-route::after {
    top: calc(50% - .28rem);
    right: -1.37rem;
    width: 1.35rem;
    height: .56rem;
    background: currentColor;
    clip-path: polygon(0 34%, 70% 34%, 70% 0, 100% 50%, 70% 100%, 70% 66%, 0 66%);
  }
}

.fit-board { --plot-height: clamp(10rem, 16vw, 12rem); }
.fit-legend {
  display: flex;
  gap: .4rem 1.2rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--learning-line);
  padding-bottom: .6rem;
  margin-bottom: .65rem;
}

.fit-legend span { display: flex; align-items: center; gap: .3rem; }
.fit-key, .fit-mark { width: .65rem; height: .65rem; display: inline-block; background: currentColor; }
.fit-key-train, .fit-train { color: var(--learning-green); border-radius: 50%; }
.fit-key-valid, .fit-valid { color: var(--learning-rose); }

.fit-chart {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  grid-template-rows: auto var(--plot-height) auto auto;
  column-gap: .55rem;
  padding-inline: .2rem 1.25rem;
}

.fit-y-title, .fit-x-title { color: #2d5248; font-size: .96rem; }
.fit-y-title { grid-column: 1 / -1; margin-bottom: .65rem; }
.fit-y-ticks {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-block: -.66rem;
  text-align: right;
}

.fit-plot {
  position: relative;
  border-left: 2px solid var(--learning-ink);
  border-bottom: 2px solid var(--learning-ink);
  background:
    repeating-linear-gradient(to bottom, #c6c0b1 0 1px, transparent 1px 25%),
    #fffdf6;
}

.fit-band { position: absolute; inset: 0 0 0 50%; background: #f9e4b875; border-left: 1px dashed #a18d5a; }
.fit-series { position: absolute; inset: 0; background: currentColor; border-radius: 0; }
.fit-series.fit-train {
  clip-path: polygon(0 9%, 25% 39%, 50% 69%, 75% 89%, 100% 94%, 100% 96%, 75% 91%, 50% 71%, 25% 41%, 0 11%);
}

.fit-series.fit-valid {
  clip-path: polygon(0 4%, 25% 34%, 50% 64%, 75% 49%, 100% 34%, 100% 36%, 75% 51%, 50% 66%, 25% 36%, 0 6%);
}

.fit-mark { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); }
.fit-callout { font-size: .92rem; position: absolute; padding-inline: .22rem; background: #fffdf6; }
.fit-callout-best { left: 50%; top: 65%; transform: translate(-50%, -125%); color: var(--learning-rose); }
.fit-callout-worse { right: 0; top: 35%; transform: translateY(-125%); color: var(--learning-rose); }
.fit-callout-train { right: 0; top: 95%; transform: translateY(-125%); color: var(--learning-green); }
.fit-x-ticks {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  margin: .22rem -.32rem 0;
}

.fit-x-title { grid-column: 2; justify-self: end; margin-top: .22rem; }
.fit-observation {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .85rem;
  padding-top: .52rem;
  border-top: 1px solid var(--learning-line);
}

.fit-observation img { width: 3.6rem; height: 2.85rem; object-fit: contain; }
.fit-observation div { display: grid; gap: .18rem; }

@media (max-width: 720px) {
  .reward-scene { grid-template-columns: minmax(0, 1fr); row-gap: .75rem; }
  .reward-results { justify-self: center; width: min(100%, 15rem); }
  .reward-return { margin: 0; }
}
