/* Inputs, labels and form layout. */
input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Every text-like input, whatever its type; checkboxes, radios and files are styled separately. */
/* :where() keeps this base rule at element specificity, so a component can
   restyle its input with a plain class selector. */
input:where(:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit])),
select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  /* The lighter line: a field is a place to write, not a thing to look at, so
     it is drawn quietly and the text inside it carries the weight. */
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
}

/* Every checkbox is a round one: the native box is replaced with a circle
   that fills in ink and shows a tick when checked. The settings toggle
   switch hides its own checkbox and is exempt (see settings.css). */
input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border-radius: 4px;
  border: 1.5px solid var(--muted);
  background: var(--card);
  display: inline-grid;
  place-items: center;
  flex: none;
  cursor: pointer;
  transition: background .15s,border-color .15s;
}

input[type=checkbox]::before {
  content: "";
  width: 8px;
  height: 5px;
  border-left: 2px solid var(--ink-text);
  border-bottom: 2px solid var(--ink-text);
  transform: translateY(-1px) rotate(-45deg);
  opacity: 0;
}

/* The box stays 16px, but an invisible ::after reaches 4px past every edge so
   the target is 24px square, the WCAG 2.5.8 minimum. (::before is the tick.) */
input[type=checkbox] {
  position: relative;
}

input[type=checkbox]::after {
  content: "";
  position: absolute;
  inset: -4px;
}

input[type=checkbox]:checked {
  background: var(--ink);
  border-color: var(--ink);
}

input[type=checkbox]:checked::before {
  opacity: 1;
}

textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  resize: vertical;
}

/* Selects drop the browser arrow for a clear chevron, sized to the field and
   set 16px in from the edge, so it reads as part of the control. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M3.5 6 8 10.5 12.5 6' fill='none' stroke='%23111114' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px 16px;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M3.5 6 8 10.5 12.5 6' fill='none' stroke='%23f2f3f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

.field {
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.code-input {
  letter-spacing: .35em;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.code-input-sm {
  letter-spacing: .3em;
  text-align: center;
  font-weight: 600;
}

/* iOS Safari zooms the page whenever a field smaller than 16px takes focus,
   which throws the phone layout out and leaves the page zoomed after the
   popup closes. Every text control is 16px on a phone; the field keeps its
   own size wherever a component sets one with a class (.code-input, the
   search field). */
@media (max-width:900px) {
  input:where(:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit])),
  select,
  textarea {
    font-size: 16px;
  }
}

/* Coarse pointers get a comfortable tick box without changing the design on a
   mouse: the box itself is untouched, only the invisible target grows. */
@media (pointer:coarse) {
  input[type=checkbox]::after {
    inset: -8px;
  }
}
