.mk {
  --ink: #132330;
  --ground: #a4c3dc;
  position: relative;
  width: 540px;
  height: 540px;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font-family: "DM Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.mk-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The photograph: the key on its base, with the lever cut out so it can turn. */
.mk-photo {
  position: absolute;
  left: -10px;
  top: 12px;
  width: 553px;
  height: 553px;
  background: url("./key.jpg") 0 0 / 100% 100% no-repeat;
  -webkit-mask-image: linear-gradient(#0000, #000 60px);
  mask-image: linear-gradient(#0000, #000 60px);
  pointer-events: none;
}

.mk-lever {
  position: absolute;
  left: 30.24px;
  top: 292.14px;
  width: 511.92px;
  height: 100.98px;
  transform-origin: 239.22px 85.05px;
  transform: rotate(-2.3deg);
  will-change: transform;
}

.mk-bracket {
  position: absolute;
  left: 244.08px;
  top: 344.52px;
  width: 50.76px;
  height: 54px;
}

.mk-key {
  position: absolute;
  left: 20px;
  top: 292px;
  width: 500px;
  height: 232px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  outline: none;
  touch-action: none;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}

.mk-key:focus-visible::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 6px;
  bottom: 6px;
  height: 2px;
  background: var(--ink);
}

/* The field: what has been keyed, and the marks of the letter in hand. */
.mk-field {
  position: absolute;
  left: 60px;
  top: 28px;
  width: 420px;
  height: 58px;
  border-bottom: 1.5px solid var(--ink);
  z-index: 1;
}

.mk-field:has(.mk-input:focus-visible) {
  box-shadow: 0 1.5px 0 var(--ink);
}

.mk-input,
.mk-ghost {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 0 40px 0 0;
  font: 500 34px/58px "DM Mono", ui-monospace, monospace;
  letter-spacing: -0.01em;
}

.mk-input {
  border: 0;
  background: none;
  color: var(--ink);
  caret-color: var(--ink);
  outline: none;
  user-select: text;
}

.mk-input::placeholder {
  color: rgb(19 35 48 / 0.42);
  font-weight: 400;
}

/* Marks keyed into an empty field take the placeholder's place. */
.mk-field:has(.mk-comp[data-keying]) .mk-input::placeholder {
  color: transparent;
}

.mk-ghost {
  display: flex;
  align-items: center;
  white-space: pre;
  pointer-events: none;
}

.mk-typed {
  visibility: hidden;
}

.mk-comp {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 9px;
  height: 100%;
}

.mk-typed:empty + .mk-comp {
  margin-left: 1px;
}

.mk-comp i {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--ink);
}

.mk-clear {
  position: absolute;
  right: 0;
  top: 15px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

.mk-clear svg {
  display: block;
  width: 16px;
  height: 16px;
  margin: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.mk-clear:focus-visible {
  box-shadow: 0 0 0 1.5px var(--ink);
}

/* The suggestions: set on the backdrop, under the field. */
.mk-content {
  position: absolute !important;
  inset: 98px auto auto 60px !important;
  width: 420px !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  transform: none !important;
  translate: none !important;
  overflow: visible;
  box-shadow: none;
}

.mk-content[hidden] {
  display: none;
}

.mk-list {
  max-height: 180px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  scrollbar-width: none;
  list-style: none;
  outline: none;
}

.mk-list::-webkit-scrollbar {
  display: none;
}

.mk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  height: 36px;
  padding: 0 10px 0 0;
  border-bottom: 1px solid rgb(19 35 48 / 0.16);
  font-size: 18px;
  color: rgb(19 35 48 / 0.72);
  cursor: pointer;
  outline: none;
}

.mk-item b {
  font-weight: 500;
  color: var(--ink);
}

.mk-item[data-highlighted] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.mk-code {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.55;
}

.mk-item[data-highlighted] .mk-code {
  opacity: 1;
}

.mk-code i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 2.5px;
  background: currentColor;
}

.mk-code i[data-k="-"] {
  width: 15px;
}

.mk-empty:empty {
  display: none;
}

.mk-empty {
  height: 36px;
  font-size: 18px;
  line-height: 36px;
  color: rgb(19 35 48 / 0.62);
}
