.textfield-outlined {
  --helper-theme: rgb(var(--theme-rgb, var(--primary-rgb, 33, 150, 243)));
  --helper-safari1: rgba(var(--on-surface-rgb, 0, 0, 0), 0.38);
  --helper-safari2: rgba(var(--on-surface-rgb, 0, 0, 0), 0.6);
  --helper-safari3: rgba(var(--on-surface-rgb, 0, 0, 0), 0.87);
  position: relative;
  display: inline-block;
  padding-top: 6px;
  font-family: var(
    --font-family,
    'Roboto',
    'Segoe UI',
    BlinkMacSystemFont,
    system-ui,
    -apple-system
  );
  font-size: var(--font-size, 18px);
  line-height: 1.5;
}

/* Input, Textarea */
.textfield-outlined > input,
.textfield-outlined > textarea {
  box-sizing: border-box;
  margin: 0;
  border-style: solid;
  border-width: 2px;
  border-color: transparent var(--helper-safari2) var(--helper-safari2);
  border-radius: 4px;
  padding: 15px 13px 15px;
  width: 100%;
  height: inherit;
  color: rgba(var(--on-surface-rgb, 0, 0, 0), 0.87);
  -webkit-text-fill-color: currentColor; /* Safari */
  background-color: transparent;
  box-shadow: inset 1px 0 transparent, inset -1px 0 transparent,
    inset 0 -1px transparent;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  caret-color: var(--helper-theme);
  transition: border 0.2s, box-shadow 0.2s;
}

.textfield-outlined > input:not(:focus):placeholder-shown,
.textfield-outlined > textarea:not(:focus):placeholder-shown {
  border-top-color: var(--helper-safari2);
}

/* Span */
.textfield-outlined > input + span,
.textfield-outlined > textarea + span {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: 100%;
  max-height: 100%;
  color: rgba(var(--on-surface-rgb, 0, 0, 0), 0.6);
  font-size: 75%;
  line-height: 15px;
  cursor: text;
  transition: color 0.2s, font-size 0.2s, line-height 0.2s;
}

.textfield-outlined > input:not(:focus):placeholder-shown + span,
.textfield-outlined > textarea:not(:focus):placeholder-shown + span {
  font-size: inherit;
  line-height: 68px;
}

/* Corners */
.textfield-outlined > input + span::before,
.textfield-outlined > input + span::after,
.textfield-outlined > textarea + span::before,
.textfield-outlined > textarea + span::after {
  content: '';
  display: block;
  box-sizing: border-box;
  margin-top: 6px;
  border-top: solid 1px var(--helper-safari2);
  min-width: 10px;
  height: 8px;
  pointer-events: none;
  box-shadow: inset 0 1px transparent;
  transition: border 0.2s, box-shadow 0.2s;
}

.textfield-outlined > input + span::before,
.textfield-outlined > textarea + span::before {
  margin-right: 4px;
  border-left: solid 1px transparent;
  border-radius: 4px 0;
}

.textfield-outlined > input + span::after,
.textfield-outlined > textarea + span::after {
  flex-grow: 1;
  margin-left: 4px;
  border-right: solid 1px transparent;
  border-radius: 0 4px;
}

.textfield-outlined > input:not(:focus):placeholder-shown + span::before,
.textfield-outlined > textarea:not(:focus):placeholder-shown + span::before,
.textfield-outlined > input:not(:focus):placeholder-shown + span::after,
.textfield-outlined > textarea:not(:focus):placeholder-shown + span::after {
  border-top-color: transparent;
}

/* Hover */
.textfield-outlined:hover > input,
.textfield-outlined:hover > textarea {
  border-color: transparent var(--helper-safari3) var(--helper-safari3);
}

.textfield-outlined:hover > input + span::before,
.textfield-outlined:hover > textarea + span::before,
.textfield-outlined:hover > input + span::after,
.textfield-outlined:hover > textarea + span::after {
  border-top-color: var(--helper-safari3);
}

.textfield-outlined:hover > input:not(:focus):placeholder-shown,
.textfield-outlined:hover > textarea:not(:focus):placeholder-shown {
  border-color: var(--helper-safari3);
}

/* Focus */
.textfield-outlined > input:focus,
.textfield-outlined > textarea:focus {
  border-color: transparent var(--helper-theme) var(--helper-theme);
  box-shadow: inset 1px 0 var(--helper-theme), inset -1px 0 var(--helper-theme),
    inset 0 -1px var(--helper-theme);
  outline: none;
}

.textfield-outlined > input:focus + span,
.textfield-outlined > textarea:focus + span {
  color: var(--helper-theme);
}

.textfield-outlined > input:focus + span::before,
.textfield-outlined > input:focus + span::after,
.textfield-outlined > textarea:focus + span::before,
.textfield-outlined > textarea:focus + span::after {
  border-top-color: var(--helper-theme) !important;
  box-shadow: inset 0 1px var(--helper-theme);
}

/* Disabled */
.textfield-outlined > input:disabled,
.textfield-outlined > input:disabled + span,
.textfield-outlined > textarea:disabled,
.textfield-outlined > textarea:disabled + span {
  border-color: transparent var(--helper-safari1) var(--helper-safari1) !important;
  color: rgba(var(--on-surface-rgb, 0, 0, 0), 0.38);
  pointer-events: none;
}

.textfield-outlined > input:disabled + span::before,
.textfield-outlined > input:disabled + span::after,
.textfield-outlined > textarea:disabled + span::before,
.textfield-outlined > textarea:disabled + span::after {
  border-top-color: var(--helper-safari1) !important;
}

.textfield-outlined > input:disabled:placeholder-shown,
.textfield-outlined > input:disabled:placeholder-shown + span,
.textfield-outlined > textarea:disabled:placeholder-shown,
.textfield-outlined > textarea:disabled:placeholder-shown + span {
  border-top-color: var(--helper-safari1) !important;
}

.textfield-outlined > input:disabled:placeholder-shown + span::before,
.textfield-outlined > input:disabled:placeholder-shown + span::after,
.textfield-outlined > textarea:disabled:placeholder-shown + span::before,
.textfield-outlined > textarea:disabled:placeholder-shown + span::after {
  border-top-color: transparent !important;
}

/* Faster transition in Safari for less noticable fractional font-size issue */
@media not all and (min-resolution: 0.001dpcm) {
  @supports (-webkit-appearance: none) {
    .textfield-outlined > input,
    .textfield-outlined > input + span,
    .textfield-outlined > textarea,
    .textfield-outlined > textarea + span,
    .textfield-outlined > input + span::before,
    .textfield-outlined > input + span::after,
    .textfield-outlined > textarea + span::before,
    .textfield-outlined > textarea + span::after {
      transition-duration: 0.1s;
    }
  }
}
