:root {
  font-family: Georgia, serif;
  color: #26261e;
  background: #f7f6ef;
  font-synthesis: none;
  --ink: #26261e;
  --paper: #f7f6ef;
  --accent: #d7fb63;
  --accent-ink: #59652d;
  --olive: #617d1c;
  --muted: #626357;
  --line: #d5d5c7;
  --sans: system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --pad: 40px;
  --stage-h: 220px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
.pg {
  max-width: 1100px;
  margin: auto;
  padding: 0 40px;
}
a {
  color: inherit;
  text-underline-offset: 4px;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
:is(button, input, a, [tabindex]):focus-visible {
  outline: 3px solid #506817;
  outline-offset: 3px;
}
::selection {
  background: var(--accent);
  color: var(--ink);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
  font: 13px var(--sans);
}
header nav {
  display: flex;
  gap: 22px;
}
.brand {
  font-size: 19px;
  font-weight: 650;
  text-decoration: none;
}

.hero {
  text-align: center;
  padding: 64px 0 32px;
}
.eyebrow {
  font: 12px/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 20px;
}
h1 {
  margin: 0;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
  font-size: clamp(34px, 6vw, 72px);
}
h1 code {
  font-family: var(--mono);
  font-weight: 500;
  background: linear-gradient(
    transparent 62%,
    var(--accent) 62%,
    var(--accent) 92%,
    transparent 92%
  );
  padding: 0 0.12em;
}
.lede {
  font: 16px/1.65 var(--sans);
  color: var(--muted);
  max-width: 56ch;
  margin: 24px auto 0;
  text-wrap: pretty;
}

/* Bench: the frame is the container. Everything that changes it lives inside it. */
.bench {
  padding: 24px 0 12px;
}
.frame-scroll {
  padding: 26px 0 18px;
}
.frame {
  --w: 760px;
  position: relative;
  left: 50%;
  width: calc(var(--w) + var(--pad) * 2);
  margin-left: calc((var(--w) + var(--pad) * 2) / -2);
  border: 1px solid var(--ink);
  border-radius: 16px;
  background: #fbfbf5;
  box-shadow: 0 1px 0 #fff inset;
}
.bar {
  position: absolute;
  top: -13px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.bar > * {
  pointer-events: auto;
}
.tools {
  display: flex;
  gap: 6px;
}
.chip {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  background: var(--ink);
  color: #f7f6ef;
  border: 0;
  border-radius: 6px;
  font: 12px/1.2 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip .tag {
  color: #c9d3a3;
}
.chip .cls {
  color: var(--accent);
  margin-right: 4px;
}
.chip.sel {
  position: relative;
  cursor: pointer;
  padding-right: 8px;
}
.chip.sel select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0 14px 0 0;
  cursor: pointer;
  margin: 0;
}
.chip.sel select:focus-visible {
  outline: none;
}
.chip.sel:focus-within {
  box-shadow: 0 0 0 3px #50681766;
}
.chip.sel .caret {
  position: absolute;
  right: 8px;
  pointer-events: none;
  color: #c9d3a3;
}
.chip.tog {
  cursor: pointer;
  color: #c9d3a3;
}
.chip.tog:hover {
  color: #f7f6ef;
}
.chip.tog[aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink);
}
.stage {
  position: relative;
  height: var(--stage-h);
  margin: 40px var(--pad) 0;
  width: var(--w);
}
.frame {
  padding-bottom: 18px;
}
#predictions,
#gutters {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#predictions > div {
  position: absolute;
  top: 18px;
  height: 184px;
}
#predictions > .pred {
  background: #d7fb6399;
  border: 1px solid #71824099;
}
#predictions > .off {
  background: #e2552f;
  opacity: 0.9;
}
#reference {
  position: absolute;
  inset: 0;
  display: flex;
  height: var(--stage-h);
}
.box {
  position: relative;
  height: var(--stage-h);
  min-width: 0;
  box-sizing: border-box;
  outline: 1px dashed #45483a;
  outline-offset: -1px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  font:
    24px Georgia,
    serif;
  color: var(--ink);
  border-radius: 0;
}
.box > .n {
  pointer-events: none;
}
.box:hover {
  outline-style: solid;
  outline-color: #26261e;
}
.box[aria-pressed="true"] {
  outline: 2px solid var(--olive);
  outline-offset: -2px;
}
.box .grip {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 9px;
  cursor: ew-resize;
  z-index: 2;
}
.box .grip::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  height: 34px;
  width: 3px;
  margin-top: -17px;
  border-radius: 2px;
  background: var(--ink);
  opacity: 0;
  transition: opacity 0.12s;
}
.box:hover .grip::after,
.box[aria-pressed="true"] .grip::after,
.grip.active::after {
  opacity: 1;
}
.box .rm {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper);
  font: 13px/1 var(--sans);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 3;
  padding: 0;
}
.box:hover .rm,
.box:focus-within .rm,
.box[aria-pressed="true"] .rm {
  opacity: 1;
}
.box .rm:hover {
  background: var(--ink);
  color: var(--paper);
}
.box .rm:disabled {
  display: none;
}

/* Gutters: gap is hatched, free space is stippled, both are draggable to change the gap. */
#gutters {
  opacity: 0;
  transition: opacity 0.15s;
}
.stage:hover #gutters,
#gutters:focus-within,
.frame.dragging #gutters,
.frame[data-gaps="on"] #gutters {
  opacity: 1;
}
.gut {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: auto;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gut .gap {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    -45deg,
    #7c6cd6 0 2px,
    #7c6cd622 2px 7px
  );
  opacity: 0.55;
  transition: opacity 0.12s;
}
.gut .free {
  position: absolute;
  top: 0;
  bottom: 0;
  background: radial-gradient(#7c6cd6 0.8px, transparent 1px) 0 0/6px 6px;
  opacity: 0.5;
}
.gut:hover .gap,
.gut.active .gap,
.frame.dragging .gut .gap,
.gut:focus-visible .gap {
  opacity: 0.95;
}
.gut .ins {
  position: absolute;
  bottom: -11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper);
  font: 14px/1 var(--sans);
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}
.gut:hover .ins,
.gut:focus-within .ins {
  opacity: 1;
}
.gut .ins:hover {
  background: var(--ink);
  color: var(--paper);
}
.gut .ins:disabled {
  display: none;
}
.gut.lead,
.gut.trail {
  cursor: default;
}

.tip {
  position: absolute;
  top: -8px;
  transform: translate(-50%, -100%);
  padding: 4px 8px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 5px;
  font: 11px/1.3 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
.tip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  margin-left: -4px;
  border: 4px solid transparent;
  border-bottom: 0;
  border-top-color: var(--ink);
}

.labels {
  position: relative;
  height: 22px;
  margin: 4px var(--pad) 0;
  width: var(--w);
  font: 11px/22px var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.labels > span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.labels > span.bad {
  color: #c2442a;
}
.drawer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
  margin: 14px var(--pad) 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #efefe4;
  font: 12px var(--sans);
}
.drawer[hidden] {
  display: none;
}
.drawer .who {
  font:
    15px Georgia,
    serif;
  margin-right: 6px;
}
.drawer .field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer .field > span {
  color: var(--muted);
}
.drawer input[type="number"] {
  width: 64px;
  padding: 5px 6px;
  border: 1px solid #b3b5a2;
  background: #fffef7;
  border-radius: 6px;
  font: 12px var(--mono);
}
.drawer .toggle {
  border: 1px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
}
.drawer .toggle button {
  border: 0;
  background: transparent;
  padding: 5px 9px;
  cursor: pointer;
  font: 12px var(--mono);
  border-right: 1px solid var(--line);
}
.drawer .toggle button:last-child {
  border-right: 0;
}
.drawer .toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--accent);
}
.drawer .meas {
  font: 11px/1.5 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.drawer .meas b {
  color: var(--ink);
  font-weight: 500;
}
.drawer .meas b.bad {
  color: #c2442a;
}
.drawer .rmbtn {
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
  color: var(--muted);
}
.drawer .rmbtn:hover {
  color: var(--ink);
}
.drawer .rmbtn:disabled {
  opacity: 0.4;
  cursor: default;
}

.readout {
  display: flex;
  gap: 8px 20px;
  flex-wrap: wrap;
  align-items: center;
  margin: 14px var(--pad) 0;
  padding: 0;
  font: 12px/1.5 var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.readout #status:empty {
  display: none;
}
.readout .legend {
  margin-right: auto;
}
.readout #error.bad {
  color: #c2442a;
}
.legend {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  color: var(--ink);
}
.legend .swatch,
.legend .outline {
  width: 13px;
  height: 13px;
  display: inline-block;
}
.legend .swatch {
  background: #d7fb6399;
  border: 1px solid #718240;
}
.legend .swatch.off {
  background: #e2552f;
  border-color: #e2552f;
  margin-left: 8px;
}
.legend .outline {
  border: 1px dashed #45483a;
  margin-left: 8px;
}

.handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.handle.left {
  left: -11px;
}
.handle.right {
  right: -11px;
}
.handle span {
  width: 8px;
  height: 44px;
  border-radius: 5px;
  background: var(--paper);
  border: 1px solid var(--ink);
  opacity: 0.9;
  transition:
    transform 0.12s,
    background 0.12s;
}
.handle:hover span,
.handle.active span,
.handle:focus-visible span {
  background: var(--ink);
  transform: scaleY(1.15);
}
.add {
  position: absolute;
  right: -32px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper);
  font: 18px/1 var(--sans);
  cursor: pointer;
  padding: 0;
}
.add:hover {
  background: var(--ink);
  color: var(--paper);
}
.add:disabled {
  opacity: 0.3;
  cursor: default;
}

.about {
  padding: 44px 0 56px;
}
.panel {
  max-width: 66ch;
  margin: auto;
  padding: 36px 40px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbf5;
}
h2 {
  font-size: 26px;
  font-weight: 400;
  margin: 0 0 14px;
}
.panel p {
  font: 14px/1.75 var(--sans);
  color: #515449;
  margin: 0 0 14px;
}
.panel code {
  font-family: var(--mono);
  font-size: 13px;
  background: #eef0e0;
  padding: 1px 5px;
  border-radius: 4px;
}
.panel .links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 22px 0 0;
  color: var(--ink);
}
footer {
  padding: 22px 0 30px;
  border-top: 1px solid var(--line);
  font: 12px var(--sans);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 700px) {
  .pg {
    padding: 0 16px;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  header nav {
    gap: 16px;
    flex-wrap: wrap;
  }
  .hero {
    padding: 44px 0 28px;
  }
  .frame-scroll {
    padding: 22px 0 14px;
  }
  .frame {
    --pad: 24px;
  }
  .add {
    width: 20px;
    height: 20px;
    right: -23px;
    font-size: 15px;
  }
  .bar {
    position: static;
    flex-wrap: wrap;
    padding: 14px 16px 0;
  }
  .stage {
    margin-top: 22px;
  }
  .drawer .meas {
    margin-left: 0;
    flex-basis: 100%;
  }
  .panel {
    padding: 26px 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
