html .article-body .ori-counting {
  --walk-success: #82c89c;
  --walk-success-wash: rgba(105, 190, 137, .12);
  container-type: inline-size;
  width: 100%;
  min-width: 0;
  margin: 1.6rem 0;
  overflow: hidden;
  border: 1px solid var(--float-edge);
  border-top-color: var(--float-edge-top);
  border-radius: 14px;
  background: var(--float-surface);
  box-shadow: var(--float-shadow);
  color: var(--text);
}
html .article-body .ori-counting-header { flex-wrap: nowrap; }
.ori-counting-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ori-counting-header .code-actions { flex: 0 0 auto; flex-wrap: nowrap; }
.ori-counting-body {
  display: grid;
  gap: clamp(.8rem, 2vw, 1.25rem);
  padding: clamp(.75rem, 2.6vw, 1.6rem);
  background: rgb(var(--tone-code, 27 27 29));
}
.ori-counting-call, .ori-counting-output {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .8rem;
  min-width: 0;
}
.ori-counting-call span, .ori-counting-output span, .ori-counting-label {
  color: var(--text-soft);
  font-size: .95rem;
}
.article-body .ori-counting code {
  color: #efedee;
  background: transparent;
  padding: 0;
  font: clamp(.96rem, 1.4vw, 1.08rem)/1.5 var(--mono);
  overflow-wrap: anywhere;
  min-width: 0;
}
.ori-counting-track { position: relative; }
.ori-counting-letters {
  display: grid;
  grid-template-columns: repeat(var(--sequence-length), minmax(0, 1fr));
  border-radius: .5rem;
  overflow: hidden;
  font: 650 clamp(1.18rem, 4.5vw, 2rem)/1 var(--mono);
}
.ori-counting-letters span {
  background: rgba(255,255,255,.035);
  border-right: 1px solid rgb(var(--tone-code, 27 27 29));
  text-align: center;
  padding: clamp(.65rem, 2vw, .95rem) 0;
  color: #c7c3c5;
}
/* Keep letters readable as text; the coloured fills are an additional cue. */
.ori-counting-letters [data-base="A"] { color: #a8dbb4; background: #a8dbb414; }
.ori-counting-letters [data-base="C"] { color: #a7cdf6; background: #a7cdf614; }
.ori-counting-letters [data-base="G"] { color: #f2cc91; background: #f2cc9114; }
.ori-counting-letters [data-base="T"] { color: #e3b9f4; background: #e3b9f414; }
.ori-counting-letters [data-active] { font-weight: 750; }
.ori-counting-window {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(100% / var(--sequence-length) * var(--scan-width));
  transform: translateX(calc(100% / var(--scan-width) * var(--scan-start)));
  border: 1px solid #e75055;
  border-radius: .42rem;
  background: rgba(232,76,81,.11);
  transition: transform 220ms ease, opacity 160ms ease, background-color 140ms ease, border-color 140ms ease;
  pointer-events: none;
}
.ori-counting[data-state="complete"] .ori-counting-window { opacity: 0; }
.ori-counting-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .15rem .7rem;
  color: var(--text-soft);
  font: .96rem/1.45 var(--mono);
}
.ori-counting-status strong { color: var(--text); }
.ori-counting-work {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: start;
  gap: .85rem;
}
.ori-counting-code { display: grid; gap: .2rem; }
.article-body .ori-counting .ori-counting-code code {
  padding: .3rem .4rem .3rem .55rem;
  border-left: 2px solid transparent;
  color: #c7c3c5;
}
.ori-counting[data-state="scanning"] .ori-counting-code code:is([data-line="scan"],[data-line="update"]),
.ori-counting[data-state="complete"] .ori-counting-code code[data-line="return"] {
  border-left-color: #e75055;
  background: rgba(232,76,81,.08);
  color: #fff;
}
.ori-counting-tallies {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.7rem, 1fr));
  gap: .35rem;
  margin-top: .35rem;
}
.ori-counting-tallies div {
  display: flex;
  justify-content: space-between;
  gap: .3rem;
  padding: .32rem .4rem;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: .4rem;
  font: .98rem/1.35 var(--mono);
}
.ori-counting-tallies [data-current], .ori-counting-tallies [data-winner] {
  background: rgba(232,76,81,.10);
  border-color: #e75055;
}
.ori-counting-output {
  padding-top: .65rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.ori-counting[data-state="complete"] .ori-counting-output code { color: #ffc3c5; }
@media (max-width: 700px) {
  .ori-counting-work { grid-template-columns: minmax(0, 1fr); gap: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ori-counting-window { transition: none; }
}

.ori-code-keyword { color: #d4a9ef; }
.ori-code-fn { color: #9cccf2; }
.ori-code-number { color: #f2c88e; }
.ori-counting-modal {
  padding: 0;
  border: 0;
  width: min(1040px, calc(100vw - 1.1rem));
  max-width: none;
  max-height: calc(100dvh - 1.1rem);
  background: transparent;
  color: var(--text);
  border-radius: 14px;
  overflow: auto;
}
.ori-counting-modal::backdrop { background: rgba(0,0,0,.72); }
html .article-body .ori-counting-modal .ori-counting { margin: 0; }
@media (max-width: 700px) {
  .ori-counting-status { justify-content: flex-start; }
  .ori-counting-call code { flex: 1 1 100%; }
}

/* Exact matches and updated counts have a separate cue from the scan. */
.ori-counting[data-match] .ori-counting-window {
  border-color: var(--walk-success);
  background-color: var(--walk-success-wash);
}
.article-body .ori-counting[data-match] .ori-counting-code code:is([data-line="update"], [data-line="increment"]) {
  border-left-color: var(--walk-success);
  background: var(--walk-success-wash);
  color: #edf9ef;
}
.ori-counting-tallies [data-current] {
  border-color: var(--walk-success);
  background: var(--walk-success-wash);
}
.ori-counting-tallies [data-current] strong,
.ori-counting[data-match] [data-action] { color: var(--walk-success); }

.ori-counting[data-kmer-walk="one"] .ori-counting-work {
  grid-template-columns: minmax(0, 1fr) max-content;
}
.ori-counting[data-kmer-walk="one"] .ori-counting-counts { min-width: 0; }
.ori-counting[data-kmer-walk="one"] .ori-counting-tallies { grid-template-columns: auto; }
.ori-counting[data-kmer-walk="one"] .ori-counting-tallies div { gap: .8rem; }
@container (max-width: 665px) {
  .ori-counting[data-kmer-walk="one"] .ori-counting-work { grid-template-columns: minmax(0, 1fr); }
  .ori-counting[data-kmer-walk="one"] .ori-counting-counts { width: max-content; max-width: 100%; }
}

/* Keep enough room for the complete frequency update line. */
.ori-counting[data-kmer-walk="all"] .ori-counting-work {
  grid-template-columns: minmax(0, 1fr) 7.5rem;
}
.ori-counting[data-kmer-walk="all"] .ori-counting-tallies {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@container (max-width: 715px) {
  .ori-counting[data-kmer-walk="all"] .ori-counting-work { grid-template-columns: minmax(0, 1fr); }
  .ori-counting[data-kmer-walk="all"] .ori-counting-tallies {
    grid-template-columns: repeat(auto-fit, minmax(3.7rem, 1fr));
  }
}

.ori-counting-tallies > div:not([data-word]) { visibility: hidden; }

/* Keep the same number of lines even when the closing message is longer. */
@container (max-width: 460px) {
  .ori-counting-status { display: grid; }
}
