/* Native select interaction, with the same 12px inset on text and arrow. */
select,
.preferences select,
.navigation-dialog .preferences select,
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-inline: 12px 40px;
  background-image: url("assets/chevron-down.svg");
  background-repeat: no-repeat;
  background-size: 16px 16px;
  background-position: right 12px center;
}
@media (forced-colors: active) {
  select,
  .preferences select,
  .navigation-dialog .preferences select,
  select.input {
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
    padding-inline: 12px;
  }
}

/* Checkboxes share the field boundary; keep the native input and keyboard behaviour. */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  border: var(--control-border-width) solid var(--control-border);
  border-radius: 4px;
  background: var(--surface);
  color: #fff;
  cursor: pointer;
}
input[type="checkbox"]::before {
  content: "";
  width: 5px;
  height: 9px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
  visibility: hidden;
}
input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate {
  background: var(--brand);
  border-color: var(--brand);
}
input[type="checkbox"]:checked::before,
input[type="checkbox"]:indeterminate::before {
  visibility: visible;
}
input[type="checkbox"]:indeterminate::before {
  width: 9px;
  height: 2px;
  border: 0;
  background: currentColor;
  transform: none;
}
html[data-theme="dark"] input[type="checkbox"] {
  color: var(--navy);
}
.input:focus-visible,
select.input:focus-visible,
.preferences select:focus-visible,
input[type="checkbox"]:focus-visible {
  border-color: var(--brand);
}
.input[aria-invalid="true"],
input[type="checkbox"][aria-invalid="true"] {
  border-color: var(--danger);
}
input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@media (forced-colors: active) {
  input[type="checkbox"] {
    appearance: auto;
    -webkit-appearance: auto;
    background: revert;
    color: revert;
  }
  input[type="checkbox"]::before {
    content: none;
  }
}
/* Quiet at rest; increased definition only when interacting or requested. */
@media (hover: hover) and (pointer: fine) {
  .input:hover:not(:focus-visible):not([aria-invalid="true"]),
  select.input:hover:not(:focus-visible):not([aria-invalid="true"]),
  .preferences select:hover:not(:focus-visible),
  input[type="checkbox"]:hover:not(:focus-visible):not(:checked):not(
      :indeterminate
    ):not(:disabled):not([aria-invalid="true"]) {
    border-color: var(--control-border-hover);
  }
}
@media (prefers-contrast: more) {
  :root {
    --control-border: #52627a;
  }
  html[data-theme="dark"] {
    --control-border: #a8b5cc;
  }
}
