html, body {
  margin: 0;
  height: 100%;
}

#viewer {
  position: relative;
  width: 60vw;
  height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: #f0f0f0;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
}

#ui {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  font: 14px/1.2 system-ui, sans-serif;
  padding: 8px;
}

#ui .frame {
  margin: 0 auto;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
}

#title {
  margin: 0 0 10px 0;
  font-size: 18px;
  line-height: 1.2;
  text-align: center;
}

.toolbar {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0;
  flex-wrap: nowrap;
}

#patternForm {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.download {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
}

.fields {
  display: grid;
  grid-template-columns: 20ch minmax(0, 1fr);
  gap: 10px 14px;
  align-items: end;
}

.field {
  text-align: left;
}

.field label {
  display: block;
  margin: 0 0 4px 0;
  font-weight: 600;
}

.field input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
}

#pattern {
  max-width: 20ch;
  width: min(100%, 20ch);
}

#patterntext {
  margin-right: calc(-1 * var(--dlw, 0px));
  padding-right: 8px;
}

.actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: nowrap;
}

.button {
  box-sizing: border-box;
  display: inline-block;
  padding: 8px 12px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.button:focus {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.button:disabled {
  background: #93a3b8;
  cursor: not-allowed;
}

#progressWrap {
  display: none;
  margin-top: 10px;
  text-align: left;
}

#pb {
  width: 100%;
  height: 14px;
  vertical-align: middle;
}

#pblabel {
  display: inline-block;
  margin-top: 4px;
}

#testResult {
  font-size: 13px;
  align-self: center;
  white-space: pre-line;
  flex: 1 1 auto;
  min-width: 0;
}

#testResult.ok {
  color: #0a7a0a;
}

#testResult.err {
  color: #c00;
}