:root {
  --bg: #ffffff;
  --ink: #161616;
  --ink-2: #505050;
  --ink-3: #8c8c8c;
  --rule: #e4e4e4;
  --rule-2: #c9c9c9;
  --wine: #8a1c2b;
  --wine-deep: #6b1320;
  --wine-soft: #c98e96;
  --wine-tint: #f7eaeb;
  --ochre: #b27b10;
  --ochre-tint: #f8ecce;
  --slate-soft: #9eabb7;
  --slate-tint: #e7ebef;

  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --gutter: 40px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--wine);
  outline-offset: 2px;
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Header */

.top {
  border-bottom: 1px solid var(--rule);
}

.top__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 32px;
  padding-top: 20px;
  padding-bottom: 18px;
}

.wordmark {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
}

.topics a {
  color: var(--ink-2);
  text-decoration: none;
}

.topics a:hover {
  color: var(--ink);
}

.topics a[aria-current='true'] {
  color: var(--ink);
  font-weight: 600;
}

/* Title tabs */

.main {
  padding-top: 36px;
  padding-bottom: 80px;
}

.algos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 32px;
  margin: 0 0 24px;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.2;
}

.algos a {
  color: var(--rule-2);
  text-decoration: none;
}

.algos a:hover {
  color: var(--ink-3);
}

.algos a[aria-current='page'] {
  color: var(--ink);
}

/* Inputs */

.inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 28px;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field--grow {
  flex: 1 1 300px;
  max-width: 520px;
}

.field__label {
  font-size: 15px;
  color: var(--ink-2);
}

.field__label .is-error {
  color: var(--wine);
}

.field__row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.text-in {
  height: 36px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--rule-2);
  border-radius: 0;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 14px;
}

.text-in:focus {
  outline: none;
  border-color: var(--ink);
}

.text-in--short {
  width: 76px;
}

.text-in[aria-invalid='true'] {
  border-color: var(--wine);
}

.btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--rule-2);
  border-radius: 0;
  background: var(--bg);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn:disabled {
  color: var(--rule-2);
  cursor: default;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
}

.seg .btn + .btn {
  margin-left: -1px;
}

.seg .btn[aria-pressed='true'] {
  position: relative;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.seg--tight .btn {
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 13px;
}

/* Bench */

.bench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 56px;
  align-items: start;
}

.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  font-size: 15px;
  color: var(--ink-3);
}

.stages li.is-on {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--wine);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.fig {
  margin: 0;
}

.fig__canvas {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fig__canvas svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.fig__cap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  color: var(--ink-2);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sw {
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
  background: var(--bg);
  flex: none;
}

.sw--round { border-radius: 50%; }
.sw--ink { background: var(--ink); }
.sw--wine { background: var(--wine); border-color: var(--wine); }
.sw--wine-tint { background: var(--wine-tint); border-color: var(--wine-soft); }
.sw--ochre { background: var(--ochre-tint); border-color: var(--ochre); }
.sw--slate { background: var(--slate-tint); border-color: var(--slate-soft); }
.sw--faint { border-color: var(--rule-2); }
.sw--line { width: 18px; height: 3px; border: 0; background: var(--ink); }

.msg {
  min-height: 3em;
  margin: 0 0 16px;
  font-size: 19px;
  line-height: 1.5;
  max-width: 64ch;
}

.msg b {
  font-weight: 600;
}

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}

.transport .btn + .btn {
  margin-left: -7px;
}

.btn--play {
  min-width: 84px;
  background: var(--wine);
  border-color: var(--wine);
  color: #fff;
}

.btn--play:hover:not(:disabled) {
  background: var(--wine-deep);
  border-color: var(--wine-deep);
}

.scrub {
  flex: 1 1 120px;
  min-width: 100px;
  height: 20px;
  margin: 0 4px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  --pct: 0%;
}

.scrub::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) var(--pct), var(--rule-2) var(--pct));
}

.scrub::-moz-range-track {
  height: 2px;
  background: var(--rule-2);
}

.scrub::-moz-range-progress {
  height: 2px;
  background: var(--ink);
}

.scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
}

.scrub::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
}

.count {
  min-width: 64px;
  font-size: 15px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.speed {
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--rule-2);
  border-radius: 0;
  background: var(--bg);
  font-size: 15px;
}

/* Side */

.bench__side {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.side__h {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
}

.code {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ln;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.code li {
  counter-increment: ln;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
}

.code li::before {
  content: counter(ln);
  padding-right: 10px;
  text-align: right;
  color: var(--rule-2);
}

.code li.is-gap {
  counter-increment: none;
  height: 10px;
}

.code li.is-gap::before {
  content: '';
}

.code .ln {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code .kw {
  font-weight: 500;
  color: var(--ink);
}

.code li.is-on {
  background: var(--wine-tint);
  color: var(--ink);
}

.code li.is-on::before {
  color: var(--wine);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.table th {
  font-weight: 400;
  color: var(--ink-2);
  padding-right: 12px;
}

.table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table td.is-bad {
  color: var(--wine);
}

.rec {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--ink-2);
}

/* Figures */

.fig svg text {
  font-family: var(--mono);
  fill: var(--ink);
}

.fig svg .t-val {
  font-size: 15px;
  text-anchor: middle;
  dominant-baseline: central;
}

.fig svg .t-small {
  font-size: 11px;
  fill: var(--ink-3);
}

.fig svg .t-mid {
  text-anchor: middle;
}

.fig svg .t-head {
  font-family: var(--serif);
  font-size: 14px;
  fill: var(--ink-2);
}

.fig svg .ptr {
  font-size: 12px;
  font-weight: 500;
  fill: var(--wine);
  text-anchor: middle;
}

.fig svg .ptr-mark {
  fill: var(--wine);
}

.fig svg .link {
  stroke: var(--rule-2);
  stroke-width: 1;
  fill: none;
}

.fig svg .focus {
  fill: none;
  stroke: var(--wine);
  stroke-width: 1.5;
}

.cell rect { fill: var(--bg); stroke: var(--ink); stroke-width: 1; transition: fill 150ms, stroke 150ms; }
.cell.is-sorted rect,
.cell.is-fixed rect { fill: var(--ink); stroke: var(--ink); }
.fig svg .cell.is-sorted text,
.fig svg .cell.is-fixed text { fill: #fff; }
.cell.is-used rect,
.cell.is-spent rect,
.cell.is-out rect { stroke: var(--rule-2); }
.fig svg .cell.is-used text,
.fig svg .cell.is-spent text,
.fig svg .cell.is-out text { fill: var(--ink-3); }
.cell.is-empty rect { fill: none; stroke: var(--ink-3); stroke-dasharray: 3 3; }
.cell.is-le rect { fill: var(--wine-tint); stroke: var(--wine-soft); }
.cell.is-gt rect { fill: var(--slate-tint); stroke: var(--slate-soft); }
.cell.is-pivot rect { fill: var(--wine); stroke: var(--wine); }
.fig svg .cell.is-pivot text { fill: #fff; }
.cell.is-cmp rect { fill: var(--ochre-tint); stroke: var(--ochre); stroke-width: 2; }
.cell.is-write rect,
.cell.is-found rect { fill: var(--wine); stroke: var(--wine); }
.fig svg .cell.is-write text,
.fig svg .cell.is-found text { fill: #fff; }

.bar { transition: transform 300ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.bar .b { fill: var(--rule-2); transition: fill 150ms; }
.bar.is-le .b { fill: var(--wine-soft); }
.bar.is-gt .b { fill: var(--slate-soft); }
.bar.is-pivot .b { fill: var(--wine); }
.bar.is-fixed .b { fill: var(--ink); }
.bar.is-out .b { fill: #eeeeee; }
.bar.is-cmp .b { fill: var(--ochre); }

.lane rect { fill: none; stroke: var(--rule-2); }
.lane.is-waiting rect { stroke: var(--ink-2); }
.lane.is-active rect { fill: var(--wine-tint); stroke: var(--wine); stroke-width: 1.5; }
.lane .pv { fill: var(--ink-3); stroke: none; }
.lane.is-waiting .pv { fill: var(--ink); }
.lane.is-active .pv { fill: var(--wine); }
.fig svg .lane .pv-t { font-size: 10px; fill: #fff; text-anchor: middle; dominant-baseline: central; }
.lane .hit { fill: var(--wine); stroke: none; }

.node circle { fill: var(--bg); stroke: var(--ink); stroke-width: 1.2; transition: fill 150ms, stroke 150ms; }
.fig svg .node text { font-size: 14px; text-anchor: middle; dominant-baseline: central; }
.node.is-path circle { fill: var(--wine-tint); stroke: var(--wine-soft); }
.node.is-cmp circle { fill: var(--ochre-tint); stroke: var(--ochre); stroke-width: 2; }
.node.is-new circle,
.node.is-cur circle { fill: var(--wine); stroke: var(--wine); }
.node.is-stack circle,
.node.is-gray circle { fill: var(--ochre-tint); stroke: var(--ochre); }
.node.is-seen circle,
.node.is-black circle { fill: var(--ink); stroke: var(--ink); }
.fig svg .node.is-new text,
.fig svg .node.is-cur text,
.fig svg .node.is-seen text,
.fig svg .node.is-black text { fill: #fff; }
.node.is-hot circle { stroke: var(--wine); stroke-width: 3; }
.fig svg .node text.badge { font-size: 11px; fill: var(--wine); font-weight: 500; text-anchor: start; }
.fig svg .node text.tag { font-size: 12.5px; fill: var(--ink-2); text-anchor: middle; }
.node .tag-bg { fill: var(--bg); stroke: var(--rule-2); }

.edge { stroke: var(--rule-2); stroke-width: 1.5; transition: stroke 150ms; }
.edge.is-tree { stroke: var(--ink); stroke-width: 3; }
.edge.is-hot { stroke: var(--wine); stroke-width: 3.5; }
.edge-w rect { fill: var(--bg); stroke: var(--rule); }
.fig svg .edge-w text { font-size: 12.5px; fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }
.edge-w.is-hot rect { fill: var(--wine); stroke: var(--wine); }
.fig svg .edge-w.is-hot text { fill: #fff; }

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 1000px) {
  .bench {
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
  }

  .bench__side {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 32px 40px;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  body {
    font-size: 16px;
  }

  .main {
    padding-top: 24px;
  }

  .algos {
    font-size: 26px;
    gap: 2px 20px;
  }

  .msg {
    font-size: 17px;
  }

  .scrub {
    order: 5;
    flex-basis: 100%;
    margin: 6px 0;
  }
}
