* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -ms-user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  user-select: none;
}

body,
html {
  height: 100%;
}

html,
input,
button {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Ubuntu, Roboto,
    Helvetica, Arial, sans-serif;
}

textarea {
  -ms-user-select: text;
  -moz-user-select: text;
  -webkit-user-select: text;
  user-select: text;
}

button {
  padding: 0.3rem 1rem;
  background: #ccc;
  border: 0;
  transition: background-color 0.2s;
}
button:hover,
button:focus {
  background: #bbb;
  transition: none;
  outline: none;
}
button:active {
  background: #aaa;
}

a,
img {
  -webkit-user-drag: none;
  user-drag: none;
}

.hide {
  opacity: 0;
  pointer-events: none;
}

#grid {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#grid ol {
  display: grid;
  position: relative;
  list-style: none;
}
#grid.arrow ol {
  cursor: crosshair;
}
#grid.pan ol {
  cursor: -webkit-grab;
}
#grid.pan:active ol {
  cursor: -webkit-grabbing;
}
#grid ul {
  position: absolute;
  list-style: none;
  left: 0;
  top: 0;
  height: 0;
  width: 0;
}

.grid-cell {
  position: relative;
  display: grid;
  border: 2px dashed #ccc;
  border-top: none;
  border-left: none;
  overflow: hidden;
  white-space: nowrap;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.grid-cell.moving {
  background: white;
  box-shadow: 0 5px 1rem rgba(0, 0, 0, 0.3);
  transform: scale(1.1);
}
.grid-cell.selected {
  background: #eee;
  outline: none;
}
.grid-cell .grabber {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 12px;
  height: 12px;
  cursor: move;
  opacity: 0;
  pointer-events: none;
}
.grid-cell .loop {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}
.pan .grid-cell:hover .grabber,
.arrow .grid-cell:hover .loop {
  opacity: 1;
  pointer-events: all;
}
.grid-cell .value {
  margin: auto;
}
.grid-cell.edit .value {
  opacity: 0;
  pointer-events: none;
}
.grid-cell .edit {
  display: flex;
  align-items: center;
  position: absolute;
  width: 100%;
  height: 100%;
}
.grid-cell .edit input {
  border: none;
  outline: none;
  width: 100%;
  text-align: center;
  background: transparent;
  font: 1rem/1.5 Consolas, monospace;
}

.grid-arrow {
  position: absolute;
  pointer-events: none;
}
.grid-arrow svg {
  display: block;
}
.grid-arrow svg .mouse {
  transition: stroke 0.1s;
}
.arrow .grid-arrow:not(.phantom) svg .mouse {
  pointer-events: all;
}
.arrow .grid-arrow svg .mouse:hover {
  stroke: rgba(204, 204, 204, 0.6);
}
.grid-arrow.selected svg .mouse.mouse {
  stroke: rgb(204, 204, 204);
}
.grid-arrow .value {
  position: absolute;
  white-space: nowrap;
}
.grid-arrow .value.inside {
  padding: 0 5px;
  background: white;
}

.toolbox {
  position: absolute;
  left: 50%;
  padding: 0 0.5em;
  background: rgba(221, 221, 221, 0.7);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
}
.toolbox ul {
  line-height: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  list-style: none;
}
.toolbox li.separator {
  margin: 0 0.5em;
  width: 2px;
  background: #aaa;
  text-indent: -9999em;
}
.toolbox li.button a {
  cursor: default;
  transition: background-color 0.2s;
}
.toolbox li.button a:hover,
.toolbox li.button a:focus {
  background: #ccc;
  transition: none;
}
.toolbox li.button a:active {
  background: #aaa;
}
.toolbox li.button.checked a {
  background: #bbb;
}
.toolbox li.button.disabled a {
  opacity: 0.4;
  pointer-events: none;
}
.toolbox li.button a {
  display: block;
  padding: 0.5em;
}
.toolbox li.button img {
  display: block;
  background-size: 100%;
  background-position: center;
  width: 24px;
  height: 24px;
  transition: background-image 0.2s;
}

#toolbox {
  bottom: 2em;
}

#properties {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}
#properties.edit {
  pointer-events: all;
}
#properties .edit {
  border-radius: 5px;
  position: absolute;
  width: 130px;
  padding: 0.3em 1em;
  background: rgba(57, 57, 57, 0.9);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.7) translate(0, 100%);
  transition: opacity 0.1s, transform 0.1s;
}
#properties .edit::after {
  content: '';
  display: block;
  position: absolute;
  left: calc(50% - 10px);
  bottom: -10px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgb(77, 77, 77);
}
#properties.edit .edit {
  opacity: 1;
  transform: scale(1);
}
#properties .edit input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: white;
  font: 1rem/1.5 Consolas, monospace;
  text-align: center;
}
#properties .toolbox {
  top: calc(-16px - 2em);
  background: rgba(0, 0, 0, 0.7);
  transition: top 0.2s;
  pointer-events: all;
}
#properties.show .toolbox {
  top: 1em;
}
#properties li.button a:hover,
#properties li.button a:focus {
  background: #0050c0;
}
#properties li.button a:active {
  background: #0030a0;
}
#properties li.button.checked a {
  background: #2272e2;
}
#properties li.button.remove a:hover,
#properties li.button.remove a:focus {
  background: #e81123;
}
#properties li.button.remove a:active {
  background: #c60001;
}
#properties li.button img {
  width: 16px;
  height: 16px;
  filter: invert(100%);
}
#properties li.separator {
  background: rgba(255, 255, 255, 0.4);
}

#modal-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0);
  visibility: hidden;
  transition: background-color 0.2s;
}
#modal-overlay.show {
  visibility: visible;
  background: rgba(255, 255, 255, 0.5);
}
#modal-overlay .modal-box {
  background: rgba(221, 221, 221, 0.7);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
  padding: 1rem;
  opacity: 0;
  transform: scale(0.9) translateY(5rem);
  transition: transform 0.2s, opacity 0.2s;
}
#modal-overlay.show .modal-box {
  opacity: 1;
  transform: none;
}

.code-box textarea {
  display: block;
  padding: 0.5rem;
  border: none;
  resize: none;
  width: 62vw;
  height: 50vh;
  font: 1rem/1.5 Consolas, monospace;
  background: #393939;
  color: white;
  white-space: pre;
}
.code-box textarea:focus {
  outline: 2px solid #4494f4;
}
.code-box .buttons {
  display: flex;
  justify-content: flex-end;
  list-style: none;
  margin-top: 1rem;
}
.code-box .buttons li:not(:first-child) {
  margin-left: 0.5rem;
}
.code-box .buttons li.separator {
  flex: 1;
}

mjx-merror {
  color: inherit !important;
  background-color: transparent !important;
  padding: 2px;
  border: 1px solid black;
}
