.sort-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.sort-controls > div { min-width: 0; }
.sort-chart { display: block; width: 100%; height: auto; border: 1px solid var(--line); background: var(--bg); }
.tool .sort-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: 0; list-style: none; }
.sort-legend li { color: var(--fg); }
.sort-legend li::before { content: '■ '; }
.sort-legend .sort-normal::before { color: #9babc0; }
.sort-legend .sort-compare::before { color: #ffd166; }
.sort-legend .sort-swap::before { color: #ff7d91; }
.sort-legend .sort-pivot::before { color: #c59aff; }
.sort-legend .sort-range::before {
  content: '';
  display: inline-block;
  width: .7em;
  height: .7em;
  margin-right: .35em;
  background: #40566b;
  border: 1px solid #8a8a8a;
}
.sort-array-heading { font-size: 1.17em; }
.sort-array-note { margin-top: 0; color: var(--mute); font-size: .9rem; }
.sort-legend .sort-done::before { color: #74d6a4; }
.sort-data { max-height: 12rem; overflow: auto; }
@media (max-width: 480px) { .sort-controls { grid-template-columns: 1fr; } }
.sort-actions { display: flex; flex-wrap: wrap; gap: 0 1rem; position: relative; }
.sort-op { display: inline-flex; align-items: center; position: relative; gap: .35rem; }
.tool .sort-op button { margin-right: 0; }
.tool .sort-help { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 50%; font-size: .8rem; }
.sort-tooltip { position: absolute; top: 100%; right: 0; z-index: 2; width: max-content; max-width: min(18rem, calc(100vw - 4rem)); padding: .6rem .8rem; border: 1px solid var(--mute); border-radius: .4rem; background: var(--bg); color: var(--fg); font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; box-sizing: border-box; }
.sort-op:first-child .sort-tooltip, .sort-op-left .sort-tooltip { left: 0; right: auto; }
.sort-tooltip { font-weight: normal; }
@media (max-width: 640px) {
  .sort-op { position: static; }
  .sort-tooltip { left: 0; right: auto; max-width: 100%; }
}
.sort-op.sort-op-left { position: relative; }
.sort-detail { margin: 0 0 1rem; }
.sort-detail dt { margin-top: .6rem; color: var(--mute); font-family: var(--mono); font-size: .9rem; }
.sort-detail dd { margin: .2rem 0 0; }
