.kem-figure {
  --alice: #e4d8f6; --bob: #c7e9d8; --cipher: #ffdf68;
  margin: 0;
}
.kem-board {
  background: radial-gradient(circle, #25271b2a .8px, transparent .95px) 0 0 / 15px 15px, #faf8ef;
  padding: clamp(14px, 3.5%, 22px);
}
.kem-chart { max-width: 410px; margin: 0 auto; }
.kem-chart-heading, .kem-chart-row > div:first-child {
  display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
}
.kem-chart-heading { padding-bottom: 10px; border-bottom: 1px solid #c9c7bc; }
.kem-chart-heading b { font: 700 1.05rem var(--mono); }
.kem-chart-heading span { font: .81rem var(--mono); color: var(--muted); }
.kem-chart-row { margin-top: 12px; }
.kem-chart-row span { font-size: .88rem; font-weight: 600; }
.kem-chart-row strong { font: 600 .86rem var(--mono); }
.kem-chart-track { margin-top: 4px; background: #e6e5dc; border-radius: 2px; height: 10px; }
.kem-bar { display: block; min-width: 2px; border: 1px solid var(--ink); height: 100%; border-radius: 2px; transform-origin: left center; }
.kem-public, .kem-bob { background: var(--bob); }
.kem-private, .kem-alice { background: var(--alice); }
.kem-cipher { background: var(--cipher); }
.kem-secret { background: #8d929a; }
.kem-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kem-lane, .kem-output {
  display: grid; justify-items: center; align-content: center; gap: 4px;
  min-width: 0; border: var(--line); border-radius: 6px; padding: 10px 6px;
  text-align: center; box-shadow: 2px 2px var(--ink);
}
.kem-lane strong { font: 750 1.05rem Archivo, Arial, sans-serif; }
.kem-lane span, .kem-output > span { font-size: .81rem; line-height: 1.35; }
.kem-output > span { font-weight: 600; }
.kem-output code { font: 500 .81rem/1.5 var(--mono); overflow-wrap: anywhere; max-width: 100%; }
.kem-wire {
  --source: 24%; --destination: 76%; --packet-surface: var(--cipher);
  position: relative; height: 80px; text-align: center;
}
.kem-wire-label { padding-top: 11px; font: 600 .74rem var(--mono); }
.kem-reverse { --source: 76%; --destination: 24%; --packet-surface: var(--bob); }
.kem-rail { position: absolute; top: 54px; left: 24%; right: 24%; height: 0; border-top: 2px solid var(--ink); }
.kem-rail::before, .kem-rail::after {
  content: ''; position: absolute; height: 24px; top: -1px; border-left: 1.5px dashed #73746b;
}
.kem-rail::before { left: 0; }
.kem-rail::after { right: 0; }
.kem-rail i {
  position: absolute; display: block; left: 50%; width: 7px; height: 7px; top: -4px;
  border-top: 2px solid var(--ink); border-right: 2px solid var(--ink); transform: rotate(45deg);
}
.kem-reverse .kem-rail i { transform: rotate(225deg); }
.kem-packet {
  position: absolute; top: 54px; left: var(--destination); transform: translate(-50%,-50%);
  display: inline-block; padding: 4px 8px; border: var(--line); border-radius: 6px;
  background: var(--packet-surface); font: 650 .77rem/1.3 var(--mono); text-align: center;
  box-shadow: 1px 2px var(--ink); max-width: 48%;
}
.kem-altered { --packet-surface: #ffd1af; }
.kem-comparison {
  margin: 15px auto 0; max-width: fit-content; padding: 5px 10px; border: 1px solid var(--ink);
  border-radius: 4px; text-align: center; font: 600 .83rem/1.4 var(--mono);
}
.kem-matched { background: var(--bob); }
.kem-different { background: #ffd1af; }
body[data-lab="ml-kem"] #step-results > p { margin-block: 10px; line-height: 1.5; }
@media (prefers-reduced-motion: no-preference) {
  .kem-bar { animation: kem-size .5s ease-out both; }
  .kem-packet { animation: kem-send 1.05s ease-in-out .18s both; }
  .kem-arrival { animation: kem-receive .28s ease-out 1.17s both; }
  .kem-comparison { animation: kem-receive .28s ease-out 1.47s both; }
}
@keyframes kem-send { from { left: var(--source); } to { left: var(--destination); } }
@keyframes kem-size { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes kem-receive { from { opacity: .14; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
