/* The doubled class below keeps later rules ahead of the reset's specificity.

   Fields look like the text around them. Focus, saving and errors change nothing
   that affects layout: no borders, padding, size or font differences between states. */
.magic-paper :is(input:not([type=checkbox], [type=radio], [type=file], [type=range], [type=color], [type=submit], [type=button], [type=reset], [type=hidden], [type=image]), textarea, select) {
  all: unset;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 1lh;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  text-align: inherit;
  text-transform: inherit;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  caret-color: currentColor;
  cursor: text;
  -webkit-tap-highlight-color: transparent;
}

/* iOS zooms the page when a field under 16px takes focus. */
@media (pointer: coarse) {
  .magic-paper :is(input:not([type=checkbox], [type=radio], [type=file], [type=range], [type=color], [type=submit], [type=button], [type=reset], [type=hidden], [type=image]), textarea, select) {
    font-size: max(1em, 16px);
  }
}

.magic-paper.magic-paper textarea {
  field-sizing: content;
  overflow: hidden;
  resize: none;
}

.magic-paper.magic-paper input { white-space: pre; }

.magic-paper.magic-paper select { cursor: pointer; }
.magic-paper.magic-paper select:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.magic-paper ::placeholder { color: currentColor; opacity: .4; }

.magic-paper input::-webkit-outer-spin-button,
.magic-paper input::-webkit-inner-spin-button { appearance: none; margin: 0; }

/* Browser autofill paints its own background unless the transition holds it off. */
.magic-paper input:-webkit-autofill {
  -webkit-text-fill-color: currentColor;
  transition: background-color 86400s;
}

.magic-paper.magic-paper [aria-invalid=true] { box-shadow: 0 2px 0 #c0392b; }

/* Fixed, so showing it can't move the page. */
.magic-paper-status {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  padding: 8px 12px;
  border-radius: 6px;
  background: #c0392b;
  color: #fff;
  font: 14px/1.3 system-ui, sans-serif;
}

.magic-paper-status:empty { display: none; }
